Blog / A03:2021 Injection
A03:2021 · Injection

One field name is all it takes to reparent a credential object

A credential's per-language value used the language name as a key on a plain object. A crafted item sets the prototype instead, and the tampered object rides along in the processed credential.

credential arrayitem supplies…name used as akey on a…the specialsetter…attacker controlsthe prototypetampered objectflows into…ATTACKER INPUTIMPACTcode path executes
Attack path · credential array item supplies a language name → name used as a key on a plain object → the special setter reparents the object → attacker controls the prototype → tampered object flows into the output

A credential's per-language value used the language name as a key on a plain object. A crafted item sets the prototype instead, and the tampered object rides along in the processed credential.

What goes wrong

A credential can carry several localized values, each tagged with a language. The code turns that into an object by assigning value under a key equal to the language string. The language is whatever the input said it was.

When the language is a reserved name and the value is an object, the assignment stops behaving like storing data. It invokes the prototype setter and gives the resulting object an attacker-chosen prototype. That object then continues on as part of the processed credential, carrying inherited properties nobody put there deliberately.

The root issue is treating external strings as safe property names. A plain object inherits from Object.prototype, and a few of its inherited names are load-bearing. Either strip the prototype from the target, or refuse the reserved keys before assigning.

The pattern

Vulnerable
const result = {};
for (const item of subject.values) {
  // item.language is untrusted
  result[item.language] = item.value;
}
return result;
Hardened
const result = Object.create(null);
const RESERVED = ["__proto__", "constructor", "prototype"];
for (const item of subject.values) {
  if (RESERVED.includes(item.language)) continue;
  result[item.language] = item.value;
}
return result;
How the pipeline adjudicated itPROVEN
ABCDEFGH

Every gate held. The exploit path was reproduced against a negative control, the impact was calibrated, and the finding was signed report-ready.

Ed25519 · per-tenant signing key · gate ledger A–H · verify offline against the published payload hash

Why it matters to you

The polluted object does not stay local. It is returned as part of the credential and handed to code that assumes a clean object with predictable properties. An inherited property can flip a truthiness check, satisfy a lookup that should have missed, or feed a wrong value into a decision that gates access. Small input, wide reach.

Check your own code