Vulnerabilities in pkg:npm/@cyclonedx/cyclonedx-library

PACKAGE
Advisory Identifier: GHSA-38gf-rh2w-gmj7
Advisory Summary

CVE-2024-34345 is a HIGH (CVSS 8.1) @cyclonedx/cyclonedx-library improper restriction of xml vulnerability (CWE-611: Improper Restriction of XML External Entity Reference) affecting @cyclonedx/cyclonedx library libraries in the npm ecosystem. The issue involves @cyclonedx/cyclonedx-library improper restriction of xml external entity reference vulnerability. Remediation is available by upgrading affected packages to version 6.7.1.

1 Known Advisory Record(s)
Package Vulnerability Intelligence

pkg:npm/@cyclonedx/cyclonedx-library

1 Known Advisory Record(s)

Vulnerability advisories affecting package pkg:npm/@cyclonedx/cyclonedx-library. Select an advisory below to view technical details or fixes.

Advisory ID CVE / NVD Severity Summary
GHSA-38gf-rh2w-gmj7 CVE-2024-34345 HIGH @cyclonedx/cyclonedx-library Improper Restriction of XML External Entity Reference vulnerability

CVE-2024-34345 at a Glance

CVE Identifier CVE-2024-34345
GHSA Identifier GHSA-38gf-rh2w-gmj7
Severity HIGH
CVSS v3.1 Base Score 8.1
CWE Classification CWE-611: Improper Restriction of XML External Entity Reference
Affected Product @cyclonedx/cyclonedx library
Package Ecosystem npm
Published Date
Last Updated

Security Impact

CVSS: 8.1

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

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

How to Fix CVE-2024-34345

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

@cyclonedx/cyclonedx-library fixed: 6.7.1
npm install @cyclonedx/cyclonedx-library@6.7.1
Verify Direct and Transitive Dependencies

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

npm ls @cyclonedx/cyclonedx-library

How to Check if You Are Affected

To determine whether your Node.js application is affected by CVE-2024-34345, inspect your project dependencies using npm:

npm ls @cyclonedx/cyclonedx-library

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

Note: The npm ls @cyclonedx/cyclonedx-library command inspects dependencies declared in your package.json and lockfile; it does not perform automated runtime dynamic scanning.

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/cyclonedx library, 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 XML External entity injections could be possible, when running the provided XML Validator on arbitrary input. #### POC ```js const { Spec: { Version }, Validation: { XmlValidator } } = require('@cyclonedx/cyclonedx-library'); const version = Version.v1dot5; const validator = new XmlValidator(version); const input = `<?xml version="1.0" encoding="UTF-8"?> <!DOCTYPE poc [ <!ENTITY xxe SYSTEM "file:///etc/passwd"> ]> <bom xmlns="http://cyclonedx.org/schema/bom/1.5"> <components> <component type="library"> <name>testing</name> <version>1.337</version> <licenses> <license> <id>&xxe;</id><!-- << XML external entity (XXE) injection --> </license> </licenses> </component> </components> </bom>`; // validating this forged(^) input might lead to unintended behaviour // for the fact that the XML external entity would be taken into account. validator.validate(input).then(ve => { console.error('validation error', ve); }); ``` ### Patches This issue was fixed in `@cyclonedx/cyclonedx-library@6.7.1 `. ### Workarounds Do not run the provided XML validator on untrusted inputs. ### References * issue was introduced via <https://github.com/CycloneDX/cyclonedx-javascript-library/pull/1063>.

CVE-2024-34345 Affected @cyclonedx/cyclonedx library Versions

1 component(s)
Fixed Versions:
6.7.1
Product / Package Ecosystem Affected Versions Fixed Version
@cyclonedx/cyclonedx-library
npm
≥ 6.7.0
< 6.7.1
All 1 versions
6.7.0
6.7.1

References

Frequently Asked Questions

What is CVE-2024-34345?
CVE-2024-34345 is a security vulnerability in @cyclonedx/cyclonedx library involving @cyclonedx/cyclonedx-library Improper Restriction of XML External Entity Reference vulnerability under CWE-611: Improper Restriction of XML External Entity Reference.
Which @cyclonedx/cyclonedx library versions are affected?
Affected versions include releases prior to 6.7.1 across affected packages: @cyclonedx/cyclonedx-library.
What version fixes CVE-2024-34345?
Upgrading to 6.7.1 (or the latest patched release for your respective branch) resolves the vulnerability.
Is @cyclonedx/cyclonedx-library affected?
Yes, @cyclonedx/cyclonedx-library is affected in releases prior to 6.7.1. Upgrade your dependency to 6.7.1 or later.
What is the CVSS score of CVE-2024-34345?
CVE-2024-34345 has a CVSS v3.1 base score of 8.1 (HIGH) with vector string CVSS:3.1/AV:N/AC:H/PR:N/UI:N/S:U/C:H/I:H/A:H.
What CWE is associated with CVE-2024-34345?
CVE-2024-34345 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 npm dependencies for CVE-2024-34345?
Run the dependency tree command: 'npm ls @cyclonedx/cyclonedx-library'. 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-38gf-rh2w-gmj7",
  "modified" : "2024-05-14T20:01:46Z",
  "published" : "2024-05-08T19:55:37Z",
  "aliases" : [ "CVE-2024-34345" ],
  "summary" : "@cyclonedx/cyclonedx-library Improper Restriction of XML External Entity Reference vulnerability",
  "details" : "### Impact\n\nXML External entity injections could be possible, when running the provided XML Validator on arbitrary input.\n\n#### POC\n\n```js\nconst {\n  Spec: { Version },\n  Validation: { XmlValidator }\n} = require('@cyclonedx/cyclonedx-library');\n\nconst version = Version.v1dot5;\nconst validator = new XmlValidator(version);\nconst input = `<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n<!DOCTYPE poc [\n  <!ENTITY xxe SYSTEM \"file:///etc/passwd\">\n]>\n<bom xmlns=\"http://cyclonedx.org/schema/bom/1.5\">\n  <components>\n    <component type=\"library\">\n      <name>testing</name>\n      <version>1.337</version>\n      <licenses>\n        <license>\n          <id>&xxe;</id><!-- << XML external entity (XXE) injection -->\n        </license>\n      </licenses>\n    </component>\n  </components>\n</bom>`;\n\n// validating this forged(^) input might lead to unintended behaviour\n// for the fact that the XML external entity would be taken into account.\nvalidator.validate(input).then(ve => {\n  console.error('validation error', ve);\n});\n```\n\n### Patches\n\nThis issue was fixed in `@cyclonedx/cyclonedx-library@6.7.1 `.\n\n\n\n### Workarounds\n\nDo not run the provided XML validator on untrusted inputs.\n\n### References\n\n* issue was introduced via <https://github.com/CycloneDX/cyclonedx-javascript-library/pull/1063>.  \n",
  "severity" : [ {
    "type" : "CVSS_V3",
    "score" : "CVSS:3.1/AV:N/AC:H/PR:N/UI:N/S:U/C:H/I:H/A:H"
  } ],
  "affected" : [ {
    "package" : {
      "ecosystem" : "npm",
      "name" : "@cyclonedx/cyclonedx-library"
    },
    "ranges" : [ {
      "type" : "ECOSYSTEM",
      "events" : [ {
        "introduced" : "6.7.0"
      }, {
        "fixed" : "6.7.1"
      } ]
    } ],
    "versions" : [ "6.7.0" ]
  } ],
  "references" : [ {
    "type" : "WEB",
    "url" : "https://github.com/CycloneDX/cyclonedx-javascript-library/security/advisories/GHSA-38gf-rh2w-gmj7"
  }, {
    "type" : "ADVISORY",
    "url" : "https://nvd.nist.gov/vuln/detail/CVE-2024-34345"
  }, {
    "type" : "WEB",
    "url" : "https://github.com/CycloneDX/cyclonedx-javascript-library/pull/1063"
  }, {
    "type" : "WEB",
    "url" : "https://github.com/CycloneDX/cyclonedx-javascript-library/commit/5e5e1e0b9422f47d2de81c7c4064b803a01e7203"
  }, {
    "type" : "PACKAGE",
    "url" : "https://github.com/CycloneDX/cyclonedx-javascript-library"
  } ],
  "database_specific" : {
    "cwe_ids" : [ "CWE-611" ],
    "severity" : "HIGH",
    "github_reviewed" : true,
    "github_reviewed_at" : "2024-05-08T19:55:37Z",
    "nvd_published_at" : "2024-05-14T15:38:40Z"
  }
}