Prototype Pollution

An attacker-controlled key such as __proto__ or constructor.prototype reaches a property write on a plain object, so the value lands on Object.prototype and is inherited by every object in the JavaScript runtime (CWE-1321).

What it is

Every JS object resolves missing properties by walking its [[Prototype]] chain to Object.prototype. If user input controls a key path in a recursive merge, clone, path-setter or parser, a write to obj["__proto__"][k] = v becomes Object.prototype[k] = v, and ({}).k === v from then on (InfoSec Write-ups deep dive, JFrog).

The broken trust boundary is between data keys and the object model. The parser treats "__proto__" as an ordinary string key (JSON.parse does not special-case it), but the assignment target does special-case it. The bug is in the sink that copies the key, not in the parser.

Pollution is a primer, not an impact. It only matters when a gadget later reads an unset property, gets the inherited value, and passes it to something dangerous. The gadget can be the app’s own code, a library, or the runtime (InfoSec Write-ups, JFrog). Tib3rius’s interview canon gives the split: client side usually leads to DOM XSS, and server side (Node.js) leads to access-control bypass or RCE (Tib3rius).

Why it matters

Impact ladder, from weakest to strongest:

LevelWhat the gadget doesExample from the notes
DoSInherited keys break iteration or validation everywheren8n: TypeORM buildWhere picks up the polluted key through for...in and throws on every query. The instance stays down until restart ([[raw/simonkoeck.com/cve-2026-33696-from-a-schema-name-to-rce-in-n8n-11422
Logic / authz bypassisAdmin, role and similar checks read an inherited true{"__proto__":{"isAdmin":true}} via Object.assign/_.merge ([[raw/infosecwriteups.com/javascript-prototype-pollution-deep-dive-reconnaissance-exploitation-b-8657
DOM XSSA library reads an unset config key into an HTML/script sinkClient-side URL-fragment or query sources ([[raw/portswigger.net/dom-invader-2577
SSRF / MitMThe HTTP client inherits proxy or headersAxios proxy gadget (CVE-2026-44494) and the Axios header-CRLF gadget that reaches IMDSv2 ([[raw/jfrog.com/where-severity-scores-go-wrong-just-add-prototype-pollution-10035
RCEInherited keys reach spawn env/options, a template compiler, or Function() codegenn8n GIT_SSH_COMMAND, Handlebars/Pug AST injection, protobuf.js CVE-2026-44291

What drives severity is whether both halves exist in the same process. JFrog reassessed the ten 2026 Axios “gadget” CVEs, which GitHub/NVD rated from low to critical. Each one is exploitable only if pollution already exists elsewhere in the runtime, so JFrog rates most of them low or medium. The same reasoning applied to DOMPurify CVE-2024-48910, React Router CVE-2026-42211 and Piscina CVE-2026-55388 (JFrog). Prototype pollution is no longer limited to the web: Adobe Acrobat Reader CVE-2026-34621 (CVSS 8.6) was a prototype pollution bug in Reader’s embedded JS engine and was exploited in the wild through phishing PDFs (Mishcon, THN, HKCERT). At ecosystem scale, Unit 42’s AI-driven zero-day sweep found that JS/TS findings concentrate in code injection, prototype pollution and SSRF (Unit 42).

How it works

Three ingredients:

  1. Source. Attacker-shaped keys: a JSON body, query string (a[__proto__][x]=1, __proto__.x=1), URL fragment, postMessage, localStorage, WebSocket frames, GraphQL variables, XML, cookies or upload metadata (InfoSec Write-ups).
  2. Pollution sink. Code that writes nested keys without own-property and name checks: _.merge/defaultsDeep, $.extend, Object.assign into a shared object, flat/unflatten, qs-style bracket parsers, path setters, obj[userKey] ??= {}.
  3. Gadget. A read of an unset property whose inherited value reaches a sink. See Prototype Pollution Gadgets.
// pollution sink (n8n GSuiteAdmin, CVE-2026-33696, simplified)
customSchemas[schemaName] ??= {};          // schemaName = "__proto__" -> Object.prototype
customSchemas[schemaName][fieldName] = v;  // Object.prototype[fieldName] = v

(Koeck)

Variants:

  • Client-Side Prototype Pollution. URL and postMessage sources in the browser. Gadgets live in front-end libraries and lead to DOM XSS or sanitizer bypass.
  • Server-Side Prototype Pollution. Node.js body, query and parser sources. The process is long-lived, so one request poisons every later request. Gadgets lead to authz bypass, DoS, SSRF or RCE.
  • Parser and deserializer pollution. Formats whose decoders resolve attacker-named properties up the chain: React Flight (React2Shell, CVE-2025-55182), xml2js, GraphQL incremental-delivery merge, protobuf.js. These are covered on the server-side page and in Insecure Deserialization.
  • Prototype traversal in sandboxes. The same chain-walking breaks JS sandboxes: vm2’s 2026 escapes (CVE-2026-43999 “escape the sandbox and enable prototype pollution”), and Cohere Terrarium CVE-2026-5752 (Pyodide → host Node.js prototype traversal, root in the container) (THN vm2, THN Terrarium).
  • Prototype overwrite inside expression sandboxes. AngularJS sandbox escapes overwrite String.prototype.charAt to break the expression lexer. This is a close cousin rather than input-key pollution, so see Client-Side Prototype Pollution.

Where to find it

  • Stack signals. Node/Express is the place to look for prototype pollution and SSRF (as93 recon). Fingerprint jQuery, lodash, Handlebars and similar libraries and their versions in JS bundles (InfoSec Write-ups).
  • Features that merge user objects into existing ones. Settings and profile PATCH endpoints, config import, “update preferences” endpoints, which overlap with Mass Assignment.
  • Generic key-to-object code. Any place a user string becomes a property name: schema names, field names, workflow node parameters (n8n), XML tag names (xml2js), GraphQL path segments (graphql-tools).
  • Non-HTTP transports. WebSocket messages and GraphQL variables (InfoSec Write-ups), and upstream GraphQL @defer/@stream responses consumed by a gateway (GitLab advisory).
  • Schema and codegen pipelines. protobuf.js treats schemas and descriptors as trusted (THN Proto6).
  • Template contexts. {{this.__proto__}} rendering [object Object] in an email or profile template points to a Node engine and prototype access (H1 #423541, SSTI 2k25).

How to test

  1. Fingerprint. Is the runtime Node or a heavy front-end, and which merge, parse or template libraries are in use, at what versions?
  2. Map sources. Spider the app and pull endpoints from JS. Include JSON, query, cookie, WebSocket, GraphQL and XML inputs (InfoSec Write-ups).
  3. Try the payload-shape matrix on every object-accepting input:
    {"__proto__":{"polluted":"yes"}}
    {"constructor":{"prototype":{"polluted":"yes"}}}
    {"a":{"__proto__":{"polluted":"yes"}}}
    {"__proto__":{"__proto__":{"polluted":"yes"}}}
    ?__proto__[polluted]=yes   ?__proto__.polluted=yes   #__proto__[polluted]=yes
    
    Also try nesting deeper than the top level. xml2js blocked a top-level <__proto__> (CVE-2023-0842), but a nested one still worked (dexpose). Try non-string key types too, such as an array segment ["__proto__"] against === blocklists (GitLab advisory).
  4. Confirm pollution without breaking things.
    • Client side: check ({}).polluted in the console, or let DOM Invader find the source.
    • Server side: look for an inherited key reflected in later JSON responses, or a status flip (403 → 200) (InfoSec Write-ups). Prefer non-destructive property names, because server pollution persists for the life of the process and can DoS the target (n8n/TypeORM).
  5. Hunt a gadget. Look for library-specific canaries. For example, an Object.prototype.pendingContent string appearing in Handlebars output fingerprints the engine black-box (po6ix). Then trace which unset properties reach sinks. See Prototype Pollution Gadgets.
  6. Report the chain. A gadget without a source gets discounted, so pair the source with the sink in the same process (JFrog; see Vulnerability Chaining).

Checklist

  • Every JSON/query/XML/GraphQL/WebSocket object input tried with __proto__, constructor.prototype, nested and bracket/dot forms
  • Array and other non-primitive key segments tried against name blocklists
  • Client-side: URL query and hash, postMessage, storage sources checked (DOM Invader / pphack)
  • Server-side: a reflected inherited property or a status/behavior change confirmed with a benign key
  • Gadget identified in the same runtime (template engine, HTTP client, child_process, codegen, sanitizer)
  • Persistence and DoS risk considered before polluting shared server keys
  • Clean-up planned (re-set the key to undefined where the app allows it)

Exploitation and escalation

  • To DOM XSS or sanitizer bypass. Inherited config keys flow into innerHTML or script src in front-end libraries. See Client-Side Prototype Pollution and DOM-Based XSS.
  • To authz bypass. Inherited isAdmin/role flags. This overlaps with Mass Assignment.
  • To RCE through child_process. Polluted env keys pass through objects the app allocates as {}. n8n’s Git node (simple-git .env() → spawn) inherits GIT_SSH_COMMAND, which git runs as a shell command on SSH-style URLs (Koeck, dexpose). Node’s own spawn no longer honors polluted options directly, so the gadget has to be app code that builds a plain options or env object (dexpose).
  • To RCE through template compilers (AST injection). Pollution inserts nodes into the Handlebars or Pug AST, and the compiler emits them into a generated function (po6ix). See JavaScript Template Engine SSTI.
  • To RCE through codegen. protobuf.js resolves type names by plain property lookup, so a polluted prototype makes an attacker string look like a primitive type. The string is then compiled with Function() (CVE-2026-44291) (THN Proto6).
  • To SSRF, cloud compromise or MitM. Axios inherits proxy (traffic interception) or CRLF-bearing header values, which smuggle an IMDSv2 token PUT (JFrog, GHSA-fvcv-3m26-pcqx). See Cloud Metadata Service Exploitation.
  • Deserializer-native chains. React2Shell reaches constructor:constructor (the Function constructor) through prototype-chain references in Flight payloads (OffSec). See Remote Code Execution.

Bypassing defenses

  • Top-level-only checks. xml2js rejected a top-level __proto__ tag after CVE-2023-0842, but a nested <test><__proto__/></test> still handed back a reference to Object.prototype (dexpose).
  • in versus own-property. xml2js’s CoffeeScript key not of obj compiles to !(key in obj). The in check walks the chain, so inherited names (__proto__, constructor) are treated as existing keys (dexpose).
  • Type confusion against string blocklists. graphql-tools compared segments with === '__proto__', but an array segment ["__proto__"] passes the check and is then coerced to the key "__proto__" by ToPropertyKey (CVE-2026-114604, fixed in 12.0.2). The earlier dset-based code (≤10.10.0) was not exploitable (GitLab advisory, Miggo).
  • constructor.prototype instead of __proto__. Filters that block only __proto__ miss it (InfoSec Write-ups).
  • Guards that exist but aren’t used. n8n already had a deepMerge with pollution guards, but the GSuiteAdmin node didn’t call it (Koeck).
  • Constrained primitives still chain. xml2js only gave array-wrapped values, but a post-parse “Edit Fields” step could write arbitrary keys through the leaked reference (dexpose).

Real-world cases

  • n8n CVE-2026-33696 (CVSS 9.4). GSuiteAdmin schemaName="__proto__" → GIT_SSH_COMMAND → RCE through the Git node, plus a TypeORM DoS (Koeck, THN ThreatsDay).
  • n8n CVE-2026-42231. xml2js nested __proto__ in a webhook body → unauthenticated RCE through a spawn-style gadget in @n8n/node-cli (dexpose).
  • React2Shell CVE-2025-55182. React 19.0.0–19.2.0 and Next.js 16.0.0–16.0.6. The Flight decoder resolves attacker property names without own-property checks, leading to unauthenticated RCE. Exploited from 5 Dec 2025, mostly to deploy coin miners (Seqrite, Microsoft, Resecurity).
  • graphql-tools CVE-2026-114604 (8.4). mergeIncrementalResult array-segment bypass. A malicious upstream pollutes the gateway (CVE Brief, SecOps Signal, OpenAdvisories).
  • protobuf.js “Proto6”. CVE-2026-44291 (8.1) is a codegen gadget after pollution, and CVE-2026-44292 is prototype injection in generated constructors. Fixed in 7.5.6 and 8.0.2 (THN, EntryZero).
  • Axios 2026 gadget wave. Ten CVEs that all need pre-existing pollution. JFrog chained lodash CVE-2019-10744 (defaultsDeep, 4.17.11) with CVE-2026-44494 to get MitM (JFrog).
  • Adobe Acrobat Reader CVE-2026-34621. Prototype pollution in Reader’s JS engine through PDF form actions. Exploited in the wild (Mishcon).
  • Handlebars GHSA-2cf5-4w76-r9qv (2021). Prototype pollution through crafted templates (Xygeni). The Shopify Return Magic Handlebars RCE abused Object.prototype.toString overriding (mahmoudsec).
  • vm2 2026 escapes and Cohere Terrarium CVE-2026-5752. Prototype traversal used as a sandbox escape (THN, THN).
  • jQuery CVE-2019-11358: $.extend(true, …) deep merge did not block __proto__, so pollution plus an application gadget gave XSS. (source)

Prevention

  • Block dangerous keys at every write. Reject __proto__, constructor and prototype, and only after validating that the key is a primitive string or number (Koeck, GitLab advisory).
  • Use prototype-less containers for user-keyed maps. Object.create(null) (or Map) for anything keyed by user input (Koeck).
  • Use own-property checks, not in or a bare obj[key], when resolving attacker-named properties. This was the root cause in both React Flight and xml2js (Seqrite, dexpose).
  • Use one vetted deep-merge. Route every merge through a single guarded helper, and lint for ad-hoc obj[a][b] = v (Koeck).
  • Freeze prototypes where the architecture allows it. Mozilla’s frozen-prototypes design repeatedly stopped an AI model’s prototype-pollution sandbox-escape attempts in Firefox (tl;dr sec #328).
  • Harden gadgets. Validate header values for CRLF (Axios), stop treating schemas and metadata as trusted code (protobuf.js), and keep Handlebars patched against its own pollution advisory (GHSA-fvcv-3m26-pcqx, THN Proto6, Xygeni).
  • Patch the source libraries. No seven-year-old lodash (4.17.11 / CVE-2019-10744), graphql-tools ≥12.0.2, protobufjs 7.5.6/8.0.2, React/Next.js past the React2Shell fix. Score gadget CVEs in context rather than at face value (JFrog).

Tools

ToolUse
DOM Invader (Burp browser)Finds client-side pollution sources and scans for gadgets that reach sinks ([[raw/portswigger.net/dom-invader-2577
Server-Side Prototype Pollution Scanner (hackvertor, Burp ≥2021.9)Non-destructive server-side detection ([[raw/github.com/snoopysecurity-awesome-burp-extensions-a-curated-list-of-amazingly-awe-892
Prototype Pollution Gadgets Finder (BApp)Server-side gadget analysis ([[raw/portswigger.net/bapp-store-portswigger-2862
BChecks “Server Side Prototype Pollution”Scanner check for Burp Pro ([[raw/github.com/portswigger-bchecks-bchecks-collection-for-burp-suite-professional-5576
pphackClient-side prototype pollution scanner ([[raw/github.com/ars0n-framework-v2-bug-bounty-hunting-framework-4866
page-fetch one-linerMass client-side check: append ?__proto__[testparam]=exploit and evaluate window.testparam ([[raw/github.com/0xpugazh-one-liners-1013
SAST / LLM reviewPrototype pollution is among the classes LLM reviewers find reliably (Snyk VulnBench JS), but SAST hits inside vendored libraries are mostly false positives without context ([[raw/snyk.io/snyk-vulnbench-js-1-0-can-llms-find-the-same-bugs-twice-9972

Sub-pages

Related: Remote Code Execution · DOM-Based XSS · Cross-Site Scripting · JavaScript Template Engine SSTI · Server-Side Template Injection · Mass Assignment · Insecure Deserialization · Gadget Chains · Server-Side Parameter Pollution · Vulnerability Chaining · GraphQL Security · Cloud Metadata Service Exploitation

Sources