openresty / openresty/encrypted-session-nginx-module
Use an HMAC, not a simple MD5 hash
Nobody has claimed this yet.
- Dominant language
- C
- Stars
- 203
- Forks
- 50
- Avg merge
- 1h 25m
- Merged PRs (30d)
- 2
Description
The code, as-is, simply generates an MD5 hash of the data, which is trivially forgeable by an attacker.
Because the authenticity of the session cookie is not guaranteed, the CBC encryption used by this module is vulnerable to padding oracle attacks, which can trivially recover the plaintext of a session cookie.
You should:
- Use an HMAC construction, not a simple MD5 hash. OpenSSL provides this.
- Use a different key than the key used for encryption.
- Create an HMAC of the encrypted data, not of the plaintext.
- Use a constant-time comparison algorithm when validating the HMAC to avoid timing attacks.
(Or use an authenticated AES mode like GCM, but this will require OpenSSL 1.0.1+.)
For more details, please see Moxie's blog post on the 'doom principle'.
Contributor guide
No contributing guide indexed for this repository
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start by locating the module's session-cookie encryption and validation paths and reviewing its OpenSSL integration. Check how the current MD5 value is produced and verified. Done means encrypted data is authenticated with a separate HMAC key, verification uses a constant-time comparison, and the relevant security behavior is covered by available tests.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- c
- Domain
- cryptography, security
- Issue type
- Bug
- Difficulty
- 5/5
- Estimated time
- Over a week
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 28/100