Blog / A03:2021 Injection
A03:2021 · Injection

A language tag named __proto__ poisons the object you return

Parsed credential data used a caller-controlled language label as an object key. Set that label to __proto__ with an object value and you change the prototype of the record you hand downstream.

untrusted JSON isparsedan item'slanguage…key set to__proto__ with…the map'sprototype…polluted objectreturned…ATTACKER INPUTIMPACTcode path executes
Attack path · untrusted JSON is parsed → an item's language field becomes a key → key set to __proto__ with an object value → the map's prototype is changed → polluted object returned downstream

Parsed credential data used a caller-controlled language label as an object key. Set that label to __proto__ with an object value and you change the prototype of the record you hand downstream.

What goes wrong

The routine walks a list of localized values and builds a lookup keyed by each item's language field. The language string comes straight from the parsed input, and it is used as a property name with no checking. That is the whole bug.

Set the language to __proto__, give the item an object value, and the assignment does not create a normal entry. It walks into the special prototype setter and reparents the lookup object. Every property read on that object afterward can resolve through the attacker's injected prototype, so downstream code that trusts the returned credential reads values the attacker planted.

When a key comes from outside, it is data, not a field name. Build the map with a null prototype, or reject the reserved names before you assign.

The pattern

Vulnerable
function buildLangMap(items) {
  const map = {};
  for (const item of items) {
    map[item.language] = item.value;   // language is attacker data
  }
  return map;
}
Hardened
function buildLangMap(items) {
  const map = Object.create(null);      // no prototype to poison
  for (const item of items) {
    if (typeof item.language !== "string") continue;
    if (item.language === "__proto__") continue;
    map[item.language] = item.value;
  }
  return map;
}
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

This object gets returned and trusted by whatever consumes the credential. If any later check reads a property the injected prototype now supplies, the attacker has seeded a value into a place that skipped validation. Prototype pollution rarely crashes anything, which is why it survives long enough to do damage.

Check your own code