Prototype Pollution In node-xml2js
Description
Description
xml2js version 0.4.23 allows an external attacker to edit or add new properties to an object. This is possible because the application does not properly validate incoming JSON keys, thus allowing the __proto__ property to be edited.
Vulnerability
Prototype pollution is a vulnerability that affects JS. It occurs when a third party manages to modify the __proto__ of an object. JavaScript first checks if such a method/attribute exists in the object. If so, then it calls it. If not, it looks in the object's prototype. If the method/attribute is also not in the object's prototype, then the property is said to be undefined.
Therefore, if an attacker succeeds in injecting the __proto__ property into an object, he will succeed in injecting or editing its properties.
Exploitation
Exploit.md
var parseString = require('xml2js').parseString; let normal_user_request = "<role>admin</role>"; let malicious_user_request = "<__proto__><role>admin</role></__proto__>"; const update_user = (userProp) => { // A user cannot alter his role. This way we prevent privilege escalations. parseString(userProp, function (err, user) {...
Evidence of exploitation

Our security policy
We have reserved the ID CVE-2023-0842 to refer to this issue from now on. Disclosure policy
System Information
Version: xml2js 0.4.23
Operating System: GNU/Linux
Mitigation
There is currently no patch available for this vulnerability.
References
Vendor page https://github.com/Leonidas-from-XIV/node-xml2js/
Patch: https://github.com/Leonidas-from-XIV/node-xml2js/releases/tag/0.6.2
Credits
The vulnerability was discovered by Carlos Bello from Fluid Attacks' Offensive Team.
Update Impact
Minimal update. May introduce new vulnerabilities or breaking changes.
Ecosystem | Package | Affected version | Patched versions |
|---|---|---|---|
debian 13 | 0.4.23+~cs15.4.0+dfsg-7 | ||
npm | 0.5.0 | ||
debian 12 | 0.4.23+~cs15.4.0+dfsg-7 | ||
debian 14 | 0.4.23+~cs15.4.0+dfsg-7 | ||
debian 11 | 0.2.8-1.1+deb11u1 | ||
npm | 0.6.2 | ||
rpm rhel6 | - | - | |
rpm rhel7 | - | - |
Aliases
References