[keyd] Prototype pollution
The keyd library's set function allows an attacker to add properties to Object.prototype, polluting all objects. This could lead to denial of service, remote code execution, or property injection depending on the application.
- Triaged in 3 hours
- Fixed in 4 months
- Disclosed after 4 months
I would like to report a prototype pollution vulnerability in keyd module.
It allows an attacker to inject properties on Object.prototype.
Module
module name: keyd
version: 1.3.4
npm page: https://www.npmjs.com/package/keyd
Module Description
A small library for using and manipulating key paths in JavaScript.
Module Stats
[71] weekly downloads
Vulnerability
Vulnerability Description
The set function can be used to add/modify properties of the Object prototype. These properties will be present on all objects.
Steps To Reproduce:
- install
keydmodule:npm i keyd
Set the __proto__.polluted property of an object:
const keyd = require('keyd');
const obj = {};
console.log("Before : " + obj.polluted);
keyd({}).set('__proto__.polluted', 'yes');
console.log("After : " + obj.polluted);
Output:
Before : undefined
After : yes
Supporting Material/References:
- OPERATING SYSTEM VERSION: Ubuntu 18.04.4 LTS
- NODEJS VERSION: v14.1.0
- NPM VERSION: 6.14.5
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
Root cause
The set function does not properly validate or block the special __proto__ key, allowing modification of Object.prototype.
Impact
Depending on the application, this could lead to denial of service, remote code execution, or property injection.
What the attacker needed
Application uses keyd
How it was found
- Install the keyd module using npm.
- Create an empty object and check that a property like 'polluted' is undefined.
- Call keyd({}).set with the path '__proto__.polluted' and a value.
- Check the original object again; the property now exists, showing prototype 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.
Prototype pollution lets an attacker add properties to the base object that other objects inherit from, which can affect the application.
What is Prototype pollution?
Input changes JavaScript's shared object prototype, altering behaviour across the application, sometimes to XSS or code execution.