Skip to content

Treat a wrong-length unwrapped CEK like an unwrap failure in jwe.decrypt - #428

Open
neeraj1235476 wants to merge 1 commit into
mpdavis:masterfrom
neeraj1235476:jwe-cek-length-oracle
Open

neeraj1235476 wants to merge 1 commit into
mpdavis:masterfrom
neeraj1235476:jwe-cek-length-oracle

Conversation

@neeraj1235476

Copy link
Copy Markdown

jwe.decrypt substitutes a random CEK when unwrap_key raises, but a CEK that unwraps cleanly is never checked against the length enc requires. With RSA1_5, a ciphertext that has valid PKCS#1 v1.5 padding but the wrong payload length fails with Key must be 256 bit for alg A256GCM, while bad padding falls through to the random CEK and fails with Invalid JWE Auth Tag. That difference is a Bleichenbacher padding oracle on the recipient's RSA key. It is clean with the rsa backend and pre-3.2 OpenSSL. With implicit rejection in newer OpenSSL it is narrower but still present. RFC 7516 section 11.5 says the recipient must not distinguish format, padding and length errors, and the existing comment in decrypt already quotes that.

The random-CEK substitution now runs after the unwrap and also replaces a CEK whose length doesn't match enc, so all three cases fail identically and still go through content decryption. The new test wraps a 16-byte CEK under RSA1_5 with enc A256GCM and expects the auth tag error. It fails on master with the key-length error.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant