githubEdit

Prototype Pollution

Prototype pollution is a JavaScript vulnerability that allows attackers to modify the prototype of base objects, potentially leading to XSS, RCE, or DoS.

How It Works

// JavaScript objects inherit from Object.prototype
let obj = {};
console.log(obj.toString); // inherited from Object.prototype

// Pollution occurs when attacker controls property assignment
obj.__proto__.polluted = "yes";
// OR
obj["__proto__"]["polluted"] = "yes";
// OR
obj.constructor.prototype.polluted = "yes";

// Now ALL objects have this property
let newObj = {};
console.log(newObj.polluted); // "yes"

Detection

Manual Testing

Automated Detection

Common Sinks (Client-Side)

Exploitation Payloads

DOM XSS via Prototype Pollution

Gadgets for Common Libraries

Server-Side Prototype Pollution (Node.js)

Bypass Techniques

Tools & Resources

  • XSS - Prototype pollution often chains to XSS

  • Deserialization - Similar object manipulation concepts

  • SSTI - Template engines can be affected

Last updated

Was this helpful?