Prototype pollution attack (mixin-deep)
The mixin-deep library allows an attacker who controls part of the input to modify the prototype of Object, adding or changing properties that affect all objects. This can cause a denial of service by replacing toString or valueOf, and more complex payloads could lead to remote code execution.
- Triaged in 20 hours
- Fixed in 11 days
- Disclosed after 15 days
As discussed in #309391, here's the separate report for each of the library. This one is the information for the mixin-deep library.
Module:
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.
var merge = require('mixin-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 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.
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
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.
What the attacker needed
Attacker controls part of input to merge; application uses mixin-deep
How it was found
- Require the mixin-deep module.
- Create a malicious JSON payload containing a __proto__ key with a property.
- Parse the JSON and pass it to the merge function along with an empty object.
- Observe that a separate empty object now has 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.
Prototype pollution is a flaw where an attacker can add or change default properties that every object in a program shares. Here, a library that merges objects lets a malicious JSON input slip in a special property that alters the shared prototype, so every object gains the attacker's property. This can crash the server or, in worse cases, let the attacker run their own code.
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.