Client-Side Prototype Pollution
Prototype pollution in the browser. URL,
postMessageor storage data writes toObject.prototypein 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]=trueor?__proto__[x]=y postMessagedata merged into statelocalStorage/sessionStorageJSON that gets re-merged- WebSocket frames
- URL query or fragment parsed into an object:
- Sinks. Client merge and extend helpers such as
$.extend,_.mergeand deep-param parsers.JSON.parse+JSON.stringifycloning 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, pointEvent.prototype.toStringat anError-familytoString, and place the code inEvent.prototype.name/message. The event object is then stringified into code. PortSwigger’s cheat sheet lists variants foronhashchange,onscroll,onpagerevealand others (PortSwigger XSS cheat sheet). - ikaes uses the same idea by polluting
Object.prototype.messageand borrowingError.prototype.toStringforArray.prototype.toString. The payload then fires from a coercedError(ikaes). - AngularJS sandbox escapes. Overwriting
'a'.constructor.prototype.charAt=[].joinbreaks Angular’s lexer so that$evalaccepts 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
postMessagedata into option objects. Parse intoObject.create(null)orMapand reject__proto__/constructor/prototypekeys (see Prototype Pollution > Prevention). - Validate
postMessageorigin and schema before merging. - Keep front-end libraries (jQuery, lodash, sanitizers) current, and re-test gadgets after upgrades (InfoSec Write-ups).
Related
- Prototype Pollution (main guide)
- Server-Side Prototype Pollution · Prototype Pollution Gadgets
- DOM-Based XSS · XSS Filter Bypasses · Cross-Site Scripting · Content Security Policy
Sources
- JavaScript Prototype Pollution Deep Dive: Reconnaissance, Exploitation & Bug Bounty Guideline · original
- DOM Invader · original
- 0xPugazh/One-Liners · original
- dwisiswant0/awesome-oneliner-bugbounty · original
- Web AppSec Interview Questions · original
- Where Severity Scores Go Wrong: "Just Add Prototype Pollution" · original
- Cross-Site Scripting (XSS) Cheat Sheet - 2026 Edition · original
- I found yet another way to invoke JavaScript functions without parentheses · original
- XSS without HTML: Client-Side Template Injection with AngularJS · original
- Angular Template Injection Payloads · original
- Adobe Acrobat Reader: Prototype pollution vulnerability enables remote code execution · original