Skip to content
Prototype pollution Disclosed report Beginner

[@firebase/util] Prototype pollution

The deepCopy and deepExtend helper functions in the @firebase/util package let a crafted object add or change properties on the shared Object prototype, so those properties then appear on every object. Depending on how the library is used, this could lead to denial of service, property injection or remote code execution.

d3lla Follow

Originally disclosed on HackerOne

  • Fixed in 41 days
  • Disclosed after 41 days

Module

module name: @firebase/util version: 0.3.2 npm page: https://www.npmjs.com/package/@firebase/util

Module Description

NOTE: This is specifically tailored for Firebase JS SDK usage, if you are not a member of the Firebase team, please avoid using this package

This is a wrapper of some Webchannel Features for the Firebase JS SDK.

Module Stats

[1,516,157] weekly downloads

Vulnerability

Vulnerability Description

I tested the deepCopy and deepExtend functions.

The deepCopy and deepExtend functions can be used to add/modify properties of the Object prototype. These properties will be present on all objects.

Steps To Reproduce:

  • install @firebase/util module:
    • npm i ``@firebase/util

Run the following poc:

JavaScript
const utils = require('@firebase/util');

const obj = {};
const source = JSON.parse('{"__proto__":{"polluted":"yes"}}');
console.log("Before : " + obj.polluted);
utils.deepExtend({}, source);
// utils.deepCopy(source);
console.log("After : " + obj.polluted);

Output:

CONSOLE

Before : undefined
After : yes
firebase_util_poc.mov From the original on HackerOne

Supporting Material/References:

  • OPERATING SYSTEM VERSION: Ubuntu 18.04.4 LTS
  • NODEJS VERSION: v14.11.0
  • NPM VERSION: 6.14.8

Wrap up

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

Thank you for your time.

best regards,

d3lla

Impact

The impact depends on the application. In some cases it is possible to achieve Denial of service (DoS), Remote Code Execution, Property Injection.

The original report as published on HackerOne, by d3lla. 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 impact depends on the application; in some cases it is possible to achieve denial of service, remote code execution or property injection.

What the attacker needed

Attacker-controlled object passed to deepCopy/deepExtend; application uses @firebase/util

How it was found

  1. Install the @firebase/util package with npm.
  2. Build an object from JSON that contains a nested __proto__ key with a property inside it.
  3. Call deepExtend (or deepCopy) with an empty target and that object.
  4. Check a fresh empty object and see the injected property is now present.

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 template called the prototype. If an attacker can add a property to that shared template, every object in the program suddenly has it too, which can confuse or break the application. Here a helper function that merges objects copied a special key instead of ignoring it, so the shared template got changed.

What is Prototype pollution?

Input changes JavaScript's shared object prototype, altering behaviour across the application, sometimes to XSS or code execution.

More by d3lla

View all

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