Skip to content

Bug class · Advanced

Prototype pollution

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

median public bounty
$5,000

Covers CWE 1321.

How it works

Full lesson

The pattern behind every report in this class.

Prototype pollution is a vulnerability where an attacker can add or modify properties on the shared prototype of objects in JavaScript (and similar object models in other languages). Because many objects inherit from that prototype, a single polluted property can affect every plain object in the application. Programs care because this can lead to serious consequences such as denial of service, DOM cross-site scripting, and even remote code execution, depending on how the polluted property is later used. The evidence shows reports across npm packages, server-side Node applications, client-side web front ends, and other technologies.

In practice, prototype pollution often arises when libraries or application code merge, extend, clone, or set nested properties using attacker-controlled keys without blocking special key names. The reports in the evidence include many npm packages that perform these operations, such as dot-prop, object-path-set, extend-merge, klona, and jQuery's extend. It also appears in server-side code that recursively merges JSON, in XML parsing libraries, and in features like Kibana's telemetry collector and GitLab's Mermaid directives. The impact ranges from observable side effects and denial of service to code execution, and it is frequently found in widely used transitive dependencies.

The core mechanism is that an attacker supplies a key or path that names the prototype (for example, a key that resolves to the prototype object) to a function that assigns or merges properties. If the function does not reject such keys, the assignment lands on the shared prototype instead of on the intended object. Once a property is set on the prototype, every object that inherits from it will appear to have that property, which can change application behaviour in unexpected ways.

Many libraries that set values at a dotted or array property path are vulnerable because they walk the path and create intermediate objects without checking whether a segment refers to the prototype. Similarly, recursive merge and extend helpers copy properties from a source object to a target; if the source contains a prototype-named key, the merge can write to the prototype. Clone and config-merge utilities can also be affected if they copy properties without filtering special keys.

Things to try

All 27

Each line worked in a disclosed report. Test only what a program's scope allows.

Client-side sinks and DOM 3

  • Look for a client-side sink that reads a property from the prototype and turns it into markup or script, then pollute that property through a query or fragment parameter.
  • Add a Mermaid diagram with a directive that sets a prototype-named key in an issue, save it and open the issue to see whether the page breaks.
  • Pollute a property that a page later renders as HTML and check whether injected markup appears.

Language-specific runtimes 3

  • Send JSON with keys naming instance variables or methods into a recursive merge and check whether the object's behaviour changes.
  • Send nested keys aimed at class attributes in a Python service and check for altered behaviour or a crash.
  • Pollute a property in a Blitz.js request path and check whether it reaches code execution.

Other 3

  • Pass an object with prototype-named properties to console.table and check whether the prototype is modified.
  • Review recursive merge and dynamic assignment code for missing checks on special key names.
  • Do not rely only on automated scanners; manually verify suspected pollution points that tools miss.

Stored and persistent pollution 3

  • Index a document whose field names target the prototype in a telemetry collector, then wait for collection or restart the service to trigger it.
  • Write a crafted influencer field name into an anomaly index, import a detection rule that uses it, enable the rule and wait for evaluation.
  • Check whether a client-side pollution survives a reload or navigation, for example through stored state, and whether it can be re-triggered later.

jQuery and legacy frameworks 3

  • Send a nested object with a prototype-named key into a jQuery extend call and check whether the resulting object has a polluted property.
  • Look for jQuery gadgets that read a polluted property and turn it into script execution or DOM changes.
  • Check whether an old AngularJS build is loaded in production and whether its merge helpers can be reached from user input.

Bypasses and variations

  • Try to get a prototype-named key past a web application firewall on a client-side sink.

Tips for beginners

All 14
  • Start by looking for libraries and application code that merge, extend, clone, or set nested properties using user-controlled keys. The evidence lists many npm packages and patterns, such as dot-prop, object-path-set, extend-merge, klona, and jQuery's extend. Focus on places where input from query parameters, JSON bodies, or XML is passed into these functions.
  • When testing a merge or extend helper, feed a nested key named for the prototype and check whether a property appears on all plain objects afterwards. For path-setting helpers, pass a path whose first segment names the prototype and see whether the assignment lands on the shared prototype. Always verify the effect on the prototype itself, not just on the returned object.
  • For server-side targets, detect pollution through observable side effects rather than crashing the process. Look for changed responses or behaviour after a crafted request, and avoid denial-of-service style tests that could disrupt the service. The evidence includes detection without denial of service as a specific technique.
  • On the client side, look for a sink that reads a property from the prototype and turns it into markup or script, then pollute that property through a query or fragment parameter. Check whether the pollution survives a reload or navigation, for example through stored state, and whether it can be re-triggered later. This can turn prototype pollution into DOM XSS.
  • Review recursive merge and dynamic assignment code for missing checks on special key names. Manual code review of merge and assignment logic in server code is a reliable way to find these issues, especially in Ruby applications that recursively merge user-supplied JSON into object attributes.
  • Test XML parsing libraries by sending XML with element or attribute names aimed at the prototype and checking the parsed object's prototype. Libraries such as fast-xml-parser and xml2js build objects from parsed input and may be vulnerable if they do not filter special keys.

Start here: a reading path

Open the path

Clear reports in order, easiest first.

Guides and techniques

View all

The best explainers, cheat sheets and technique posts on Prototype pollution, from around the web.

Newest reports

All 127

Most recently disclosed.

New Prototype pollution reports by email

Follow Prototype pollution and get each week's new disclosures in one short email.

Free. New reports for what you follow, weekly by default. One-click unsubscribe. Privacy