[nested-property] Prototype Pollution
The nested-property npm module allows an attacker to modify Object.prototype via its set function when given a path like '__proto__.b'. This could lead to denial of service or remote code execution in some cases.
Originally disclosed on HackerOne
- Triaged in 3 days
- Fixed in 8 months
- Disclosed after 9 months
Hi team, I would like to report a prototype pollution vulnerability in nested-property that allows an attacker to modify properties on Object.prototype.
Module name:nested-property version: 1.0.4 npm page: https://www.npmjs.com/package/nested-property
Module Description Read, write or test a data structure's nested property via a string like 'my.nested.property'. It works through arrays and objects.
Module Stats
Replace stats below with numbers from npm’s module page:
[1] weekly downloads :81,395
Vulnerability
Vulnerability Description
the vulnerabilty is similar to what reported in https://hackerone.com/reports/719856 nestedproperty module is vulnerable when it performs a set operation for nested objects
Steps To Reproduce:
Supporting Material/References:
var nestedProperty = require("nested-property"); const object = {}; object.b=true; console.log("Before " + object.b); // will log true nestedProperty.set(object, 'proto.b', false); console.log("After " + {}.b); // will log false
- [OPERATING SYSTEM VERSION] Ubuntu 16.04
- [NODEJS VERSION] 10.16
- [NPM VERSION] 6.90
Wrap up
- I contacted the maintainer to let them know: N
- I opened an issue in the related repository: N
Hunter's comments and funny memes goes here
https://media1.tenor.com/images/dc2899b4432861e0ce1b9a03d8c98719/tenor.gif
Impact
This might causes Denial of Service or RCE in some cases
Not written yet. The AI write-up for this report has not been written yet. The Original tab links to the source.
How it worked
Impact
This might cause denial of service or remote code execution in some cases.
What the attacker needed
The nested-property module is used; attacker can control the property path
How it was found
- Require the nested-property module.
- Create an empty object and set a property on it.
- Call nestedProperty.set with a path that targets the prototype.
- Observe that a new empty object now has the changed property.
Explained by bugbounty.wiki with AI from the original and checked against quotes from it; it can still be wrong. Read the original before relying on a detail.
Not written yet. The AI write-up for this report has not been written yet. The Original tab links to the source.
Prototype pollution is a flaw where an attacker can add or change properties on a base object that many other objects inherit from. In JavaScript, every object inherits from Object.prototype, so changing it can affect the whole program. Here, a library that sets nested properties let a special path reach that base object.
What is Prototype pollution?
Input changes JavaScript's shared object prototype, altering behaviour across the application, sometimes to XSS or code execution.