Skip to content
DoS Disclosed report Intermediate CVE-2018-16491

Prototype pollution attack in node.extend

The node.extend library could be tricked into copying a __proto__ key from a parsed object onto the Object prototype, so every object in the process gained the injected property. An attacker who controls JSON passed to the library could add or change properties on all objects, which the reporter says could cause denial of service and possibly more.

asgerf Follow

Originally disclosed on HackerOne

Medium 5.7 View original
  • Triaged in 1 hour
  • Fixed in 26 hours
  • Disclosed after 31 days

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

Module

module name: node.extend version: 2.0.0 npm page: https://www.npmjs.com/package/node.extend

Module Description

A port of jQuery.extend that actually works on node.js

Module Stats

267,701 downloads in the last week

Vulnerability

Vulnerability Description

This is a variant of this vulnerability: https://hackerone.com/reports/310443

node.extend can be tricked into adding or modifying properties of the Object prototype. These properties will be present on all objects.

Steps To Reproduce:

Craft an object of form {__proto__: {...}} and send it to node.extend:

JavaScript
let extend = require('node.extend');
extend(true, {}, JSON.parse('{"__proto__": {"isAdmin": true}}'));
console.log({}.isAdmin); // true

Wrap up

  • I contacted the maintainer to let them know: [N]
  • I opened an issue in the related repository: [N]

Impact

Denial of service, possibly more depending on the application. See https://hackerone.com/reports/310443

The original report as published on HackerOne, by asgerf. 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

Likely the deep-merge routine copied the __proto__ key from the parsed input without blocking it, so the assignment reached Object.prototype instead of the target object.

Impact

The reporter states this could cause denial of service and possibly more depending on the application.

What the attacker needed

Attacker-controlled JSON reaches node.extend; application uses the affected library version

How it was found

  1. Load the node.extend module in a Node.js script.
  2. Parse a JSON string containing a __proto__ key into an object.
  3. Pass that object to the library's deep extend function with an empty target.
  4. Read a property from a fresh empty object and see the injected value.

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 the prototype. If a library copies user-supplied keys into that shared object, a key named __proto__ lets the user add a property that then appears on every object in the program. Here the library did exactly that, so a value like isAdmin showed up on an empty object.

What is DoS?

A request that exhausts resources or crashes a component. Many programs forbid testing it; reports usually show it from code, not by attacking.

More by asgerf

View all

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

Denial of service

The lesson behind this report.

A request that exhausts resources or crashes a component. Many programs forbid testing it; reports usually show it from code, not by attacking.