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

CVE-2026-63575: Bouncy Castle PKCS#12 DOS Vulnerability

CVE-2026-63575 is a denial of service vulnerability in Bouncy Castle bc-csharp that allows attackers to cause CPU exhaustion through malicious PKCS#12 files. This post covers technical details, affected versions, and mitigation.

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-63575 Overview

CVE-2026-63575 is a denial-of-service vulnerability in the Legion of the Bouncy Castle bc-csharp library before version 2.7.0. The flaw resides in the PKCS#12 key derivation routine (Pkcs12ParametersGenerator), where the derivation loop uses an inequality check against the iteration counter instead of a bounded comparison. An attacker who supplies a crafted PKCS#12 (PFX) file or a PKCS#8 encrypted private key using PKCS#12 password-based encryption can trigger CPU exhaustion. A negative or zero iteration count causes the counter to wrap through approximately 2^32 iterations before any MAC or password validation occurs. A proof-of-concept 75-byte PFX file kept Pkcs12Store.Load busy for many minutes.

Critical Impact

A 75-byte malicious PFX file can lock a parsing thread for several minutes, enabling remote denial-of-service against any .NET service that loads untrusted PKCS#12 or PKCS#8 input.

Affected Products

  • Legion of the Bouncy Castle bc-csharp versions before 2.7.0
  • Applications invoking Pkcs12Store.Load on attacker-controlled PFX files
  • Applications parsing PKCS#8 encrypted private keys using PKCS#12 password-based encryption algorithms

Discovery Timeline

  • 2026-10-02 - CVE-2026-63575 published to NVD
  • 2026-10-02 - Last updated in NVD database

Technical Details for CVE-2026-63575

Vulnerability Analysis

The vulnerability is a classic loop-with-unreachable-exit-condition weakness classified under [CWE-835]. In Pkcs12ParametersGenerator.cs, the key derivation routine iterates a message digest using a for loop whose termination relies on a strict inequality (j != mIterationCount). When mIterationCount is zero or negative, the loop counter never equals the target value until it wraps around the full 32-bit signed integer range. The derivation effectively runs for roughly 2^32 digest operations before any downstream MAC verification can reject the structure. Because the input validation happens after derivation, an attacker only needs to encode an invalid iteration count in the MacData field of a tiny PFX structure to monopolize a CPU core for an extended period.

Root Cause

The root cause is improper input validation of the iteration count combined with an unbounded loop termination condition. The parser trusts the integer value decoded from the ASN.1 MacData structure without rejecting non-positive counts, and the derivation loop uses != instead of < for its exit test.

Attack Vector

Exploitation requires an attacker to deliver a malicious PKCS#12 file or PKCS#8 encrypted key blob to a target application that calls Pkcs12Store.Load or an equivalent parsing API. User interaction is required to supply the file, but no authentication or privileges are needed. Common attack surfaces include certificate upload endpoints, client authentication handlers, and automated key-import pipelines.

text
// Patch in crypto/src/crypto/generators/Pkcs12ParametersGenerator.cs
                digest.BlockUpdate(I, 0, I.Length);
                digest.DoFinal(A, 0);

-               for (int j = 1; j != mIterationCount; j++)
+               for (int j = 1; j < mIterationCount; j++)
                {
                    digest.BlockUpdate(A, 0, A.Length);
                    digest.DoFinal(A, 0);

Source: bc-csharp commit 0c7a6dfd

Detection Methods for CVE-2026-63575

Indicators of Compromise

  • PKCS#12 or PFX files containing a MacData iteration count of zero or a negative integer value
  • Unusually small PFX uploads (under 100 bytes) that cause prolonged parsing time
  • .NET worker processes showing sustained 100% single-core CPU usage inside Pkcs12ParametersGenerator call stacks

Detection Strategies

  • Parse incoming PKCS#12 structures with an ASN.1 inspector before loading and reject any MacData iteration count less than one
  • Instrument Pkcs12Store.Load call sites with execution-time thresholds and log inputs exceeding a few seconds of parse time
  • Monitor dependency manifests for bc-csharp versions below 2.7.0 across .NET build pipelines

Monitoring Recommendations

  • Alert on sustained CPU saturation in processes that handle user-supplied certificate material
  • Capture stack traces from long-running threads inside Org.BouncyCastle.Crypto.Generators namespaces
  • Track upload endpoints that accept .pfx, .p12, or encrypted PKCS#8 files for anomalous size-to-processing-time ratios

How to Mitigate CVE-2026-63575

Immediate Actions Required

  • Upgrade BouncyCastle.Cryptography (bc-csharp) to version 2.7.0 or later across all .NET projects
  • Audit application code paths that invoke Pkcs12Store.Load, Pkcs12StoreBuilder, or PKCS#8 decryption on untrusted input
  • Apply pre-parsing validation that rejects PKCS#12 iteration counts outside a sane range (for example, 1 to 5,000,000)

Patch Information

The fix is distributed across two commits. The derivation loop was corrected in commit 0c7a6dfd, which replaces j != mIterationCount with j < mIterationCount. A defense-in-depth change in commit 7c0ed15f introduces iteration-count validation in Pkcs12Store and Pkcs12Utilities, including a configurable maximum via the Org.BouncyCastle.Pkcs12.MaxIterations property with a default of 5,000,000. Additional detail is published on the bc-csharp CVE-2026-63575 wiki.

text
// Patch in crypto/src/pkcs/Pkcs12Utilities.cs
+   private static readonly int DefaultMaxIterations = 5000000;
+
+   internal static readonly string MaxIterationsProperty = "Org.BouncyCastle.Pkcs12.MaxIterations";

Source: bc-csharp commit 7c0ed15f

Workarounds

  • Wrap Pkcs12Store.Load calls in a bounded-time task and cancel parsing operations that exceed a safe threshold
  • Pre-validate the ASN.1 MacData iteration count field and reject values less than one or above an application-defined ceiling
  • Rate-limit and size-limit certificate upload endpoints to reduce exposure until the library upgrade is deployed
bash
# Upgrade the Bouncy Castle package in a .NET project
dotnet add package BouncyCastle.Cryptography --version 2.7.0

# Enforce a maximum iteration count at runtime (defense in depth)
export DOTNET_Org_BouncyCastle_Pkcs12_MaxIterations=5000000

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.