Blog / A03:2021 Injection
A03:2021 · Injection

Prototype pollution that reaches your authorization checks

A translation step copied map keys onto a plain object. A __proto__ key with an object value reparents the result, and downstream code reads inherited fields when it decides who gets in.

untrusted keysenter…keys copied ontoa plain objecta __proto__ keyreparents…inheritedproperties…an access checkreads the…ATTACKER INPUTIMPACTcode path executes
Attack path · untrusted keys enter a translation step → keys copied onto a plain object → a __proto__ key reparents the object → inherited properties appear on the result → an access check reads the planted value

A translation step copied map keys onto a plain object. A __proto__ key with an object value reparents the result, and downstream code reads inherited fields when it decides who gets in.

What goes wrong

The function translates a map or object into a fresh object by copying each key across. One of those keys can be __proto__, and its value can be an object. When that pair is assigned, the fresh object's prototype changes to the attacker's object.

This one is rated higher than the usual prototype-pollution finding for a reason. The output feeds consumers that make authorization and validation decisions, and those consumers read properties without distinguishing own from inherited. An attacker who plants a property on the prototype can make a check see a field that was never legitimately set. A role that should be absent appears present. A flag that should be false reads true.

Copy loops over untrusted keys are where this lives. Filter the dangerous names, or build the target with no prototype so there is nothing to poison and no inherited property to confuse the reader.

The pattern

Vulnerable
function translate(entries) {
  const out = {};
  for (const [key, value] of entries) {
    out[key] = translateValue(value);   // key may be __proto__
  }
  return out;
}
Hardened
function translate(entries) {
  const out = Object.create(null);
  for (const [key, value] of entries) {
    if (key === "__proto__" || key === "constructor") continue;
    out[key] = translateValue(value);
  }
  return out;
}
// consumers: use Object.hasOwn(obj, field) for security reads
How the pipeline adjudicated itHELD
ABCDEFGH

Grounding and reachability were confirmed. The exploit-path gate would not conclude without the calling code, so the finding was held and an evidence request was raised instead of being reported as fact.

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

Why it matters to you

When polluted data can reach an access decision, the severity stops being theoretical. The gap between an object with a weird prototype and an unauthorized request that looks authorized is one careless property read, and most codebases have plenty of those. Fix it at the source object, and harden the readers that gate access.

Check your own code