Skip to content

Reading list

Learn Prototype pollution from real reports

Input changes JavaScript's shared object prototype, altering behaviour across the application, sometimes to XSS or code execution.

12 reports, easiest first.

  1. [object-path-set] Prototype pollution

    Node.js third-party modules Beginner

    The object-path-set module allows an attacker to set properties on Object.prototype via a path like __proto__.polluted. This prototype pollution could lead to denial of service, remote code execution, or property injection depending on the application.

    Prototype pollution is a JavaScript bug where an attacker can add or change properties on the base object that all other objects inherit from. This means every object in the program suddenly gets that property, which can break logic or even let an attacker run code. Here, a library that sets nested values by path did not block special path parts like __proto__.

    The lesson. Likely the setPath function does not block or sanitise special path segments such as __proto__, constructor, or prototype, allowing assignment to Object.prototype.

  2. Prototype pollution attack (merge.recursive)

    Node.js third-party modules Beginner

    The merge.recursive function in the merge npm package can be tricked into adding or modifying properties on Object.prototype by passing an object with a __proto__ key. An attacker could use this to inject properties that appear on all objects, potentially causing denial of service or other effects depending on the application.

    Prototype pollution lets an attacker add or change properties that every object inherits. Here, a function that merges objects does not block a special __proto__ key, so an attacker can inject a property like isAdmin into every object, which can break the application.

    The lesson. Likely the merge.recursive function does not filter or block the __proto__ key when recursively merging objects, allowing it to modify Object.prototype.

  3. [ts-dot-prop] Prototype Pollution

    Node.js third-party modules Beginner

    The set function in ts-dot-prop allows setting properties on Object.prototype via a __proto__ path, enabling prototype pollution. An attacker could modify prototype behaviour, potentially leading to sensitive information disclosure, denial of service, or remote code execution depending on the application.

    Prototype pollution is when an attacker can add or change properties on a shared base object that many other objects inherit from. In JavaScript, every object inherits from Object.prototype, so changing it affects all objects. Here, a library function that sets nested properties did not block the special __proto__ key, so an attacker could add a property like isAdmin to every object.

    The lesson. The set function does not block or sanitise the __proto__ key when traversing a dot-notation path, allowing writes to Object.prototype.

  4. [extend-merge] Prototype pollution

    Node.js third-party modules Beginner

    The merge function in the extend-merge npm package allows an attacker to add or modify properties on the Object prototype by passing an object with a __proto__ property. This can lead to denial of service, remote code execution, or property injection depending on the application.

    Prototype pollution is a bug where an attacker can add or change properties on a base object that all other objects inherit from. In JavaScript, every object inherits from Object.prototype, so polluting it affects every object in the program. This can break the application or, in some cases, let the attacker run their own code.

    The lesson. The merge function allows keys like __proto__ to modify Object.prototype.

  5. [keyd] Prototype pollution

    Node.js third-party modules Beginner

    The keyd library's set function allows an attacker to add properties to Object.prototype, polluting all objects. This could lead to denial of service, remote code execution, or property injection depending on the application.

    Prototype pollution lets an attacker add properties to the base object that other objects inherit from, which can affect the application.

    The lesson. The set function does not properly validate or block the special __proto__ key, allowing modification of Object.prototype.

  6. [json8-merge-patch] Prototype Pollution

    Node.js third-party modules Beginner

    The apply function in json8-merge-patch does not restrict access to object prototypes, allowing an attacker to modify prototype behaviour. This could lead to sensitive information disclosure, denial of service, or remote code execution depending on how the library is used.

    Prototype pollution is a bug where an attacker can change properties on a shared object that other objects inherit from. Here, a function that merges JSON data let a malicious input set a property on that shared object. This can break the application or, in some cases, may allow an attacker to run their own code.

    The lesson. The apply function does not block the special __proto__ key when merging objects, so it writes to the prototype instead of the object itself.

  7. [plain-object-merge] Prototype pollution

    Node.js third-party modules Beginner

    The merge function in the plain-object-merge npm package copies a __proto__ key from attacker-supplied input onto Object.prototype, so every object in the process gains the injected property. Depending on how the host application uses objects, this could lead to denial of service, property injection or remote code execution.

    JavaScript objects inherit shared defaults from a built-in template called the prototype. If a library copies a special key named __proto__ from untrusted input, it can add new defaults to that shared template, so every object in the program suddenly has the extra property. Here a small merge helper did exactly that, and the reporter showed a plain object gaining a 'polluted' value after the merge.

    The lesson. Likely the merge routine recursed into the __proto__ key of the input object instead of skipping or blocking it, letting the write reach Object.prototype.

  8. [objtools] Prototype pollution

    Node.js third-party modules Beginner

    The merge function in the objtools npm package copies a __proto__ key from attacker-supplied input onto Object.prototype, so every object in the process gains the injected property. Depending on how the host application uses objects, this could lead to denial of service, property injection or remote code execution.

    JavaScript objects inherit shared defaults from a built-in object called Object.prototype. If a library copies a special key named __proto__ from untrusted input, it can add new defaults that every object in the program then sees. Here the merge helper did exactly that, so a crafted object quietly changed behaviour across the whole application.

    The lesson. The merge function copies a __proto__ key from input onto Object.prototype rather than only the target object.

  9. Supply Chain Pollution: Hunting a 16 Million Download/Week npm Package Vulnerability for a CTF Challenge

    Node.js third-party modules Intermediate

    The npm package 'ini' was vulnerable to prototype pollution because it did not blacklist dangerous keys when parsing INI files. An attacker could supply a malicious INI file to pollute object prototypes, potentially leading to remote code execution if the application uses the polluted properties in a dangerous way.

    Prototype pollution is a JavaScript bug where an attacker can add or change properties on the base object that all other objects inherit from. This can make the application behave unexpectedly, for example by making every user appear to be an administrator. In this case, a library that reads configuration files allowed such changes because it did not block special property names.

  10. One ENS text record keyed on an Object.prototype member permanently replaces a name’s Manager profile page, and the Edit dialog inside it, with an error screen

    ENS Intermediate

    The Manager's record-definition lookup uses a plain object, so keys like 'constructor' return inherited Object.prototype members that are truthy but lack a section, causing a TypeError during render. An attacker who owns any name can set such a text record, permanently breaking that name's Manager profile page and its Edit dialog for every visitor.

    The app looks up record types in a JavaScript object, and objects inherit built-in names like 'constructor' and 'toString'. If a name owner writes a text record with one of those names, the lookup returns a built-in function instead of a record definition, and the page crashes while drawing itself. Because the edit screen lives inside the crashed page, the owner cannot remove the record through the app.

    The lesson. Likely the record lookup table is a plain object without an own-property check, so prototype members are treated as valid record definitions and their undefined section is spread into the accumulator.

  11. SQL Injection or Denial of Service due to a Prototype Pollution

    Node.js third-party modules Intermediate

    The TypeORM library's deep merge function did not guard against the __proto__ key, allowing an attacker who can save a crafted object to pollute the Object prototype. This could cause denial of service or SQL injection by altering query logic, and potentially command execution if gadgets exist.

    Prototype pollution is a JavaScript bug where an attacker can add properties to a base object that all other objects inherit from. In this case, a library function that merges objects did not block a special key called __proto__, so an attacker could sneak in extra settings. Those settings could then break the application or change database queries.

    The lesson. The mergeDeep function iterates over all keys of a source object without filtering out the special __proto__ key, so it writes attacker-controlled properties onto Object.prototype.

  12. GHSL-2020-160: Prototype pollution in Merge-deep

    GitHub Security Lab Intermediate

    The merge-deep library attempted to block prototype pollution by preventing merges into __proto__, but still allowed pollution of Object.prototype via a constructor payload. An attacker could set properties on Object.prototype, which are then inherited by all objects, potentially leading to denial of service or remote code execution depending on the application.

    Prototype pollution is a JavaScript bug where an attacker can add or change properties on a base object that many other objects inherit from. In this case, the merge-deep library tried to stop this by blocking one way to reach that base object, but another way (using a 'constructor' property) still worked. This means an attacker could make every object in the program think it has a property like 'isAdmin' set to true, which might bypass security checks.

    The lesson. The library's protection only blocked direct merges into __proto__, but did not block merges into constructor.prototype, allowing prototype pollution.