CVE-2021-32796: Xmldom Misinterpretation Of Malicious XML Input Vulnerability

MODERATE
Advisory Identifier: GHSA-5fg8-2547-mr8q
CVSS 6.5
CWE-116
Published
Advisory Summary

CVE-2021-32796 is a MODERATE (CVSS 6.5) misinterpretation of malicious xml input vulnerability (CWE-116: Improper Encoding or Escaping of Output) affecting Xmldom libraries in the npm ecosystem. The issue involves misinterpretation of malicious xml input. Remediation is available by upgrading affected packages to version 0.7.0.

CVE-2021-32796 at a Glance

CVE Identifier CVE-2021-32796
GHSA Identifier GHSA-5fg8-2547-mr8q
Severity MODERATE
CVSS v3.1 Base Score 6.5
CWE Classification CWE-116: Improper Encoding or Escaping of Output
Affected Product Xmldom
Package Ecosystem npm
Published Date
Last Updated

Security Impact

CVSS: 6.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:L/I:L/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 Low (C:L)
Integrity Low (I:L)
Availability None (A:N)

How to Fix CVE-2021-32796

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

xmldom fixed: Latest secure release
npm install xmldom@Latest secure release
@xmldom/xmldom fixed: 0.7.0
npm install @xmldom/xmldom@0.7.0
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 xmldom

How to Check if You Are Affected

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

npm ls xmldom

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

Note: The npm ls xmldom 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-116: Improper Encoding or Escaping of Output, where the product prepares a structured message for communication with another component, but encoding or escaping of the data is either missing or done incorrectly. as a result, the intended structure of the message is not preserved. In Xmldom, 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 xmldom versions 0.6.0 and older do not correctly escape special characters when serializing elements removed from their ancestor. This may lead to unexpected syntactic changes during XML processing in some downstream applications. ### Patches Update to one of the fixed versions of `@xmldom/xmldom` (`>=0.7.0`) See issue #271 for the status of publishing `xmldom` to npm or join #270 for Q&A/discussion until it's resolved. ### Workarounds Downstream applications can validate the input and reject the maliciously crafted documents. ### References Similar to this one reported on the Go standard library: - https://mattermost.com/blog/coordinated-disclosure-go-xml-vulnerabilities/ - https://mattermost.com/blog/securing-xml-implementations-across-the-web/ ### For more information If you have any questions or comments about this advisory: * Open an issue in [`xmldom/xmldom`](https://github.com/xmldom/xmldom) * Email us: send an email to **all** addresses that are shown by `npm owner ls @xmldom/xmldom`

CVE-2021-32796 Affected Xmldom Versions

2 component(s)
Fixed Versions:
0.7.0
Product / Package Ecosystem Affected Versions Fixed Version
xmldom
npm
≤ 0.6.0
@xmldom/xmldom
npm
< 0.7.0
0.7.0

References

Frequently Asked Questions

What is CVE-2021-32796?
CVE-2021-32796 is a security vulnerability in Xmldom involving Misinterpretation of malicious XML input under CWE-116: Improper Encoding or Escaping of Output.
Which Xmldom versions are affected?
Affected versions include releases prior to 0.7.0 across affected packages: xmldom, @xmldom/xmldom.
What version fixes CVE-2021-32796?
Upgrading to 0.7.0 (or the latest patched release for your respective branch) resolves the vulnerability.
Is xmldom affected?
Yes, xmldom is affected in releases prior to Latest secure release. Upgrade your dependency to Latest secure release or later.
Is @xmldom/xmldom affected?
Yes, @xmldom/xmldom is affected in releases prior to 0.7.0. Upgrade your dependency to 0.7.0 or later.
What is the CVSS score of CVE-2021-32796?
CVE-2021-32796 has a CVSS v3.1 base score of 6.5 (MODERATE) with vector string CVSS:3.1/AV:N/AC:L/PR:N/UI:N/S:U/C:L/I:L/A:N.
What CWE is associated with CVE-2021-32796?
CVE-2021-32796 is classified under CWE-116: Improper Encoding or Escaping of Output (The product prepares a structured message for communication with another component, but encoding or escaping of the data is either missing or done incorrectly. As a result, the intended structure of the message is not preserved.).
How can I check npm dependencies for CVE-2021-32796?
Run the dependency tree command: 'npm ls xmldom'. 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-5fg8-2547-mr8q",
  "modified" : "2024-02-22T19:03:28Z",
  "published" : "2021-08-03T16:57:05Z",
  "aliases" : [ "CVE-2021-32796" ],
  "summary" : "Misinterpretation of malicious XML input",
  "details" : "### Impact\nxmldom versions 0.6.0 and older do not correctly escape special characters when serializing elements removed from their ancestor. This may lead to unexpected syntactic changes during XML processing in some downstream applications.\n\n### Patches\nUpdate to one of the fixed versions of `@xmldom/xmldom` (`>=0.7.0`)\n\nSee issue #271 for the status of publishing `xmldom` to npm or join #270 for Q&A/discussion until it's resolved.\n\n### Workarounds\n\nDownstream applications can validate the input and reject the maliciously crafted documents.\n\n### References\n\nSimilar to this one reported on the Go standard library:\n\n- https://mattermost.com/blog/coordinated-disclosure-go-xml-vulnerabilities/\n- https://mattermost.com/blog/securing-xml-implementations-across-the-web/\n\n### For more information\n\nIf you have any questions or comments about this advisory:\n\n* Open an issue in [`xmldom/xmldom`](https://github.com/xmldom/xmldom)\n* Email us: send an email to **all** addresses that are shown by `npm owner ls @xmldom/xmldom`\n",
  "severity" : [ {
    "type" : "CVSS_V3",
    "score" : "CVSS:3.1/AV:N/AC:L/PR:N/UI:N/S:U/C:L/I:L/A:N"
  } ],
  "affected" : [ {
    "package" : {
      "ecosystem" : "npm",
      "name" : "xmldom"
    },
    "ranges" : [ {
      "type" : "ECOSYSTEM",
      "events" : [ {
        "introduced" : "0"
      }, {
        "last_affected" : "0.6.0"
      } ]
    } ]
  }, {
    "package" : {
      "ecosystem" : "npm",
      "name" : "@xmldom/xmldom"
    },
    "ranges" : [ {
      "type" : "ECOSYSTEM",
      "events" : [ {
        "introduced" : "0"
      }, {
        "fixed" : "0.7.0"
      } ]
    } ]
  } ],
  "references" : [ {
    "type" : "WEB",
    "url" : "https://github.com/xmldom/xmldom/security/advisories/GHSA-5fg8-2547-mr8q"
  }, {
    "type" : "ADVISORY",
    "url" : "https://nvd.nist.gov/vuln/detail/CVE-2021-32796"
  }, {
    "type" : "WEB",
    "url" : "https://github.com/xmldom/xmldom/commit/7b4b743917a892d407356e055b296dcd6d107e8b"
  }, {
    "type" : "PACKAGE",
    "url" : "https://github.com/xmldom/xmldom"
  }, {
    "type" : "WEB",
    "url" : "https://mattermost.com/blog/coordinated-disclosure-go-xml-vulnerabilities"
  }, {
    "type" : "WEB",
    "url" : "https://mattermost.com/blog/securing-xml-implementations-across-the-web"
  }, {
    "type" : "WEB",
    "url" : "https://www.npmjs.com/package/@xmldom/xmldom"
  } ],
  "database_specific" : {
    "cwe_ids" : [ "CWE-116" ],
    "severity" : "MODERATE",
    "github_reviewed" : true,
    "github_reviewed_at" : "2021-08-02T23:21:11Z",
    "nvd_published_at" : "2021-07-27T22:15:00Z"
  }
}