CVE-2025-9340: Bouncy Castle Bouncy Castle For Java Has Vulnerability

LOW
Advisory Identifier: GHSA-g6rx-6wfx-gj74
CWE-787
Published
Advisory Summary

CVE-2025-9340 is a LOW bouncy castle for java has vulnerability (CWE-787: Out-of-bounds Write) affecting Bouncy Castle libraries in the Maven ecosystem. The issue involves bouncy castle for java has out-of-bounds write vulnerability. Remediation is available by upgrading affected packages to version 2.1.1.

CVE-2025-9340 at a Glance

CVE Identifier CVE-2025-9340
GHSA Identifier GHSA-g6rx-6wfx-gj74
Severity LOW
CVSS v3.1 Base Score N/A
CWE Classification CWE-787: Out-of-bounds Write
Affected Product Bouncy Castle
Package Ecosystem Maven
Published Date
Last Updated

How to Fix CVE-2025-9340

To remediate this vulnerability, upgrade all affected Bouncy Castle dependencies to a patched release. Both direct and transitive dependencies should be checked, as frameworks or security libraries may pull in vulnerable versions transitively.

org.bouncycastle:bc-fips fixed: 2.1.1
<dependency>
    <groupId>org.bouncycastle</groupId>
    <artifactId>bc-fips</artifactId>
    <version>2.1.1</version>
</dependency>
Verify Direct and Transitive Dependencies

Run the following command in your project directory to verify that all resolved dependencies use the patched release:

mvn dependency:tree -Dincludes=org.bouncycastle

How to Check if You Are Affected

To determine whether your Java application is affected by CVE-2025-9340, inspect your build dependencies using the Maven Dependency Plugin:

mvn dependency:tree -Dincludes=org.bouncycastle

Analyze the terminal output to locate any version of Bouncy Castle in your dependency tree. If any resolved version matches the vulnerable ranges listed in the table below (for example, versions earlier than 2.1.1), your application is affected.

Note: The mvn dependency:tree -Dincludes=org.bouncycastle command inspects the resolved dependency graph declared in your project's POM files; it does not perform automated security scanning or inspect runtime dynamic classpaths. Always verify runtime container classpaths and shaded JARs.

Technical Details

Vulnerability Mechanism & Technical Analysis

This vulnerability is classified under CWE-787: Out-of-bounds Write, where the product writes data past the end, or before the beginning, of the intended buffer. In Bouncy Castle, software state validation or input boundaries are circumvented during processing. Review the official source advisory statement below for specific affected components, classes, and reproduction details.

Source Advisory Statement

Out-of-bounds Write vulnerability in Legion of the Bouncy Castle Inc. Bouncy Castle for Java bc-fips on All (API modules). This vulnerability is associated with program files org/bouncycastle/jcajce/provider/BaseCipher. This issue affects Bouncy Castle for Java: from BC-FJA 2.1.0 through 2.1.0.

CVE-2025-9340 Affected Bouncy Castle Versions

1 component(s)
Fixed Versions:
2.1.1
Product / Package Ecosystem Affected Versions Fixed Version
org.bouncycastle:bc-fips
Maven
≥ 2.1.0
< 2.1.1
All 1 versions
2.1.0
2.1.1

References

Frequently Asked Questions

What is CVE-2025-9340?
CVE-2025-9340 is a security vulnerability in Bouncy Castle involving Bouncy Castle for Java has Out-of-Bounds Write Vulnerability under CWE-787: Out-of-bounds Write.
Which Bouncy Castle versions are affected?
Affected versions include releases prior to 2.1.1 across affected packages: org.bouncycastle:bc-fips.
What version fixes CVE-2025-9340?
Upgrading to 2.1.1 (or the latest patched release for your respective branch) resolves the vulnerability.
Is bc-fips affected?
Yes, org.bouncycastle:bc-fips is affected in releases prior to 2.1.1. Upgrade your dependency to 2.1.1 or later.
What CWE is associated with CVE-2025-9340?
CVE-2025-9340 is classified under CWE-787: Out-of-bounds Write (The product writes data past the end, or before the beginning, of the intended buffer.).
How can I check Maven dependencies for CVE-2025-9340?
Run the dependency tree command: 'mvn dependency:tree -Dincludes=org.bouncycastle'. This command lists direct and transitive dependencies in your build configuration so you can verify if a vulnerable version is resolved.
Machine-readable OSV JSON OSV v1.5 Schema
Normalized schema output
{
  "schema_version" : "1.4.0",
  "id" : "GHSA-g6rx-6wfx-gj74",
  "modified" : "2025-08-22T20:30:44Z",
  "published" : "2025-08-22T12:30:30Z",
  "aliases" : [ "CVE-2025-9340" ],
  "summary" : "Bouncy Castle for Java has Out-of-Bounds Write Vulnerability",
  "details" : "Out-of-bounds Write vulnerability in Legion of the Bouncy Castle Inc. Bouncy Castle for Java bc-fips on All (API modules). This vulnerability is associated with program files org/bouncycastle/jcajce/provider/BaseCipher.\n\nThis issue affects Bouncy Castle for Java: from BC-FJA 2.1.0 through 2.1.0.",
  "severity" : [ {
    "type" : "CVSS_V4",
    "score" : "CVSS:4.0/AV:P/AC:L/AT:P/PR:L/UI:A/VC:N/VI:N/VA:N/SC:N/SI:N/SA:N/E:X/CR:X/IR:X/AR:X/MAV:X/MAC:X/MAT:X/MPR:X/MUI:X/MVC:X/MVI:X/MVA:X/MSC:X/MSI:X/MSA:X/S:N/AU:X/R:U/V:X/RE:M/U:Green"
  } ],
  "affected" : [ {
    "package" : {
      "ecosystem" : "Maven",
      "name" : "org.bouncycastle:bc-fips"
    },
    "ranges" : [ {
      "type" : "ECOSYSTEM",
      "events" : [ {
        "introduced" : "2.1.0"
      }, {
        "fixed" : "2.1.1"
      } ]
    } ],
    "versions" : [ "2.1.0" ]
  } ],
  "references" : [ {
    "type" : "ADVISORY",
    "url" : "https://nvd.nist.gov/vuln/detail/CVE-2025-9340"
  }, {
    "type" : "PACKAGE",
    "url" : "https://github.com/bcgit/bc-java"
  }, {
    "type" : "WEB",
    "url" : "https://github.com/bcgit/bc-java/wiki/CVE%E2%80%902025%E2%80%909340"
  } ],
  "database_specific" : {
    "cwe_ids" : [ "CWE-787" ],
    "severity" : "LOW",
    "github_reviewed" : true,
    "github_reviewed_at" : "2025-08-22T20:30:44Z",
    "nvd_published_at" : "2025-08-22T10:15:33Z"
  }
}