Skip to content
Prototype pollution Disclosed report Intermediate

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.

dienpv Follow

Originally disclosed on HackerOne

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

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

The original report as published on HackerOne, by dienpv. 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

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

  1. Load the mergify module in a Node.js script.
  2. Build a JSON payload containing a __proto__ key with a property to inject.
  3. Parse the payload and pass it to mergify together with an empty target object.
  4. 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.

More by dienpv

View all

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