Prototype Pollution Bugs
Prototype Pollution is a vulnerability that allows attackers to exploit the rules of the JavaScript programming language, by injecting properties into existing JavaScript language construct prototypes, such as Objects to compromise applications in various ways.
JavaScript allows all Object attributes to be altered. This includes their magical attributes such as __proto__, constructor and prototype.
An attacker is able to manipulate 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, resulting in either:
- Denial of Service – by triggering JavaScript exceptions;
- Remote Code Execution – by tampering with the application source code to force the code path that the attacker injects – read more;
- XSS – read more.
Why is Prototype Pollution an issue?
In Javascript, prototypes define an object’s structure and properties, so that the application knows how to deal with the data. When new objects are created, they carry over the properties and methods of the prototype “object“. If you modify the prototype in one place, it will affect how the objects work throughout an entire application.