You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Commit 53fccd9
Browse filesBrowse the repository at this point in the historyBrowse files
Don't leak how PKCS#7 encryptedKey decryption failed (#15369)
* Don't leak how PKCS#7 encryptedKey decryption failed
pkcs7_decrypt_der and its PEM and S/MIME variants reported invalid RSA
PKCS#1 v1.5 padding, a recovered key of the wrong length, and a wrong
key as three distinct errors, and the middle one disclosed the exact
recovered length. That is a Bleichenbacher oracle for any caller that
decrypts untrusted messages. The wrong-length case also returned before
the AES-CBC pass, so the same distinction was observable by timing,
proportional to a content size the attacker chooses.
Substitute a random key of the expected length on failure, per RFC 3218,
and continue down an identical path so that every outcome looks alike.
EnvelopedData still authenticates nothing, so revealing whether
decryption succeeded remains a CBC padding oracle regardless. That is a
property of PKCS#7 rather than of this implementation, and is now
documented instead.
Co-Authored-By: Claude Opus 5 <[email protected]>
* Cover the non-ValueError path out of encryptedKey decryption
Only a ValueError from unwrapping the key is attacker controlled and so
deliberately silenced. A private key implemented outside of this library
can fail in other ways, and those still reach the caller -- but nothing
exercised that arm, leaving it uncovered.
Add a DummyRSAPrivateKey double whose decrypt() raises a TypeError, and
tests for each of its methods.
Co-Authored-By: Claude Opus 5 <[email protected]>
* fix?
* error message
---------
Co-authored-by: Claude Opus 5 <[email protected]>
0 commit comments