Skip to content
Prototype pollution Disclosed report Beginner

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

d3lla Follow

Originally disclosed on HackerOne

  • 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 keyd module:
    • npm i keyd

Set the __proto__.polluted property of an object:

JavaScript

const keyd = require('keyd');
const obj = {};
console.log("Before : " + obj.polluted);
keyd({}).set('__proto__.polluted', 'yes');
console.log("After : " + obj.polluted);

Output:

CONSOLE

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

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.

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

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

  1. Install the keyd module using npm.
  2. Create an empty object and check that a property like 'polluted' is undefined.
  3. Call keyd({}).set with the path '__proto__.polluted' and a value.
  4. 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.

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.