Skip to content
DoS Disclosed report Beginner CVE-2018-16489

Prototype pollution attack in just-extend

The just-extend library allows an attacker to inject properties onto Object.prototype by passing specially crafted objects containing a constructor.prototype or __proto__ key. This could lead to denial of service or other impacts depending on the application.

asgerf Follow

Originally disclosed on HackerOne

Medium 5.7 View original
  • Disclosed after 31 days

I would like to report a prototype pollution vulnerability in just-extend It allows an attacker to inject properties on Object.prototype.

Module

module name: just-extend version: 2.1.0, and 3.0.0 npm page: https://www.npmjs.com/package/just-extend

Module Description

Part of a library of zero-dependency npm modules that do just do one thing. Guilt-free utilities for every occasion.

Module Stats

723,414 downloads in the last week

Vulnerability

Vulnerability Description

This is a variant of this vulnerability: https://hackerone.com/reports/310443

The functions just-extend can be tricked into adding or modifying properties of the Object prototype. These properties will be present on all objects.

Steps To Reproduce:

Craft an object of form {constructor: {prototype: {...}}} or {__proto__: {...}} and send it to just-extend.

JavaScript
var extend = require('just-extend');

var payload1 = JSON.parse('{"constructor": {"prototype": {"isAdmin": true}}}');
extend(true, {}, payload1);
console.log({}.isAdmin); // true

var payload2 = JSON.parse('{"__proto__": {"isAdmin2": true}}');
extend(true, {}, payload2);
console.log({}.isAdmin2); // true

Wrap up

  • I contacted the maintainer to let them know: [Y]
  • I opened an issue in the related repository: [N]

Impact

Denial of service, possibly more depending on the application. See https://hackerone.com/reports/310443

The original report as published on HackerOne, by asgerf. 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 extend function recursively merges properties without blocking special keys such as __proto__ or constructor.prototype, allowing them to reach Object.prototype.

Impact

Denial of service, possibly more depending on the application.

What the attacker needed

Application uses just-extend to merge untrusted input

How it was found

  1. Craft an object with a constructor.prototype or __proto__ key containing the desired property.
  2. Pass the object to just-extend with the deep merge flag.
  3. Observe that the property appears on a plain 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.

Prototype pollution is a bug where an attacker can add or change properties on a fundamental JavaScript object that all other objects inherit from. This means every object in the program suddenly gets the attacker's property, which can break things or change behaviour. Here, a library that merges objects together does not check for special keys like __proto__, so it copies attacker-controlled properties onto the shared prototype.

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 asgerf

View all

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