Skip to content
Prototype pollution Disclosed report Beginner

[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.

prathis Follow

Originally disclosed on HackerOne

  • 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.

The original report as published on HackerOne, by prathis. Images and videos are our own copies; raw HTML is shown as text. View it on HackerOne.

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

  1. Install the ts-dot-prop package.
  2. Create an empty object and check a property such as isAdmin.
  3. Call the set function with a path starting with __proto__ and a value.
  4. 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.

More from Node.js third-party modules

View all

The newest disclosed reports for this program.

Similar reports

View all

Same bug class and techniques, clearest first.

Prototype pollution

The lesson behind this report.

Input changes JavaScript's shared object prototype, altering behaviour across the application, sometimes to XSS or code execution.