Prototype pollution attack (mergify)
The mergify npm package performs a recursive deep copy of objects without guarding against the special __proto__ key, so a crafted JSON object can add properties to Object.prototype. An attacker who controls JSON input passed to the library could pollute every object in the process, which the reporter says may lead to denial of service or remote code execution in some cases.
- Disclosed after 9 days
Hi team, I would like to report a prototype pollution vulnerability in mergify that allows an attacker to inject properties on Object.prototype.
Module
module name: mergify
version: 1.0.2
npm page: https://www.npmjs.com/package/mergify
Module Description
Merge objects deeply
Vulnerability
Vulnerability Description
this vulnerability type is similar to my report #438274 mergify is vulnerable when it performs a recursive copy of the specified objects.
Steps To Reproduce:
In the following code snippet, "payload" would come from user-input (JSON data).
var mergify= require('mergify');
var payload = '{"__proto__":{"polluted":"mergify_done !"}}';
var test = {};
console.log("Before: ", test.polluted);
mergify({},JSON.parse(payload));
console.log("After: ", test.polluted);
# Wrap up
- I contacted the maintainer to let them know: [Y/N]
- I opened an issue in the related repository: [Y/N]
Thanks!
## Impact
It causes Denial of Service or RCE 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
The reporter states it causes denial of service or, in some cases, remote code execution, though no concrete exploitation beyond the pollution demo is shown.
What the attacker needed
Attacker-controlled JSON reaches mergify; application uses the affected package version
How it was found
- Load the mergify module in a Node.js script.
- Build a JSON payload containing a __proto__ key with a property to inject.
- Parse the payload and pass it to mergify together with an empty target object.
- Read the injected property from an unrelated empty object to confirm pollution.
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 built-in object called Object.prototype. If a library copies user-supplied data into objects without blocking the special __proto__ key, an attacker can add their own defaults that then appear on every object in the program. That can break the application or, in some situations, be turned into code execution.
What is Prototype pollution?
Input changes JavaScript's shared object prototype, altering behaviour across the application, sometimes to XSS or code execution.