Client-Side Prototype Pollution

Prototype pollution in the browser. URL, postMessage or storage data writes to Object.prototype in the page’s JS realm, and a front-end gadget turns the inherited property into DOM XSS or a security-control bypass.

How it works

  • Sources. These are the browser-side inputs that front-end code parses into objects (InfoSec Write-ups):
    • URL query or fragment parsed into an object: https://target/#__proto__[polluted]=true or ?__proto__[x]=y
    • postMessage data merged into state
    • localStorage/sessionStorage JSON that gets re-merged
    • WebSocket frames
  • Sinks. Client merge and extend helpers such as $.extend, _.merge and deep-param parsers. JSON.parse + JSON.stringify cloning on its own is safe, but merging the clone afterwards is not (InfoSec Write-ups).
  • Gadgets. A library reads an unset option (for example an HTML template, script URL or sanitizer config) and inherits the attacker’s value. The typical outcome is DOM XSS. Tib3rius summarizes client-side impact as “can lead to DOM XSS” (Tib3rius). Gadget CVEs in DOMPurify (CVE-2024-48910) and React Router (CVE-2026-42211) are exploitable only when pollution already exists in the page (JFrog).
  • Scope. Pollution lasts for the page’s JS realm and only affects the victim’s tab. Delivery is a crafted link, unlike Server-Side Prototype Pollution, which persists for the process and affects every user.

Techniques / payloads

Detection one-liner (mass triage). Append a URL-source pollution probe and evaluate the result in a headless page (0xPugazh, dwisiswant0):

sed 's/$/\/?__proto__[testparam]=exploit\//' alive.txt \
 | page-fetch -j 'window.testparam == "exploit" ? "[VULNERABLE]" : "[NOT VULNERABLE]"'

Manual confirmation. After loading the page with the payload, check ({}).polluted === "yes" in DevTools (InfoSec Write-ups).

DOM Invader. This Burp browser extension automatically identifies client-side pollution sources, then scans for controllable gadgets passed to dangerous sinks. It covers web-message vectors in the same workflow (DOM Invader). See DOM-Based XSS.

Prototype overwrite as an XSS primitive. Once you have JS execution or expression evaluation, overwriting built-in prototypes produces filter-evading payloads. These are related techniques, not input-key pollution:

  • Parenthesis-free calls. Set an event handler to setTimeout, point Event.prototype.toString at an Error-family toString, and place the code in Event.prototype.name/message. The event object is then stringified into code. PortSwigger’s cheat sheet lists variants for onhashchange, onscroll, onpagereveal and others (PortSwigger XSS cheat sheet).
  • ikaes uses the same idea by polluting Object.prototype.message and borrowing Error.prototype.toString for Array.prototype.toString. The payload then fires from a coerced Error (ikaes).
  • AngularJS sandbox escapes. Overwriting 'a'.constructor.prototype.charAt=[].join breaks Angular’s lexer so that $eval accepts code (PortSwigger CSTI). Per-version payloads reach __proto__ through computed keys (Angular payload gist).

Notable cases

  • DOMPurify CVE-2024-48910 was rated critical by GitHub/NVD but assessed low by JFrog, because it requires prior pollution. Score a client-side gadget together with a real source (JFrog).
  • Adobe Acrobat Reader CVE-2026-34621 is the same class in a non-browser JS host. A malicious PDF’s form-action JS pollutes the base prototype to override security-critical internals, leading to code execution on open. It was exploited in spear-phishing (Mishcon).

Defenses

  • Don’t deep-merge URL or postMessage data into option objects. Parse into Object.create(null) or Map and reject __proto__/constructor/prototype keys (see Prototype Pollution > Prevention).
  • Validate postMessage origin and schema before merging.
  • Keep front-end libraries (jQuery, lodash, sanitizers) current, and re-test gadgets after upgrades (InfoSec Write-ups).

Sources