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-63569 Overview
CVE-2026-63569 is an improper input validation flaw [CWE-20] in the DHAgreement.CalculateAgreement method of Legion of the Bouncy Castle Inc. bc-csharp before version 2.7.0. The method implements the MTI/A0 two-pass Diffie-Hellman key agreement protocol. The vulnerability allows an on-path attacker to force the local party to compute a shared value the attacker already knows. A malicious peer can also learn the local static private key modulo the small factors of p-1, and fully recover it in groups with many such factors. Only applications that invoke DHAgreement directly are affected.
Critical Impact
Attackers can defeat the key authentication MTI/A0 provides and, through small-subgroup confinement, recover a reused static Diffie-Hellman private key.
Affected Products
- Legion of the Bouncy Castle Inc. bc-csharp versions prior to 2.7.0
- .NET applications calling DHAgreement.CalculateAgreement directly
- Any workflow using MTI/A0 two-pass Diffie-Hellman via the affected library
Discovery Timeline
- 2026-10-02 - CVE CVE-2026-63569 published to NVD
- 2026-10-02 - Last updated in NVD database
Technical Details for CVE-2026-63569
Vulnerability Analysis
The DHAgreement class implements MTI/A0, a two-pass Diffie-Hellman protocol that provides implicit key authentication by binding each party's static private key into the shared secret. In the vulnerable code, the peer's ephemeral message value is raised directly to the local static private key m_key.X modulo p without any range or subgroup-membership validation. The peer's public Y was checked, but the message was not. This asymmetry breaks the authentication property because an attacker can inject a crafted ephemeral that produces a predictable output.
An on-path attacker can substitute a small-order or out-of-range element for the peer ephemeral, driving message^X mod p to a known constant such as 1 or an element of a small subgroup. The computed shared value loses dependence on the static key, and the attacker learns or controls it.
Root Cause
The root cause is missing validation of the peer ephemeral message parameter before modular exponentiation with the local static private key. The call message.ModPow(m_key.X, p) operates on untrusted input that bypasses the DH public-value range check (1 < y < p-1) and subgroup-membership check. Because the private key is static and reused, the attacker can repeat the exchange with values from distinct small subgroups and solve for the private key modulo each subgroup order using the Chinese Remainder Theorem.
Attack Vector
The attack is network-based and requires no authentication. An attacker on the key-agreement path crafts an ephemeral element of small order in Z_p* and submits it as message. The local party raises that element to its static private key, producing an output confined to the small subgroup. By querying across small-order elements that generate different prime-power subgroups of p-1, the attacker reconstructs the private key modulo each order, then recombines via CRT.
BigInteger p = m_dhParams.P;
- BigInteger peerY = pub.Y;
- if (peerY == null || peerY.CompareTo(BigInteger.One) <= 0 || peerY.CompareTo(p.Subtract(BigInteger.One)) >= 0)
- throw new ArgumentException("Diffie-Hellman public key is weak");
+ // Both peer-supplied values are raised to our (potentially static) private key, so both must
+ // satisfy the DH public-value range/subgroup checks; otherwise a peer can submit a small-order
+ // or out-of-range element to mount a small-subgroup confinement attack and, when our private
+ // key is reused, recover it via CRT. The 'message' is a raw BigInteger, so validate it by
+ // construction. A normally-constructed DHPublicKeyParameters already validated its Y; but Y is
+ // virtual and a subclass can override it to return an unvalidated value, so re-validate unless
+ // pub is exactly the base type.
+ BigInteger peerMessage = new DHPublicKeyParameters(message, m_dhParams).Y;
+
+ BigInteger peerY = pub.GetType() == typeof(DHPublicKeyParameters)
+ ? pub.Y
+ : new DHPublicKeyParameters(pub.Y, m_dhParams).Y;
BigInteger result = peerY.ModPow(m_privateValue, p);
if (result.Equals(BigInteger.One))
throw new InvalidOperationException("Shared key can't be 1");
- return message.ModPow(m_key.X, p).Multiply(result).Mod(p);
+ return peerMessage.ModPow(m_key.X, p).Multiply(result).Mod(p);
}
}
}
Source: bc-csharp commit fe236ad. The patch wraps the raw message in DHPublicKeyParameters, which enforces the range and subgroup checks, and re-validates pub.Y when a subclass could override the virtual property.
Detection Methods for CVE-2026-63569
Indicators of Compromise
- Repeated MTI/A0 handshakes against the same static-key endpoint from a single peer, consistent with CRT-based private key recovery.
- Peer ephemeral values equal to 0, 1, p-1, or values whose order divides a small factor of p-1.
- Application exceptions originating from DHAgreement.CalculateAgreement referencing weak Diffie-Hellman inputs.
Detection Strategies
- Inventory .NET applications using BouncyCastle.Cryptography or bc-csharp and flag versions earlier than 2.7.0.
- Instrument wrappers around DHAgreement.CalculateAgreement to log peer ephemeral values and reject those failing 1 < m < p-1 plus subgroup-order checks.
- Perform static analysis for direct calls to DHAgreement as opposed to higher-level TLS or protocol stacks.
Monitoring Recommendations
- Alert on frequent handshake retries from the same source against identity-bound key agreement endpoints.
- Capture and review protocol telemetry for ephemeral values of unusually low bit length or arithmetic order.
- Monitor dependency manifests (packages.config, .csproj, paket.dependencies) in CI for pinned vulnerable bc-csharp versions.
How to Mitigate CVE-2026-63569
Immediate Actions Required
- Upgrade bc-csharp to version 2.7.0 or later across all .NET projects and container images.
- Rotate any static Diffie-Hellman private keys that were used with DHAgreement.CalculateAgreement prior to patching.
- Audit code for direct use of DHAgreement and prefer vetted higher-level protocol implementations where possible.
Patch Information
The fix is published in bc-csharp 2.7.0. The patch validates the peer message by constructing it through DHPublicKeyParameters, which enforces the standard DH public-value range and subgroup checks. It also re-validates pub.Y when pub is a subclass of DHPublicKeyParameters to prevent overridden virtual properties from returning unvalidated values. Review the bc-csharp CVE-2026-63569 wiki entry and the upstream commit for details.
Workarounds
- Wrap calls to DHAgreement.CalculateAgreement in a helper that validates the peer ephemeral against 1 < m < p-1 and performs a subgroup-order check before invocation.
- Avoid reusing static Diffie-Hellman private keys with MTI/A0 until the upgrade is deployed, which limits CRT-based key recovery to a single session.
- Where feasible, migrate to an ECDH-based agreement using a prime-order curve, which eliminates small-subgroup confinement by construction.
# Upgrade the vulnerable package in a .NET project
dotnet add package BouncyCastle.Cryptography --version 2.7.0
# Verify no project still pins a vulnerable version
grep -R "BouncyCastle.Cryptography" --include="*.csproj" . \
| grep -v "2.7.0"
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

