xmldom allows multiple root nodes in a DOM

Description

Impact

xmldom parses XML that is not well-formed because it contains multiple top level elements, and adds all root nodes to the childNodes collection of the Document, without reporting any error or throwing.
This breaks the assumption that there is only a single root node in the tree, which led to https://nvd.nist.gov/vuln/detail/CVE-2022-39299 and is a potential issue for dependents.

Patches

Update to @xmldom/xmldom@~0.7.7, @xmldom/xmldom@~0.8.4 (dist-tag latest) or @xmldom/xmldom@>=0.9.0-beta.4 (dist-tag next).

Workarounds

One of the following approaches might help, depending on your use case:
- Instead of searching for elements in the whole DOM, only search in the documentElement.
- Reject a document with a document that has more then 1 childNode.

References

  • https://nvd.nist.gov/vuln/detail/CVE-2022-39299
  • https://github.com/jindw/xmldom/issues/150

For more information

If you have any questions or comments about this advisory:
* Email us at [email protected]

Basic information

Type
reviewed
Severity
critical
Advisory on GitHub
Open advisory ↗
Repository advisory
Open repository advisory ↗
Source code
Browse source ↗
Published (advisory)
2022-11-01 17:29:11 UTC
Updated
2023-03-31 16:06:26 UTC
GitHub reviewed
2022-11-01 17:29:11 UTC
NVD published
2022-11-02

EPSS Score

Score Percentile
0.97% 76.52%

CVSS Scores

Base score Version Severity Vector
9.8 3.1
CVSS:3.1/AV:N/AC:L/PR:N/UI:N/S:U/C:H/I:H/A:H Click to expand
Attack vector (AV:N)
Could be attacked over the internet or any normal routed network—not just someone sitting at the machine.
Attack complexity (AC:L)
Once they can reach the bug, pulling it off is straightforward—no weird race conditions or rare setup.
Privileges required (PR:N)
No account or special rights needed—anonymous or random user is enough.
User interaction (UI:N)
Nobody has to click “OK” or open a trap file; it can work without a victim helping.
Scope (S:U)
Damage stays in the same “trust bubble” as the broken component—no big spill into unrelated systems.
Confidentiality (C:H)
Serious risk that confidential data gets exposed in a big way.
Integrity (I:H)
They could widely tamper with or forge data—trust in the data is badly hurt.
Availability (A:H)
Could take the service down hard or make it unusable for people who depend on it.

Identifiers

CWEs

CWE id Name
CWE-20 Improper Input Validation
CWE-1288 Improper Validation of Consistency within Input

Credits

  • frumioj (analyst)
  • karfau (analyst)
  • kurt-r2c (analyst)

Affected packages (4)

Vulnerable version ranges and first patched releases as published by GitHub.

Ecosystem Package Vulnerable range First patched Vulnerable functions
npm xmldom <= 0.6.0
npm @xmldom/xmldom < 0.7.7 0.7.7
npm @xmldom/xmldom >= 0.8.0, < 0.8.4 0.8.4
npm @xmldom/xmldom >= 0.9.0-beta.1, < 0.9.0-beta.4 0.9.0-beta.4

References

cvelogic Threat Intelligence