[ts-dot-prop] Prototype Pollution
The set function in ts-dot-prop allows setting properties on Object.prototype via a __proto__ path, enabling prototype pollution. An attacker could modify prototype behaviour, potentially leading to sensitive information disclosure, denial of service, or remote code execution depending on the application.
- Fixed in 17 days
- Disclosed after 47 days
I would like to report a Prototype Pollution vulnerability in ts-dot-prop.
It allows an attacker to inject properties on Object.prototype.
Module
module name: ts-dot-prop
version: 1.4.0
npm page: https://www.npmjs.com/package/ts-dot-prop
Module Description
TypeScript utility to transform nested objects using a dot notation path.
Module Stats
Weekly downloads: 1028
Vulnerability
Vulnerability Description
The set function can be used to set properties of the Object prototype. It 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 ts-dot-prop: npm install ts-dot-prop
Create an object with proto property and pass it to the set function:
POC:
const tsDot = require('ts-dot-prop'); var obj = {} console.log("Before : " + obj.isAdmin); tsDot.set(obj, '__proto__.isAdmin', true); console.log("After : " + obj.isAdmin);
Output:
Before: undefined After: true
Supporting Material/References:
- Operating System: Windows 10
- NODEJS VERSION: v12.18.3
- NPM VERSION: v6.14.6
Wrap up
- I contacted the maintainer to let them know: [Y]
- I opened an issue in the related repository: [Y]
Impact
The impact depends on the application. In some cases, it is possible to obtain Sensitive Information, 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
The set function does not block or sanitise the __proto__ key when traversing a dot-notation path, allowing writes to Object.prototype.
Impact
Depending on the application, an attacker could obtain sensitive information, cause denial of service, achieve remote code execution, or inject properties.
What the attacker needed
Application uses ts-dot-prop set with attacker input
How it was found
- Install the ts-dot-prop package.
- Create an empty object and check a property such as isAdmin.
- Call the set function with a path starting with __proto__ and a value.
- Observe that the property now appears on the original object.
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 when an attacker can add or change properties on a shared base object that many other objects inherit from. In JavaScript, every object inherits from Object.prototype, so changing it affects all objects. Here, a library function that sets nested properties did not block the special __proto__ key, so an attacker could add a property like isAdmin to every object.
What is Prototype pollution?
Input changes JavaScript's shared object prototype, altering behaviour across the application, sometimes to XSS or code execution.