Skip to content

Random Notes about prototype pollution

Published: at 03:22 PMSuggest Changes

Understanding Prototypes

Prototypes in JavaScript are like a blueprint. Every object gets default properties and behavior from this blueprint.

const car = {}; // Creating a Object 
// The object can already do things like car.toString() because it inherits this ability from the prototype (Object.prototype).

Prototype pollution is a JavaScript security issue where an attacker can add or change properties in a default object (called a prototype). This can break an application or let the attacker do bad things like bypassing security or gaining extra privileges.

Example

Let’s imagine JavaScript objects are like cookie cutters. When you create a cookie (object), it takes the default shape from the cutter (prototype). If someone secretly alters the cutter, every new cookie inherits the changes.

const user = JSON.parse('{"__proto__": {"isAdmin": true}}');
console.log(user.isAdmin); // Output: true (unintended!)

Flow diagram of above the example

Important points about proto


Previous Post
Hacking Porn and Dating Sites - A Theme-Based Bug Bounty Approach
Next Post
Breach in the Cloud - Cloudtrial challenge