CVE-2024-38374: Cyclonedx core java Cyclonedx-core-java Vulnerability

HIGH
Advisory Identifier: GHSA-683x-4444-jxh8
CVSS 7.5
CWE-611
Published
Advisory Summary

CVE-2024-38374 is a HIGH (CVSS 7.5) cyclonedx-core-java vulnerability (CWE-611: Improper Restriction of XML External Entity Reference) affecting Cyclonedx core java libraries in the Maven ecosystem. The issue involves cyclonedx-core-java. Remediation is available by upgrading affected packages to version 9.0.4.

CVE-2024-38374 at a Glance

CVE Identifier CVE-2024-38374
GHSA Identifier GHSA-683x-4444-jxh8
Severity HIGH
CVSS v3.1 Base Score 7.5
CWE Classification CWE-611: Improper Restriction of XML External Entity Reference
Affected Product Cyclonedx core java
Package Ecosystem Maven
Published Date
Last Updated

Security Impact

CVSS: 7.5

The security impact metrics below are parsed directly from the CVSS v3.1 vector string (CVSS:3.1/AV:N/AC:L/PR:N/UI:N/S:U/C:H/I:N/A:N).

Attack Vector Network (AV:N)
Attack Complexity Low (AC:L)
Privileges Required None (PR:N)
User Interaction None (UI:N)
Scope Unchanged (S:U)
Confidentiality High (C:H)
Integrity None (I:N)
Availability None (A:N)

How to Fix CVE-2024-38374

To remediate this vulnerability, upgrade all affected Cyclonedx core java 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.cyclonedx:cyclonedx-core-java fixed: 9.0.4
<dependency>
    <groupId>org.cyclonedx</groupId>
    <artifactId>cyclonedx-core-java</artifactId>
    <version>9.0.4</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.cyclonedx

How to Check if You Are Affected

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

mvn dependency:tree -Dincludes=org.cyclonedx

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

Note: The mvn dependency:tree -Dincludes=org.cyclonedx 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-611: Improper Restriction of XML External Entity Reference, where the product processes an xml document that can contain xml entities with uris that resolve to documents outside of the intended sphere of control, causing the product to embed incorrect documents into its output. In Cyclonedx core java, 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

### Impact Before deserializing CycloneDX Bill of Materials in XML format, _cyclonedx-core-java_ leverages XPath expressions to determine the schema version of the BOM. The `DocumentBuilderFactory` used to evaluate XPath expressions was not configured securely, making the library vulnerable to XML External Entity (XXE) injection. XXE injection can be exploited to exfiltrate local file content, or perform Server Side Request Forgery (SSRF) to access infrastructure adjacent to the vulnerable application. ### PoC ```java import org.cyclonedx.parsers.XmlParser; class Poc { public static void main(String[] args) { // Will throw org.cyclonedx.exception.ParseException: java.net.ConnectException: Connection refused new XmlParser().parse(""" <?xml version="1.0" encoding="UTF-8"?> <!DOCTYPE bom [<!ENTITY % sp SYSTEM "https://localhost:1010/does-not-exist/file.dtd"> %sp;]> <bom xmlns="http://cyclonedx.org/schema/bom/1.5"/> """.getBytes()); } } ``` ### Patches The vulnerability has been fixed in _cyclonedx-core-java_ version 0.9.4. ### Workarounds If feasible, applications can reject XML documents before handing them to _cyclonedx-core-java_ for parsing. This may be an option if incoming CycloneDX BOMs are known to be in JSON format. ### References * Issue was fixed via <https://github.com/CycloneDX/cyclonedx-core-java/pull/434> * Issue was introduced via <https://github.com/CycloneDX/cyclonedx-core-java/commit/162aa594f347b3f612fe0a45071693c3cd398ce9> * <https://owasp.org/www-community/vulnerabilities/XML_External_Entity_(XXE)_Processing> * <https://cheatsheetseries.owasp.org/cheatsheets/XML_External_Entity_Prevention_Cheat_Sheet.html#xpathexpression>

CVE-2024-38374 Affected Cyclonedx core java Versions

1 component(s)
Fixed Versions:
9.0.4
Product / Package Ecosystem Affected Versions Fixed Version
org.cyclonedx:cyclonedx-core-java
Maven
≥ 2.1.0
< 9.0.4
9.0.4

References

Frequently Asked Questions

What is CVE-2024-38374?
CVE-2024-38374 is a security vulnerability in Cyclonedx core java involving cyclonedx-core-java under CWE-611: Improper Restriction of XML External Entity Reference.
Which Cyclonedx core java versions are affected?
Affected versions include releases prior to 9.0.4 across affected packages: org.cyclonedx:cyclonedx-core-java.
What version fixes CVE-2024-38374?
Upgrading to 9.0.4 (or the latest patched release for your respective branch) resolves the vulnerability.
Is cyclonedx-core-java affected?
Yes, org.cyclonedx:cyclonedx-core-java is affected in releases prior to 9.0.4. Upgrade your dependency to 9.0.4 or later.
What is the CVSS score of CVE-2024-38374?
CVE-2024-38374 has a CVSS v3.1 base score of 7.5 (HIGH) with vector string CVSS:3.1/AV:N/AC:L/PR:N/UI:N/S:U/C:H/I:N/A:N.
What CWE is associated with CVE-2024-38374?
CVE-2024-38374 is classified under CWE-611: Improper Restriction of XML External Entity Reference (The product processes an XML document that can contain XML entities with URIs that resolve to documents outside of the intended sphere of control, causing the product to embed incorrect documents into its output.).
How can I check Maven dependencies for CVE-2024-38374?
Run the dependency tree command: 'mvn dependency:tree -Dincludes=org.cyclonedx'. 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-683x-4444-jxh8",
  "modified" : "2024-06-28T18:58:48Z",
  "published" : "2024-06-24T20:44:48Z",
  "aliases" : [ "CVE-2024-38374" ],
  "summary" : "Improper Restriction of XML External Entity Reference in org.cyclonedx:cyclonedx-core-java",
  "details" : "### Impact\n\nBefore deserializing CycloneDX Bill of Materials in XML format, _cyclonedx-core-java_ leverages XPath expressions to determine the schema version of the BOM. The `DocumentBuilderFactory` used to evaluate XPath expressions was not configured securely, making the library vulnerable to XML External Entity (XXE) injection.\n\nXXE injection can be exploited to exfiltrate local file content, or perform Server Side Request Forgery (SSRF) to access infrastructure adjacent to the vulnerable application.\n\n### PoC\n\n```java\nimport org.cyclonedx.parsers.XmlParser;\n\nclass Poc {\n\n    public static void main(String[] args) {\n        // Will throw org.cyclonedx.exception.ParseException: java.net.ConnectException: Connection refused\n        new XmlParser().parse(\"\"\"\n            <?xml version=\"1.0\" encoding=\"UTF-8\"?>\n            <!DOCTYPE bom [<!ENTITY % sp SYSTEM \"https://localhost:1010/does-not-exist/file.dtd\"> %sp;]>\n            <bom xmlns=\"http://cyclonedx.org/schema/bom/1.5\"/>\n            \"\"\".getBytes());\n    }\n\n}\n```\n\n### Patches\n\nThe vulnerability has been fixed in _cyclonedx-core-java_ version 0.9.4.\n\n### Workarounds\n\nIf feasible, applications can reject XML documents before handing them to _cyclonedx-core-java_ for parsing.\nThis may be an option if incoming CycloneDX BOMs are known to be in JSON format.\n\n### References\n\n* Issue was fixed via <https://github.com/CycloneDX/cyclonedx-core-java/pull/434>\n* Issue was introduced via <https://github.com/CycloneDX/cyclonedx-core-java/commit/162aa594f347b3f612fe0a45071693c3cd398ce9>\n* <https://owasp.org/www-community/vulnerabilities/XML_External_Entity_(XXE)_Processing>\n* <https://cheatsheetseries.owasp.org/cheatsheets/XML_External_Entity_Prevention_Cheat_Sheet.html#xpathexpression>\n",
  "severity" : [ {
    "type" : "CVSS_V3",
    "score" : "CVSS:3.1/AV:N/AC:L/PR:N/UI:N/S:U/C:H/I:N/A:N"
  } ],
  "affected" : [ {
    "package" : {
      "ecosystem" : "Maven",
      "name" : "org.cyclonedx:cyclonedx-core-java"
    },
    "ranges" : [ {
      "type" : "ECOSYSTEM",
      "events" : [ {
        "introduced" : "2.1.0"
      }, {
        "fixed" : "9.0.4"
      } ]
    } ]
  } ],
  "references" : [ {
    "type" : "WEB",
    "url" : "https://github.com/CycloneDX/cyclonedx-core-java/security/advisories/GHSA-683x-4444-jxh8"
  }, {
    "type" : "ADVISORY",
    "url" : "https://nvd.nist.gov/vuln/detail/CVE-2024-38374"
  }, {
    "type" : "WEB",
    "url" : "https://github.com/CycloneDX/cyclonedx-core-java/pull/434"
  }, {
    "type" : "WEB",
    "url" : "https://github.com/CycloneDX/cyclonedx-core-java/pull/434/commits/ab0bc9c530d24f737970dbd0287d1190b129853d"
  }, {
    "type" : "PACKAGE",
    "url" : "https://github.com/CycloneDX/cyclonedx-core-java"
  } ],
  "database_specific" : {
    "cwe_ids" : [ "CWE-611" ],
    "severity" : "HIGH",
    "github_reviewed" : true,
    "github_reviewed_at" : "2024-06-24T20:44:48Z",
    "nvd_published_at" : "2024-06-28T18:15:04Z"
  }
}