Skip to content
Prototype pollution Disclosed report Beginner CVE-2018-16469

Prototype pollution attack (merge.recursive)

The merge.recursive function in the merge npm package can be tricked into adding or modifying properties on Object.prototype by passing an object with a __proto__ key. An attacker could use this to inject properties that appear on all objects, potentially causing denial of service or other effects depending on the application.

asgerf Follow

Originally disclosed on HackerOne

  • Triaged in 3 days
  • Fixed in 47 days
  • Disclosed after 3 months

I would like to report prototype pollution in merge. It allows an attacker to inject properties on Object.prototype.

Module

module name: merge version: 1.2.0 npm page: https://www.npmjs.com/package/merge

Module Description

Merge multiple objects into one, optionally creating a new cloned object. Similar to the jQuery.extend but more flexible. Works in Node.js and the browser.

Module Stats

1,822,662 downloads in the last week

Vulnerability

Vulnerability Description

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

The merge.recursive function 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 merge.recursive.

JavaScript
let merge = require('merge');
let payload = JSON.parse('{"__proto__": {"isAdmin": true}}');
merge.recursive({}, payload);
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 merge.recursive function does not filter or block the __proto__ key when recursively merging objects, allowing it to modify Object.prototype.

Impact

Denial of service, possibly more depending on the application.

What the attacker needed

Application uses merge.recursive on untrusted input

How it was found

  1. Craft an object with a __proto__ key containing the properties to inject.
  2. Pass this object to merge.recursive along with an empty target object.
  3. Observe that the injected property appears on all objects.

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 lets an attacker add or change properties that every object inherits. Here, a function that merges objects does not block a special __proto__ key, so an attacker can inject a property like isAdmin into every object, which can break the 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 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.

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.