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

Prototype pollution attack (merge-deep)

The merge-deep library merges attacker-controlled JSON into an object without blocking special keys, so a crafted payload can modify the prototype shared by all objects. This lets an attacker add or replace properties such as toString or valueOf, which the report says can crash the server or, with more complex payloads, lead to remote code execution.

holyvier Follow

Originally disclosed on HackerOne

  • Triaged in 41 hours
  • Fixed in 12 days
  • Disclosed after 16 days

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

Module: merge-deep

Summary: Utilities function in all the listed modules can be tricked into modifying 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.

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

var a = {}; console.log("Before : " + a.oops); 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 guaranteed 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 guaranteed, 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 deep-merge routine copies keys such as __proto__ from untrusted input without filtering them, so it writes into Object.prototype instead of only the target object.

Impact

The report states denial of service is guaranteed because toString and valueOf can be replaced, breaking express and causing crashes or 500 responses, while more complex payloads could achieve remote code execution.

What the attacker needed

Attacker controls JSON passed to merge; application uses merge-deep on that input

How it was found

  1. Load the merge-deep library and build a JSON payload that targets the shared prototype.
  2. Parse the payload and pass it to the merge function with an empty object.
  3. Observe that a separate, previously empty 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 common parent object called the prototype. If a program copies user-supplied data into an object without checking key names, a key like __proto__ can reach that shared parent and change it for everything. Here that means one request could break or alter every later request on the server.

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

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.