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

MODERATE
Advisory Identifier: GHSA-h6q6-9hqw-rwfv
CVSS 4.3
CWE-436 CWE-115
Published
Advisory Summary

CVE-2021-21366 is a MODERATE (CVSS 4.3) misinterpretation of malicious xml input vulnerability (CWE-436: Interpretation Conflict) 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.5.0.

CVE-2021-21366 at a Glance

CVE Identifier CVE-2021-21366
GHSA Identifier GHSA-h6q6-9hqw-rwfv
Severity MODERATE
CVSS v3.1 Base Score 4.3
CWE Classification CWE-436: Interpretation Conflict
Affected Product Xmldom
Package Ecosystem npm
Published Date
Last Updated

Security Impact

CVSS: 4.3

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:R/S:U/C:N/I:L/A:N).

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

How to Fix CVE-2021-21366

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: 0.5.0
npm install xmldom@0.5.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-21366, 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.5.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-436: Interpretation Conflict, where product a handles inputs or steps differently than product b, which causes a to perform incorrect actions based on its perception of b's state. 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.4.0 and older do not correctly preserve [system identifiers](https://www.w3.org/TR/2008/REC-xml-20081126/#d0e4313), [FPIs](https://en.wikipedia.org/wiki/Formal_Public_Identifier) or [namespaces](https://www.w3.org/TR/xml-names11/) when repeatedly parsing and serializing maliciously crafted documents. This may lead to unexpected syntactic changes during XML processing in some downstream applications. ### Patches Update to 0.5.0 (once it is released) ### 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/ ### 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`

CVE-2021-21366 Affected Xmldom Versions

1 component(s)
Fixed Versions:
0.5.0
Product / Package Ecosystem Affected Versions Fixed Version
xmldom
npm
< 0.5.0
0.5.0

References

Frequently Asked Questions

What is CVE-2021-21366?
CVE-2021-21366 is a security vulnerability in Xmldom involving Misinterpretation of malicious XML input under CWE-436: Interpretation Conflict.
Which Xmldom versions are affected?
Affected versions include releases prior to 0.5.0 across affected packages: xmldom.
What version fixes CVE-2021-21366?
Upgrading to 0.5.0 (or the latest patched release for your respective branch) resolves the vulnerability.
Is xmldom affected?
Yes, xmldom is affected in releases prior to 0.5.0. Upgrade your dependency to 0.5.0 or later.
What is the CVSS score of CVE-2021-21366?
CVE-2021-21366 has a CVSS v3.1 base score of 4.3 (MODERATE) with vector string CVSS:3.1/AV:N/AC:L/PR:N/UI:R/S:U/C:N/I:L/A:N.
What CWE is associated with CVE-2021-21366?
CVE-2021-21366 is classified under CWE-436: Interpretation Conflict (Product A handles inputs or steps differently than Product B, which causes A to perform incorrect actions based on its perception of B's state.).
How can I check npm dependencies for CVE-2021-21366?
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-h6q6-9hqw-rwfv",
  "modified" : "2023-01-02T21:51:19Z",
  "published" : "2021-03-12T22:39:39Z",
  "aliases" : [ "CVE-2021-21366" ],
  "summary" : "Misinterpretation of malicious XML input",
  "details" : "### Impact\n\nxmldom versions 0.4.0 and older do not correctly preserve [system identifiers](https://www.w3.org/TR/2008/REC-xml-20081126/#d0e4313), [FPIs](https://en.wikipedia.org/wiki/Formal_Public_Identifier) or [namespaces](https://www.w3.org/TR/xml-names11/) when repeatedly parsing and serializing maliciously crafted documents.\n\nThis may lead to unexpected syntactic changes during XML processing in some downstream applications.\n\n### Patches\n\nUpdate to 0.5.0 (once it is released)\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\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`",
  "severity" : [ {
    "type" : "CVSS_V3",
    "score" : "CVSS:3.1/AV:N/AC:L/PR:N/UI:R/S:U/C:N/I:L/A:N"
  } ],
  "affected" : [ {
    "package" : {
      "ecosystem" : "npm",
      "name" : "xmldom"
    },
    "ranges" : [ {
      "type" : "ECOSYSTEM",
      "events" : [ {
        "introduced" : "0"
      }, {
        "fixed" : "0.5.0"
      } ]
    } ]
  } ],
  "references" : [ {
    "type" : "WEB",
    "url" : "https://github.com/xmldom/xmldom/security/advisories/GHSA-h6q6-9hqw-rwfv"
  }, {
    "type" : "ADVISORY",
    "url" : "https://nvd.nist.gov/vuln/detail/CVE-2021-21366"
  }, {
    "type" : "WEB",
    "url" : "https://github.com/xmldom/xmldom/commit/d4201b9dfbf760049f457f9f08a3888d48835135"
  }, {
    "type" : "PACKAGE",
    "url" : "https://github.com/xmldom/xmldom"
  }, {
    "type" : "WEB",
    "url" : "https://github.com/xmldom/xmldom/releases/tag/0.5.0"
  }, {
    "type" : "WEB",
    "url" : "https://lists.debian.org/debian-lts-announce/2023/01/msg00000.html"
  }, {
    "type" : "WEB",
    "url" : "https://www.npmjs.com/package/xmldom"
  } ],
  "database_specific" : {
    "cwe_ids" : [ "CWE-115", "CWE-436" ],
    "severity" : "MODERATE",
    "github_reviewed" : true,
    "github_reviewed_at" : "2021-03-12T16:21:24Z",
    "nvd_published_at" : "2021-03-12T17:15:00Z"
  }
}