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

Prototype pollution attack (deap)

The deap library's merge, extend, clone and main functions could be tricked into modifying the prototype of Object when an attacker controls part of the input structure. An attacker could add or replace properties on every object, at minimum causing a denial of service and potentially leading to remote code execution.

holyvier Follow

Originally disclosed on HackerOne

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

As discussed in #309391, here's the separate report for each of the library. This one is the information for the deap library.

Module:

deap

Summary:

Utilities function in all the listed modules can be tricked into modify the prototype of "Object" when the attacker control part of the structure passed to these function. This can let an attacker add or modify existing property that will exist on all object.

Description:

Steps To Reproduce:

The simplest test case to reproduce the issue is the following code snippet. In the code snippet, "malicious_payload" would come from an endpoint which accepts JSON data. The test case also works with the "deap.extend" function, the "deap" function and the "deap.clone" function.

var deap= require('deap'); var malicious_payload = '{"__proto__":{"oops":"It works !"}}';

var a = {}; console.log("Before : " + a.oops); deap.merge({}, JSON.parse(malicious_payload)); console.log("After : " + a.oops);

This shows that an attacker can add attributes to all existing object on the server. Additional attribute can be used to change the execution code flow or cause error on every subsequent request by replacing "toString" or "valueOf".

Impact:

This vulnerability is garanteed to at least obtain denial of service as all the library allow the property "toString" and "valueOf" to be replaced by a "String". This breaks the express module and forces the server to either crash or return a 500 to every subsequent request.

More complex payload can be crafted to gain remote code execution (see PoC in #309391).

Supporting Material/References:

If extra information is needed don't hesitate to ask.

Impact

Variable. Server crash or the server becoming unable to respond to all request is garanteed, but more significant impact like remote code execution can be achieved in some cases.

The original report as published on HackerOne, by holyvier. 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/extend/clone helpers copy keys from parsed JSON without skipping special keys such as __proto__, so a nested object can reach and modify Object.prototype.

Impact

The author states denial of service is guaranteed because toString and valueOf can be replaced, breaking express so the server crashes or returns 500 to every request; more complex payloads could achieve remote code execution in some cases.

What the attacker needed

Attacker controls JSON passed to the library; application uses deap merge/extend/clone

How it was found

  1. Create an empty object and note a property is absent.
  2. Parse a JSON payload whose nested key targets the object prototype.
  3. Pass the parsed payload to deap.merge (or extend, clone, deap).
  4. Observe the property now appears on the previously empty 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.

JavaScript objects inherit shared properties from a common template called a prototype. If a library copies attacker-supplied data into that shared template, every object in the running program gains the attacker's property. Here that let an attacker break the server, and the author says it could go further.

What is Prototype pollution?

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

More by holyvier

View all

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