Prototype Pollution

Prototype pollution is a JavaScript vulnerability that enables an attacker to add arbitrary properties to global object prototypes, which may then be inherited by user-defined objects. name.__proto__ , name['__proto__'] , name.constructor.prototype

Steps:

  • Try different ways of adding an arbitrary property to Object.prototype. Try to inject an arbitrary property via the query string, URL fragment, and any JSON input. (es. __proto__[foo]=bar -> In console Object.prototype.foo)

  • Identify a gadget property that allows you to execute arbitrary JavaScript.

Use DOM Invader and Server-Side Prototype Pollution Scanner.

More difficult to detect:

  • No source code access

  • Lack of developer tools

  • The DoS problem

  • Pollution persistence

POST or PUT requests that submit JSON data to an application or API are prime candidates

POST Request
{
    "user":"wiener",
    "__proto__":{
        "foo":"bar"
    }
}

Detection

RCE

For identifying

For exploit

or

Last updated

Was this helpful?