CVEReports
CVEReports

Automated vulnerability intelligence platform. Comprehensive reports for high-severity CVEs generated by AI.

Product

  • Home
  • Sitemap
  • RSS Feed

Company

  • About
  • Contact
  • Privacy Policy
  • Terms of Service

© 2026 CVEReports. All rights reserved.

Made with love by Amit Schendel & Alon Barad



CVE-2024-29857
7.50.34%

CVE-2024-29857: Denial of Service via Algorithmic Complexity in Bouncy Castle ECC

Alon Barad
Alon Barad
Software Engineer

Mar 11, 2026·5 min read·2 visits

PoC Available

Executive Summary (TL;DR)

Bouncy Castle (Java < 1.78, C# < 2.3.1) fails to limit the field degree parameter when processing explicit ECC curve parameters over binary fields. This allows remote attackers to trigger an infinite CPU loop via malicious X.509 certificates.

An algorithmic complexity exhaustion vulnerability exists in the Bouncy Castle cryptographic libraries for Java and C# .NET. The vulnerability affects the processing of Elliptic Curve Cryptography (ECC) parameters defined over binary finite fields. Remote attackers can trigger unbounded resource consumption and cause a denial of service (DoS) by supplying specially crafted X.509 certificates with excessively large field degree parameters.

Vulnerability Overview

Bouncy Castle provides foundational cryptographic APIs and serves as the underlying TLS and certificate validation provider for a vast array of Java and C# .NET enterprise applications. CVE-2024-29857 is an algorithmic complexity vulnerability residing in the library's Elliptic Curve Cryptography (ECC) implementation. The flaw manifests exclusively when the library processes ECC parameters defined over binary finite fields ($F_{2^m}$).

The vulnerability stems from an uncontrolled resource consumption condition (CWE-400). The computational cost of instantiating binary fields scales quadratically or is directly proportional to the field degree parameter. Attackers exploit this mathematical property by injecting exceptionally large degree values into explicit curve definitions.

Upon encountering these malicious parameters during certificate parsing or curve initialization, the vulnerable application initiates execution loops that process massive polynomial structures. This results in synchronous thread blocking and continuous 100% CPU utilization. Downstream applications depending on Bouncy Castle for untrusted input validation, such as Jenkins, Keycloak, and WebLogic, inherit this exposure directly.

Root Cause Analysis

In Elliptic Curve Cryptography over binary finite fields, the field structure is mathematically defined by a reduction polynomial of degree $m$. Foundational field operations require constructing these polynomials and solving quadratic equations to execute point decompression. The algorithmic complexity of these foundational operations is directly proportional to the magnitude of the $m$ parameter.

Prior to the patch, Bouncy Castle implementations in ECCurve.java and ECCurve.cs accepted arbitrary integer values for $m$. The library lacked upper bound validation during the initialization phase of $F_{2^m}$ curves. An attacker could specify a maliciously large value for $m$, up to the maximum 32-bit integer limit.

When point decompression is mandated by the cryptographic payload, the library invokes the solveQuadraticEquation method to resolve the equation $z^2 + z = \beta$. This method implements the Half-Trace approach for odd values of $m$ and Trace-based approaches for even values. Both algorithms utilize iterative loops that execute exactly $m$ times. Supplying an extreme upper-bound integer value forces the thread to execute billions of complex polynomial operations, locking the CPU core indefinitely.

Exploit Mechanics and Trigger Path

Network-based exploitation requires the target application to parse an untrusted X.509 certificate containing malicious explicit curve parameters. The attacker does not need authentication to trigger the vulnerability, provided the endpoint accepts and evaluates client certificates. The vulnerability triggers during the initial parsing phase, long before cryptographic validation or signature verification occurs.

The attack vector was formalized in USENIX Security 2025 research detailing the X.509DoSTool. The researchers automated the generation of malicious certificates by injecting an exceptionally large $m$ parameter into the binary field definition of the X.509 ASN.1 structure. When a vulnerable service receives this certificate, the ASN.1 parser extracts the parameters and passes them directly to the Bouncy Castle ECCurve.F2m constructor.

The exploit results in synchronous thread blocking. Applications handling concurrent connections will rapidly exhaust their thread pools if multiple malicious certificates are submitted. This leads to a complete denial of service for the affected cryptographic module and the host application.

Code Analysis and Patch Walkthrough

The remediation strategy focuses on implementing a strict fail-fast boundary check during field instantiation. Bouncy Castle developers modified the buildField method to validate the degree parameter before allocating resources or initiating mathematical operations. This prevents the execution flow from reaching the expensive loop structures inside solveQuadraticEquation.

The Java implementation patch in commit fee80dd230e7fba132d03a34f1dd1d6aae0d0281 introduces a default upper limit of 1142 for the $m$ parameter. This limit accommodates standard secure curve sizes (such as B-571) while preventing denial-of-service conditions.

private static FiniteField buildField(int m, int k1, int k2, int k3) {
    if (m > Properties.asInteger("org.bouncycastle.ec.max_f2m_field_size", 1142)) {
        throw new IllegalArgumentException("field size out of range: " + m);
    }
    // Field construction proceeds safely
}

The C# .NET implementation patch in commit 56daa6eac526f165416d17f661422d60de0dfd63 applies an identical logic flow in ECCurve.cs. The implementation retrieves the maximum threshold from an environment variable, throwing an ArgumentException if the input exceeds the safe boundary.

private static IFiniteField BuildField(int m, int k1, int k2, int k3) {
    int maxM = ImplGetInteger("Org.BouncyCastle.EC.F2m_MaxSize", 1142);
    if (m > maxM)
        throw new ArgumentException("F2m m value out of range");
    // Field construction proceeds safely
}

Remediation and Configuration Fallbacks

The primary remediation is upgrading the Bouncy Castle library to the officially patched releases. Java applications must upgrade to version 1.78 or LTS version 2.73.6. C# .NET applications must upgrade to version 2.3.1. Bouncy Castle FIPS (BC-FJA) users must upgrade to version 1.0.2.5.

Administrators who cannot immediately deploy patched binaries can utilize configuration-based workarounds introduced in the backported fixes. The patched versions allow runtime configuration of the maximum $m$ parameter via system properties or environment variables. This enables organizations to adjust the default limit of 1142 if specific legacy applications require larger field sizes.

In Java environments, administrators can set the org.bouncycastle.ec.max_f2m_field_size system property. In .NET environments, the equivalent setting is Org.BouncyCastle.EC.F2m_MaxSize. Network-layer mitigation via Web Application Firewalls (WAF) is generally ineffective, as deep packet inspection of ASN.1 structures within encrypted TLS handshakes is computationally prohibitive and prone to false negatives.

Official Patches

Bouncy CastleOfficial Bouncy Castle release page
NetAppNetApp Security Advisory for CVE-2024-29857

Fix Analysis (2)

Technical Appendix

CVSS Score
7.5/ 10
CVSS:3.1/AV:N/AC:L/PR:N/UI:N/S:U/C:N/I:N/A:H
EPSS Probability
0.34%
Top 44% most exploited

Affected Systems

JenkinsKeycloakLogstashOracle WebLogic ServerIBM SPSS Collaboration and Deployment ServicesRed Hat Enterprise Linux (RHEL)Amazon LinuxCloudera Flow Management

Affected Versions Detail

Product
Affected Versions
Fixed Version
Bouncy Castle Java (BC Java)
Legion of the Bouncy Castle
< 1.781.78
Bouncy Castle Java LTS
Legion of the Bouncy Castle
< 2.73.62.73.6
Bouncy Castle FIPS (BC-FJA)
Legion of the Bouncy Castle
< 1.0.2.51.0.2.5
Bouncy Castle C# .NET
Legion of the Bouncy Castle
< 2.3.12.3.1
AttributeDetail
CWE IDCWE-400 / CWE-125
Attack VectorNetwork (Malicious X.509 Certificate)
CVSS v3.1 Score7.5
EPSS Score0.00337 (56.09%)
Impact100% CPU Exhaustion (Denial of Service)
Exploit StatusProof of Concept (X.509DoSTool)
KEV StatusNot Listed

MITRE ATT&CK Mapping

T1499.002Endpoint Denial of Service: Service Exhaustion
Impact
T1499.003Endpoint Denial of Service: Application Exhaustion
Impact
CWE-400
Uncontrolled Resource Consumption

The application does not properly control the allocation of computing resources required to process incoming data, leading to resource exhaustion.

Known Exploits & Detection

USENIX Security 2025X.509DoSTool demonstrating malicious certificate generation

Vulnerability Timeline

Initial fix for Java version added to solveQuadraticEquation.
2023-12-18
Refactored Java fix to move check to foundational buildField method.
2023-12-22
Fix implemented in Bouncy Castle C# repository.
2024-04-23
CVE-2024-29857 published.
2024-05-09
Official Bouncy Castle advisories released for Java and C#.
2024-05-14
USENIX paper 'X.509DoS' presents the vulnerability as a case study.
2025-08-15

References & Sources

  • [1]Bouncy Castle Java GitHub Advisory
  • [2]Bouncy Castle C# GitHub Advisory
  • [3]Java Patch Commit
  • [4]C# Patch Commit
  • [5]X.509DoS: Exploiting and Detecting Denial-of-Service
  • [6]NetApp Advisory
  • [7]Bouncy Castle Latest Releases

Attack Flow Diagram

Press enter or space to select a node. You can then use the arrow keys to move the node around. Press delete to remove it and escape to cancel.
Press enter or space to select an edge. You can then press delete to remove it or escape to cancel.