Unwrap the RFC 9709 content-encryption algorithm at every CMS recipient key-size and policy check - #2446
Open
Arpan0995 wants to merge 1 commit into
Open
Unwrap the RFC 9709 content-encryption algorithm at every CMS recipient key-size and policy check#2446Arpan0995 wants to merge 1 commit into
Arpan0995 wants to merge 1 commit into
Conversation
…nt key-size and policy check
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Under RFC 9709 the
EncryptedContentInfonamesid-alg-cek-hkdf-sha256and carries the content-encryptionAlgorithmIdentifierin its parameters. The 1.86 fix for CVE-2026-71892 resolves it, per its release note: "The recipient now dispatches on the content-encryption algorithm OID". The sibling call sites do not.JceKEKRecipient,JceKTSKeyTransRecipient,JceKEMRecipientandJceKeyTransRecipient's ownid-ori-kembranch pass the outer identifier toEnvelopedDataHelper.keySizeCheck, which registers no key size for it, sosetKeySizeValidation(true)checks nothing. The 1.85 policy controls read the outer identifier on every recipient family, key transport included: an allowed set namingaes256-CBCrefuses the message outright, one namingid-alg-cek-hkdf-sha256admits any content algorithm, andsetMinimumTagSizenever sees a tag size.Reproduced on the released 1.86 jars and on classes built from
origin/main(ab16374d37), unchanged inorg.bouncycastle.cmssincer1rv86. A 32-byte CEK under an advertisedaes128-CBCdrawsCMSException: Expected key size for algorithm OID not found in recipient.from all four with HKDF off; with it on, key transport still refuses and KEK, KTS and ML-KEM return the content. AES-128-GCM with a 96-bit tag undersetMinimumTagSize(128)raisesCMSTagLengthExceptionwith HKDF off and recovers with it on for all four, key transport included: the tag floor was not in the 1.86 fix.This change:
id-alg-cek-hkdf-sha256unwrap intoEnvelopedDataHelper.keySizeCheck, so all five key-size sites validate against the carried algorithm and the special case inJceKeyTransRecipient.extractSecretKeycollapses to the plain call (theid-ori-kembranch carries no test, since no shipped generator emits such aKeyTransRecipientInfo);AbstractRecipient.checkContentAlgorithm, which resolves the wrapper once and then applies the allowed set and the tag floor, replacing the identical prologue in the nine recipients carrying it (shape only in the other five: only the fourJcerecipients that derive the CEK reach an RFC 9709 message today); andNewEnvelopedDataTest: the KEK, KTS and ML-KEM key-size sites, and the allow-list and tag-floor halves onJceKeyTransRecipient. They are the only failures against the unchanged sources; with the change all pass, as do the other 224 tests in the 15 CMS enveloped-, auth-enveloped- and authenticated-data classes.One behaviour change: a caller who listed
id-alg-cek-hkdf-sha256in an allowed set must now list the content algorithms themselves.Base tree only, as the 1.86 fix was; the legacy
pkix/src/main/jdk1.1overlays are left alone, and nomodule-info/ OSGi change is needed. A release-note entry is in the 1.87 defects block; happy to reword it.