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

CVE-2026-63574: Bouncy Castle bc-csharp DOS Vulnerability

CVE-2026-63574 is a denial of service vulnerability in Bouncy Castle bc-csharp allowing attackers to cause memory exhaustion via crafted OpenPGP data. 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-63574 Overview

CVE-2026-63574 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 OpenPGP signature and user attribute subpacket parsers, specifically SignatureSubpacketsParser.ReadPacket and UserAttributeSubpacketsParser.ReadPacket. A remote, unauthenticated attacker can supply a crafted OpenPGP public key, certificate, or signature with a subpacket header using the five-octet length form. The parser uses the declared length to allocate a buffer without validating it against the enclosing packet size, allowing a few bytes of input to demand up to roughly 2 GB of memory. The result is an OutOfMemoryException or memory exhaustion in the parsing process. The vulnerability is classified as [CWE-789: Memory Allocation with Excessive Size Value].

Critical Impact

A few bytes of attacker-controlled input can trigger a ~2 GB allocation, exhausting memory in any .NET process that parses untrusted OpenPGP data.

Affected Products

  • Legion of the Bouncy Castle Inc. bc-csharp versions prior to 2.7.0
  • .NET applications consuming SignatureSubpacketsParser for OpenPGP signature parsing
  • .NET applications consuming UserAttributeSubpacketsParser for OpenPGP user attribute parsing

Discovery Timeline

  • 2026-10-02 - CVE-2026-63574 published to the National Vulnerability Database
  • 2026-10-02 - Last updated in NVD database

Technical Details for CVE-2026-63574

Vulnerability Analysis

The vulnerability affects two OpenPGP subpacket parsers in bc-csharp: SignatureSubpacketsParser in crypto/src/bcpg/SignatureSubpacketsReader.cs and UserAttributeSubpacketsParser in crypto/src/bcpg/UserAttributeSubpacketsReader.cs. Both parsers read a subpacket length from the stream and allocate a backing byte array of that size before reading any body bytes. OpenPGP permits a five-octet length form, so an attacker can declare a length approaching UInt32.MaxValue. The parsers accept the declared value and attempt a new byte[length] allocation. Because the length is not bounded by the size of the enclosing packet or subpacket area, the process can be forced into a multi-gigabyte allocation on the managed heap. On memory-constrained systems the process terminates with an OutOfMemoryException; on larger systems repeated requests exhaust available memory.

Root Cause

The root cause is the absence of an upper bound on subpacket body length. The parsers treat the attacker-declared length as authoritative and do not compare it against the containing packet boundary. [CWE-789] applies directly: memory is allocated using a size derived from untrusted input without validation.

Attack Vector

Exploitation requires only that a vulnerable application parse an attacker-supplied OpenPGP artifact. The attack is remote, unauthenticated, and requires no user interaction. Typical delivery paths include email signature validation, key server imports, package signature verification, and any API that accepts OpenPGP certificates. The five-octet length header is a legal OpenPGP encoding, so network-layer filters cannot distinguish malicious packets from benign ones without parsing.

text
// Patch: crypto/src/bcpg/SignatureSubpacketsReader.cs
/// <summary>Parser for signature subpackets</summary>
public class SignatureSubpacketsParser
{
    // Absolute upper bound on a single signature subpacket body. A crafted long-length header
    // could otherwise force a multi-gigabyte new byte[] (below) before any body bytes are read,
    // a pre-auth allocation DoS. 2 MiB matches bc-java's SignaturePacket.MAX_SUBPACKET_LEN
    // (large enough for e.g. embedded keys).
    private const int MaxSubpacketLength = 2 * 1024 * 1024;

    private readonly Stream m_input;

    public SignatureSubpacketsParser(Stream input)

Source: bc-csharp commit f51dacf

Detection Methods for CVE-2026-63574

Indicators of Compromise

  • Unexpected System.OutOfMemoryException events raised from Org.BouncyCastle.Bcpg namespace parsers in .NET application logs.
  • Sudden process memory growth to multi-gigabyte levels immediately after receiving an OpenPGP key, certificate, or signature.
  • Repeated crashes of services that handle OpenPGP input such as mail gateways, key servers, or package verifiers.

Detection Strategies

  • Inventory .NET build artifacts for BouncyCastle.Cryptography package versions below 2.7.0 using software composition analysis.
  • Monitor managed heap allocation metrics and large object heap pressure on processes that handle OpenPGP data.
  • Capture OpenPGP packets at ingress boundaries and flag subpacket headers using the five-octet length form with declared lengths above 2 MiB.

Monitoring Recommendations

  • Instrument OpenPGP-handling services with per-request memory ceilings and alert on allocations above expected baselines.
  • Correlate application crash dumps containing SignatureSubpacketsParser or UserAttributeSubpacketsParser frames with inbound network sources.
  • Track dependency drift on bc-csharp in CI pipelines and fail builds that pin versions below 2.7.0.

How to Mitigate CVE-2026-63574

Immediate Actions Required

  • Upgrade bc-csharp to version 2.7.0 or later in all .NET projects that consume Bouncy Castle for OpenPGP operations.
  • Audit transitive dependencies, since OpenPGP parsing is often reached indirectly through higher-level cryptography libraries.
  • Restrict exposure of OpenPGP parsing endpoints to authenticated clients where feasible until patching completes.

Patch Information

The fix caps subpacket body length at 2 MiB in both SignatureSubpacketsParser and UserAttributeSubpacketsParser, matching the MAX_SUBPACKET_LEN ceiling used by bc-java. See bc-csharp commit f51dacf for the subpacket cap and bc-csharp commit 986fb48 for related OpenPGP updates. The project maintains additional background in the CVE-2026-63574 wiki entry.

Workarounds

  • Enforce an application-layer size limit on inbound OpenPGP artifacts before handing them to Bouncy Castle parsers.
  • Isolate OpenPGP parsing in a separate process with a hard memory quota so an exhaustion event does not take down the parent service.
  • Reject OpenPGP packets whose declared subpacket lengths exceed 2 MiB at a pre-parsing validation layer.
bash
# Upgrade the Bouncy Castle NuGet package to the fixed version
dotnet add package BouncyCastle.Cryptography --version 2.7.0

# Verify no project still references a vulnerable version
dotnet list package --include-transitive | grep -i bouncycastle

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.