CVE-2022-37616 Overview
A prototype pollution vulnerability exists in the copy function within dom.js in the xmldom package (published as @xmldom/xmldom) for Node.js. The vulnerability allows attackers to pollute object prototypes via the p variable, potentially leading to arbitrary property injection on target objects. While the vendor has contested the classification of this vulnerability, security researchers maintain that prototype pollution occurs when a target object is polluted, regardless of whether global objects are affected through recursive merge or deep cloning operations.
Critical Impact
This prototype pollution vulnerability can allow remote attackers to manipulate object properties, potentially leading to denial of service, property injection, or in some scenarios, arbitrary code execution depending on how the polluted objects are used in the application.
Affected Products
- xmldom_project xmldom (versions before 0.8.3 for Node.js)
- xmldom 0.9.0-beta1 for Node.js
- Debian Linux 10.0
Discovery Timeline
- 2022-10-11 - CVE CVE-2022-37616 published to NVD
- 2024-11-21 - Last updated in NVD database
Technical Details for CVE-2022-37616
Vulnerability Analysis
The vulnerability resides in the copy function located in dom.js within the xmldom package. Prototype pollution is a JavaScript-specific vulnerability class (CWE-1321) that occurs when user-controlled input can modify the prototype of base objects. In the case of CVE-2022-37616, the p variable within the copy function does not properly validate or sanitize property names before assignment, allowing an attacker to inject properties like __proto__, constructor, or prototype.
When exploited, this allows attackers to modify the behavior of objects throughout the application. Since xmldom is widely used for XML parsing in Node.js applications, this vulnerability could affect any application that processes untrusted XML input through affected versions.
Root Cause
The root cause of this vulnerability is improper input validation in the copy function within dom.js. The function fails to check whether property names being copied include special prototype-related properties (__proto__, constructor.prototype). Without proper sanitization, an attacker can inject malicious properties that propagate to all objects sharing the same prototype chain, leading to application-wide pollution.
Attack Vector
This vulnerability is exploitable over the network without authentication or user interaction. An attacker can craft malicious XML input that, when processed by a vulnerable xmldom instance, triggers the prototype pollution through the copy function. The attack requires the target application to process attacker-controlled XML data.
The exploitation flow involves:
- Attacker submits crafted XML containing specially-named elements or attributes
- The xmldom parser processes this input through the vulnerable copy function
- The p variable receives attacker-controlled property names without validation
- Prototype pollution occurs, affecting object behavior throughout the application
Technical details and discussion of this vulnerability can be found in the GitHub XMLDOM Issue #436 and the GitHub Security Advisory GHSA-9pgh-qqpf-7wqj.
Detection Methods for CVE-2022-37616
Indicators of Compromise
- Unexpected properties appearing on JavaScript objects within Node.js applications using xmldom
- Application behavior changes after processing specific XML payloads
- Log entries showing unusual property access patterns on parsed XML objects
- Runtime errors related to unexpected prototype properties in downstream code
Detection Strategies
- Implement software composition analysis (SCA) to identify xmldom versions prior to 0.8.3 in your dependency tree
- Monitor npm audit reports for CVE-2022-37616 in project dependencies
- Deploy runtime application self-protection (RASP) solutions that can detect prototype pollution attempts
- Review application logs for anomalous XML parsing behavior or unexpected object property modifications
Monitoring Recommendations
- Enable verbose logging for XML parsing operations in applications using xmldom
- Implement integrity monitoring for critical JavaScript objects to detect prototype modifications
- Set up dependency vulnerability scanning in CI/CD pipelines to catch vulnerable xmldom versions
- Monitor for unusual application crashes or behavior that may indicate prototype pollution exploitation
How to Mitigate CVE-2022-37616
Immediate Actions Required
- Upgrade xmldom (@xmldom/xmldom) to version 0.8.3 or later immediately
- Audit all Node.js applications for xmldom dependencies using npm ls xmldom or npm ls @xmldom/xmldom
- Review transitive dependencies that may include vulnerable xmldom versions
- Consider implementing input validation for XML data before processing with xmldom
Patch Information
The vulnerability has been addressed in xmldom version 0.8.3. Organizations should update to this version or later to remediate the vulnerability. For Debian Linux 10.0 users, refer to the Debian LTS Announcement for distribution-specific patch information. The fix involves proper validation of property names in the copy function to prevent prototype pollution through the p variable.
Workarounds
- Implement Object.freeze() on critical object prototypes to prevent modification
- Use Object.create(null) for objects that will receive untrusted data to create prototype-less objects
- Deploy a web application firewall (WAF) configured to inspect and sanitize XML payloads
- Consider using alternative XML parsing libraries until upgrade is possible
# Upgrade xmldom to patched version
npm update @xmldom/xmldom
# Verify installed version
npm ls @xmldom/xmldom
# For yarn users
yarn upgrade @xmldom/xmldom
# Audit for vulnerable dependencies
npm audit
Disclaimer: This content was generated using AI. While we strive for accuracy, please verify critical information with official sources.

