Server-Side Prototype Pollution

Prototype pollution in a Node.js process. A request body, query string or parsed document writes to the server’s shared Object.prototype, and that state persists across every later request until the process restarts.

How it works

  • Sources. Express express.json()/body-parser, qs-style query parsing, cookies, upload metadata, GraphQL variables and WebSocket messages (InfoSec Write-ups). Less obvious sources include XML bodies (xml2js), upstream GraphQL incremental responses, and protobuf schemas.

  • Sinks.

    • Object.assign(user, req.body)
    • _.merge(defaultConfig, userConfig)
    • lodash defaultsDeep (CVE-2019-10744)
    • flat
    • ad-hoc obj[userKey] ??= {}; obj[userKey][k] = v

    Sources for this list: InfoSec Write-ups, JFrog, Koeck.

  • Why it is worse than client side. One process serves every user. A single request poisons all later objects, so impact runs from logic bypass (isAdmin) to denial of service to RCE (Tib3rius). The same persistence makes careless testing destructive.

Techniques / payloads

Payload-shape matrix for JSON bodies (InfoSec Write-ups):

{"__proto__":{"polluted":"yes"}}
{"constructor":{"prototype":{"polluted":"yes"}}}
{"a":{"__proto__":{"polluted":"yes"}}}
{"__proto__.polluted":"yes"}

Confirm the pollution through a side channel: the inherited key appears in an unrelated JSON response, or an authorization decision changes.

Parser-specific primitives

  • xml2js (n8n CVE-2026-42231). A top-level <__proto__> is blocked (CVE-2023-0842), but a nested <test><__proto__/></test> returns { test: { ['__proto__']: [ [Object: null prototype] {}, '' ] } }. This is a live reference to the prototype, which later workflow steps can write through.

    • Root cause: CoffeeScript key not of obj compiles to !(key in obj), and in walks the prototype chain.
    • Constraint: injected values arrive wrapped in arrays.

    (dexpose)

  • graphql-tools mergeIncrementalResult (CVE-2026-114604, versions 10.10.1–12.0.2).

    • setObjectKeyPath blocks '__proto__'/'constructor'/'prototype' with ===. A path segment ["__proto__"] is an array, so it passes the check, then current[key] coerces it to "__proto__".
    • Attacker position: a malicious, compromised or MITM’d upstream sending @defer/@stream parts to a gateway.
    • Fixed in 12.0.2.

    (GitLab advisory, Miggo, SecOps Signal)

  • React Flight (React2Shell, CVE-2025-55182). The decoder resolves $id:prop:prop references with attacker-supplied property names and no own-property check. Paths such as __proto__:then and constructor:constructor therefore reach Promise machinery and the Function constructor through a fake Chunk object (Seqrite, OffSec). Also see Insecure Deserialization.

  • Workflow and integration nodes. n8n GSuiteAdmin used a user schemaName as a plain-object key, so "__proto__" makes the ??= a no-op and the next assignment writes Object.prototype[fieldName]. Koeck found the bug by grepping nodes-base for missing __proto__/constructor/prototype checks, which is a reusable source-review technique (Koeck).

Black-box gadget fingerprinting. Setting Object.prototype.pendingContent to a marker string makes it appear in Handlebars output, which confirms both the pollution and the engine (po6ix). For escalation see Prototype Pollution Gadgets.

Tooling.

  • Server-Side Prototype Pollution Scanner (hackvertor), a Burp extension for Burp ≥2021.9 (awesome-burp-extensions)
  • Prototype Pollution Gadgets Finder BApp (BApp Store)
  • The “Server Side Prototype Pollution” BCheck (BChecks)

Testing hygiene. Pollution in n8n crashed the instance after each workflow run, because the stats update touched the polluted object. TypeORM’s for...in in buildWhere threw on every query until restart. Use unique, harmless key names, and reset keys to undefined where the app lets you (dexpose, Koeck).

Notable cases

  • n8n CVE-2026-33696 (9.4). An editor-level user goes from GSuiteAdmin pollution to GIT_SSH_COMMAND to RCE as the n8n user. That user holds the credential encryption key. Fixed in 2.14.1, 2.13.3 and 1.123.27 (Koeck, THN).
  • n8n CVE-2026-42231. An xml2js webhook body leads to unauthenticated RCE (dexpose).
  • React2Shell. Affects React 19.0.0–19.2.0 and Next.js 16.0.0–16.0.6, giving unauthenticated RCE. Exploitation was seen from 5 Dec 2025 on Windows and Linux, and most follow-on payloads were coin miners (Microsoft, Resecurity).
  • graphql-tools CVE-2026-114604 (CVSS 8.4) (CVE Brief).

Defenses

  • Use Object.create(null) or Map for user-keyed containers. Reject __proto__/constructor/prototype after checking that the key is a primitive. Route all merges through one guarded deepMerge, since n8n had one and a node bypassed it (Koeck, GitLab advisory).
  • Use own-property lookups (Object.hasOwn) wherever a decoder resolves property names it received from the wire (Seqrite).
  • Treat upstream GraphQL responses, XML and schemas as untrusted input (CVE Brief).
  • Patch the source libraries and remove gadgets, which is defense in depth (JFrog).

Sources