# 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 ([[raw/infosecwriteups.com/javascript-prototype-pollution-deep-dive-reconnaissance-exploitation-b-8657|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 ([[raw/infosecwriteups.com/javascript-prototype-pollution-deep-dive-reconnaissance-exploitation-b-8657|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" ([[raw/tib3rius.com/web-appsec-interview-questions-5906|Tib3rius]]). Gadget CVEs in DOMPurify (CVE-2024-48910) and React Router (CVE-2026-42211) are exploitable only when pollution already exists in the page ([[raw/jfrog.com/where-severity-scores-go-wrong-just-add-prototype-pollution-10035|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 ([[raw/github.com/0xpugazh-one-liners-1013|0xPugazh]], [[raw/github.com/dwisiswant0-awesome-oneliner-bugbounty-5921|dwisiswant0]]):
```bash
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 ([[raw/infosecwriteups.com/javascript-prototype-pollution-deep-dive-reconnaissance-exploitation-b-8657|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 ([[raw/portswigger.net/dom-invader-2577|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 ([[raw/portswigger.net/cross-site-scripting-xss-cheat-sheet-2026-edition-portswigger-285|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` ([[raw/blog.ikaes.de/i-found-yet-another-way-to-invoke-javascript-functions-without-parenth-12225|ikaes]]).
- *AngularJS sandbox escapes.* Overwriting `'a'.constructor.prototype.charAt=[].join` breaks Angular's lexer so that `$eval` accepts code ([[raw/blog.portswigger.net/portswigger-web-security-blog-xss-without-html-client-side-template-in-395|PortSwigger CSTI]]). Per-version payloads reach `__proto__` through computed keys ([[raw/gist.github.com/angular-template-injection-payloads-393|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 ([[raw/jfrog.com/where-severity-scores-go-wrong-just-add-prototype-pollution-10035|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 ([[raw/mishcon.com/adobe-acrobat-reader-prototype-pollution-vulnerability-enables-remote-5627|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 ([[raw/infosecwriteups.com/javascript-prototype-pollution-deep-dive-reconnaissance-exploitation-b-8657|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
- [[raw/infosecwriteups.com/javascript-prototype-pollution-deep-dive-reconnaissance-exploitation-b-8657|JavaScript Prototype Pollution Deep Dive: Reconnaissance, Exploitation & Bug Bounty Guideline]]
- [[raw/portswigger.net/dom-invader-2577|DOM Invader]]
- [[raw/github.com/0xpugazh-one-liners-1013|0xPugazh/One-Liners]]
- [[raw/github.com/dwisiswant0-awesome-oneliner-bugbounty-5921|dwisiswant0/awesome-oneliner-bugbounty]]
- [[raw/tib3rius.com/web-appsec-interview-questions-5906|Web AppSec Interview Questions]]
- [[raw/jfrog.com/where-severity-scores-go-wrong-just-add-prototype-pollution-10035|Where Severity Scores Go Wrong: "Just Add Prototype Pollution"]]
- [[raw/portswigger.net/cross-site-scripting-xss-cheat-sheet-2026-edition-portswigger-285|Cross-Site Scripting (XSS) Cheat Sheet - 2026 Edition]]
- [[raw/blog.ikaes.de/i-found-yet-another-way-to-invoke-javascript-functions-without-parenth-12225|I found yet another way to invoke JavaScript functions without parentheses]]
- [[raw/blog.portswigger.net/portswigger-web-security-blog-xss-without-html-client-side-template-in-395|XSS without HTML: Client-Side Template Injection with AngularJS]]
- [[raw/gist.github.com/angular-template-injection-payloads-393|Angular Template Injection Payloads]]
- [[raw/mishcon.com/adobe-acrobat-reader-prototype-pollution-vulnerability-enables-remote-5627|Adobe Acrobat Reader: Prototype pollution vulnerability enables remote code execution]]