Skip to main content
Vulnerability Database/CVE-2026-71892

CVE-2026-71892: Bouncy Castle Java Privilege Escalation

CVE-2026-71892 is a privilege escalation flaw in Bouncy Castle for Java that bypasses key-size validation in CMS key-transport recipients using RFC 9709 content-encryption key derivation, allowing mismatched keys to be accepted. This post explains its technical details, affected versions, impact, and mitigation steps.

Published:

Disclaimer: This content was generated using AI. While we strive for accuracy, please verify critical information with official sources.

Sources: National Vulnerability Database, CISA KEV, Exploit-DB

CVE-2026-71892 Overview

CVE-2026-71892 is a cryptographic validation flaw in Bouncy Castle for Java versions before 1.86. The opt-in key-size validation on Cryptographic Message Syntax (CMS) key-transport recipients fails to execute for messages using RFC 9709 content-encryption key derivation (id-alg-cek-hkdf-sha256). An always-false comparison between a byte array and an ASN.1 Object Identifier causes the check to fall through, silently defeating the only API mechanism for enforcing recovered key size. The issue also affects Bouncy Castle for Java FIPS (BC-FJA) before bcpkix-fips 2.0.13 and 2.1.13. The vulnerability is categorized under [CWE-697] Incorrect Comparison.

Critical Impact

Applications calling JceKeyTransRecipient.setKeySizeValidation(true) on HKDF-derived CMS messages receive no validation, accepting content-encryption keys that do not match the advertised algorithm's key size.

Affected Products

  • Bouncy Castle for Java before version 1.86
  • Bouncy Castle for Java FIPS (BC-FJA) bcpkix-fips before 2.0.13 (2.0.X series)
  • Bouncy Castle for Java FIPS (BC-FJA) bcpkix-fips before 2.1.13 (2.1.X series)

Discovery Timeline

  • 2026-10-03 - CVE-2026-71892 published to NVD
  • 2026-10-06 - Last updated in NVD database

Technical Details for CVE-2026-71892

Vulnerability Analysis

The flaw resides in org.bouncycastle.cms.jcajce.JceKeyTransRecipient, which implements CMS key-transport recipient processing. When setKeySizeValidation(true) is enabled, the recipient is expected to verify that a recovered content-encryption key (CEK) matches the key size of the advertised symmetric algorithm.

For messages using RFC 9709 HKDF-based CEK derivation, the validation branch performed a type-mismatched equality check. It compared the encrypted-key byte array against the id-alg-cek-hkdf-sha256ASN1ObjectIdentifier. This comparison returns false for every possible input. Execution then fell through to a key-size lookup against the outer wrapper OID, which identifies a key-derivation construction and has no registered key size, so the comparison was skipped entirely.

The practical consequence is that EnvelopedData or AuthEnvelopedData messages with HKDF-derived CEKs whose size does not match the advertised content-encryption algorithm are accepted without error, even when validation is explicitly enabled.

Root Cause

The root cause is an incorrect comparison between heterogeneous types. The code compared encryptedEncryptionKey (a byte array) against CMSObjectIdentifiers.id_alg_cek_hkdf_sha256 (an ASN1ObjectIdentifier), which can never evaluate to true. The dispatcher should have examined the algorithm OID carried in the key-derivation AlgorithmIdentifier.

Attack Vector

An attacker who can craft or tamper with CMS EnvelopedData or AuthEnvelopedData structures can supply HKDF-derived content-encryption keys with mismatched sizes. Recipients that opted into key-size validation gain no protection, undermining defense-in-depth for CMS consumers that rely on this check to detect malformed or hostile messages. Messages with matching key sizes, non-HKDF messages, and recipients that do not enable validation are unaffected.

java
// Patch excerpt from JceKeyTransRecipient.java
if (validateKeySize)
{
-    if (encryptedEncryptionKey.equals(CMSObjectIdentifiers.id_alg_cek_hkdf_sha256))
+    if (encryptedKeyAlgorithm.getAlgorithm().equals(CMSObjectIdentifiers.id_alg_cek_hkdf_sha256))
    {
        helper.keySizeCheck(
            AlgorithmIdentifier.getInstance(encryptedKeyAlgorithm.getParameters()), key);

Source: Bouncy Castle Patch Commit

Detection Methods for CVE-2026-71892

Indicators of Compromise

  • Presence of Bouncy Castle bcpkix JAR files with versions earlier than 1.86 on application classpaths.
  • Presence of bcpkix-fips JARs earlier than 2.0.13 (2.0.X) or 2.1.13 (2.1.X).
  • CMS messages containing the id-alg-cek-hkdf-sha256 OID (1.2.840.113549.1.9.16.3.31) processed by Java applications using Bouncy Castle.

Detection Strategies

  • Inventory Java application dependencies with Software Composition Analysis (SCA) tools to locate vulnerable bcpkix and bcpkix-fips artifacts.
  • Audit source code for calls to JceKeyTransRecipient.setKeySizeValidation(true) to identify consumers that rely on the bypassed check.
  • Scan CMS traffic and stored envelopes for RFC 9709 HKDF OIDs to identify systems that process affected message types.

Monitoring Recommendations

  • Log CMS decryption operations and record the algorithm identifiers of recovered content-encryption keys for later review.
  • Monitor for exceptions or anomalies raised by downstream symmetric cipher initialization that may indicate size-mismatched keys.
  • Track the versions of cryptographic libraries deployed across build pipelines and runtime hosts via continuous dependency scanning.

How to Mitigate CVE-2026-71892

Immediate Actions Required

  • Upgrade Bouncy Castle for Java to version 1.86 or later.
  • Upgrade Bouncy Castle FIPS to bcpkix-fips 2.0.13 for the 2.0.X series or 2.1.13 for the 2.1.X series.
  • Review all code paths that invoke setKeySizeValidation(true) and confirm they execute against the patched library at runtime.

Patch Information

The fix changes the dispatch logic so that validation examines the algorithm OID of the content-encryption AlgorithmIdentifier rather than performing an impossible comparison against the encrypted-key byte array. See the GitHub commit be0a7d9 and the CVE-2026-71892 wiki entry.

Workarounds

  • Reject CMS messages carrying the id-alg-cek-hkdf-sha256 OID at an application boundary until the library is upgraded.
  • Enforce key-size validation at an additional layer, for example by inspecting the recovered CEK length against the expected symmetric algorithm before downstream use.
  • Constrain accepted content-encryption algorithms to a narrow allow-list to reduce exposure to unexpected key-size pairings.
bash
# Example Maven dependency update
mvn versions:use-dep-version -Dincludes=org.bouncycastle:bcpkix-jdk18on -DdepVersion=1.86 -DforceVersion=true

# FIPS variant
mvn versions:use-dep-version -Dincludes=org.bouncycastle:bcpkix-fips -DdepVersion=2.1.13 -DforceVersion=true

Disclaimer: This content was generated using AI. While we strive for accuracy, please verify critical information with official sources.

Sources: National Vulnerability Database, CISA KEV, Exploit-DB

Experience the Most Advanced Cybersecurity Platform

See how the world’s most intelligent, autonomous cybersecurity platform can protect your organization today and into the future.