Skip to content
Prototype pollution Disclosed report Beginner CVE-2020-8147

[utils-extend] Prototype pollution

The utils-extend library's extend function allows an attacker to modify the prototype of a base object by supplying a crafted JSON payload with a __proto__ key. This can lead to denial of service, access to sensitive data, or remote code execution depending on how the library is used.

tuo4n8 Follow

Originally disclosed on HackerOne

Critical 9.4 View original
  • Triaged in 3 hours
  • Fixed in 41 days
  • Disclosed after 41 days

NOTE! Thanks for submitting a report! Please replace all the [square] sections below with the pertinent details. Remember, the more detail you provide, the easier it is for us to triage and respond quickly, so be sure to take your time filling out the report!

I would like to report prototype polution in utils-extend It allows an attacker to modify the prototype of a base object which can vary in severity depending on the implementation (DoS, access to sensitive data, RCE).

Module

module name: utils-extend version: 1.0.8 npm page: https://www.npmjs.com/package/utils-extend

Module Description

Extend nodejs util api, and it is light weight and simple.

Module Stats

[1] weekly downloads : 129,956

Vulnerability

Vulnerability Description

Steps To Reproduce:

  1. npm install --save utils-extend
  2. create file index.js with content :
JavaScript
const { extend } = require('utils-extend');
const payload = '{"__proto__":{"isAdmin":true}}'
const emptyObject = {}
const pollutionObject = JSON.parse(payload);
extend({}, pollutionObject)
console.log(emptyObject.isAdmin)  // true
  1. run node index.js => true

Wrap up

Select Y or N for the following statements:

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

Impact

Can result in: dos, access to restricted data, rce (depends on implementation)

Attachments

demo.jpg
demo.jpg From the original on HackerOne

The original report as published on HackerOne, by tuo4n8. 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 filtering out the __proto__ key, allowing an attacker to modify Object.prototype.

Impact

Depending on how the library is used, this could lead to denial of service, access to restricted data, or remote code execution.

What the attacker needed

Attacker controls input passed to extend

How it was found

  1. Install the utils-extend package.
  2. Create a JavaScript file that parses a JSON payload containing a __proto__ key and passes it to the extend function.
  3. Run the file with Node.js and observe that the polluted property appears on an empty 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 lets an attacker change properties on a base object that other objects inherit from. Here, passing a crafted JSON payload with a __proto__ key to the extend function pollutes an empty object. This can break the application or, in worse cases, lead to 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 tuo4n8

View all

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