Skip to content
Prototype pollution Disclosed report Intermediate CVE-2018-16487

Prototype pollution attack (lodash / constructor.prototype)

The lodash functions merge, mergeWith, and defaultsDeep can be tricked into adding or modifying properties of the Object prototype. An attacker could 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

High 7.0 View original
  • Triaged in 24 hours
  • Fixed in 3 months
  • Paid in 17 months
  • Disclosed after 4 months

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

Module

module name: lodash version: 4.17.10 npm page: https://www.npmjs.com/package/lodash

Module Description

The Lodash library exported as Node.js modules.

Module Stats

12M downloads in the last week

Vulnerability

Vulnerability Description

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

The functions merge, mergeWith, and defaultsDeep 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 {constructor: {prototype: {...}}} and send it to _.merge.

JavaScript
var _ = require('lodash');
var payload = JSON.parse('{"constructor": {"prototype": {"isAdmin": true}}}');
_.merge({}, 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 functions recursively copy properties from user-controlled objects without checking for special keys like constructor and prototype, allowing modification of Object.prototype.

Impact

Denial of service, possibly more depending on the application.

What the attacker needed

Application uses lodash merge, mergeWith, or defaultsDeep; attacker can supply object input to these functions

How it was found

  1. Craft an object with a constructor property containing a prototype property with the desired malicious properties.
  2. Pass this object to the lodash merge function along with an empty target object.
  3. Observe that the malicious property is now present on all objects, e.g., {}.isAdmin returns true.

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 on Object.prototype, so the changes appear on all objects. This can cause denial of service, possibly more depending on 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.