Prototype Pollution Gadgets

Code that reads a property the program never set, inherits an attacker-polluted value from Object.prototype, and passes it to a dangerous sink. A gadget is the half of a prototype-pollution chain that produces the impact.

How it works

A gadget needs three things:

  1. An object created without that property. Usually a plain {} options, env or config object.
  2. A lookup that walks the prototype chain. obj.x, obj[key], for...in, or the in operator.
  3. A sink that uses the result. Process spawn, code generation, an HTTP request, HTML output, or a DB query.

The vulnerable library does not create the pollution. It only consumes it. Without a separate pollution source in the same runtime, the gadget does nothing, and without the gadget the pollution has no effect. JFrog’s lodash → Axios chain shows this split (JFrog). The concept mirrors deserialization Gadget Chains: existing code is reused, and impact depends on what is loaded.

Techniques / payloads

Gadgets by sink class (described conceptually, not as working chains):

SinkGadgetPolluted key / mechanism
Process envsimple-git .env() allocates {}. Node copies inherited keys into the child env, and git runs GIT_SSH_COMMAND for SSH-style URLs (n8n Git node)GIT_SSH_COMMAND ([[raw/simonkoeck.com/cve-2026-33696-from-a-schema-name-to-rce-in-n8n-11422
Process optionsNode’s spawn no longer honors polluted options, so a gadget must be app or library code that builds a plain options object and passes it to spawn (@n8n/node-cli). stdio was not controllable, which pushed the chain to GIT_SSH_COMMAND([[raw/dexpose.io/n8n-from-parsing-bug-to-remote-code-execution-aka-cve-2026-42231-7582
Template compiler (AST injection)Handlebars: polluted AST-shaped values pass the parser and reach the compiler, which emits them into the generated template function. Pug: Object.prototype.block is walked when a While node lacks its own blockpendingContent (detection), type/body, block ([[raw/po6ix.github.io/ast-injection-prototype-pollution-to-rce-in-handlebars-4131
Code generationprotobuf.js resolves type names by plain property lookup, so a polluted value makes an attacker string look like a primitive type and it is compiled into a Function() encoder or decoder (CVE-2026-44291, CVSS 8.1)type-name keys ([[raw/thehackernews.com/six-proto6-vulnerabilities-in-protobuf-js-expose-node-js-apps-to-rce-a-8856
HTTP client: proxyAxios takes proxy from the merged config, which leads to all traffic and credentials passing through the attacker (CVE-2026-44494)proxy ([[raw/jfrog.com/where-severity-scores-go-wrong-just-add-prototype-pollution-10035
HTTP client: headersAxios merges inherited header keys and writes them unsanitized (CWE-113). CRLF in the value smuggles a second request, such as an IMDSv2 token PUTarbitrary header name ([[raw/github.com/axios-unrestricted-cloud-metadata-exfiltration-via-header-injection-ch-4787
ORM / for...inTypeORM buildWhere iterates inherited keys and throws EntityPropertyNotFoundError on every query, which is a DoSany key ([[raw/simonkoeck.com/cve-2026-33696-from-a-schema-name-to-rce-in-n8n-11422
String coercionOverriding Object.prototype.toString so that coercion returns attacker-chosen code (Shopify Return Magic Handlebars RCE)toString ([[raw/mahmoudsec.blogspot.com/handlebars-template-injection-and-rce-in-shopify-app-4132
Sanitizer / router (client)DOMPurify CVE-2024-48910 and React Router CVE-2026-42211 consume inherited config. Piscina CVE-2026-55388 is a server-side worker-pool equivalent([[raw/jfrog.com/where-severity-scores-go-wrong-just-add-prototype-pollution-10035

Finding gadgets.

  • Black box. Pollute a candidate key with a marker, then look for the marker in output. pendingContent appearing in Handlebars output is one example (po6ix). In Burp, use the Prototype Pollution Gadgets Finder BApp (BApp Store).
  • White box. Find {} objects whose optional fields reach spawn/exec, Function/eval, template compilation, http.request options, or innerHTML.

Notable cases

  • Axios 2026. Ten gadget CVEs (CVE-2026-42033/35/41/42/44/264, -44489/90/94/95) received GitHub/NVD ratings from low to critical. JFrog rates most of them low or medium, because each needs pre-existing pollution and the app must not set the property itself (JFrog). The separate header-injection advisory GHSA-fvcv-3m26-pcqx claimed CVSS 9.9 and RCE or cloud compromise for all v0.x–1.x versions (GHSA).
  • protobuf.js “Proto6”. Six CVEs. The root cause is that schemas and metadata are trusted by default. Fixed in 7.5.6 and 8.0.2, and protobufjs-cli 1.2.1 and 2.0.2 (THN).
  • Handlebars and Pug AST injection. The demo used the unpatched flat module as the pollution source (po6ix). See JavaScript Template Engine SSTI.
  • n8n. The same GIT_SSH_COMMAND gadget was reused across two separate pollution sources (XML node and GSuiteAdmin) (Koeck, dexpose).

Defenses

  • Create option, env and header objects with Object.create(null), or copy only own properties. Validate header values for CRLF (GHSA-fvcv-3m26-pcqx).
  • Never feed schema- or config-derived strings into Function() without strict allow-lists (THN Proto6).
  • Keep template engines patched against their own pollution advisories, such as Handlebars GHSA-2cf5-4w76-r9qv (Xygeni).
  • Triage gadget CVEs in context. Ask whether a pollution source exists in the same process, and whether the app sets the property itself (JFrog). Programs often cap a standalone gadget, as covered in Vulnerability Chaining.

Sources