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
function translate(entries) {
const out = {};
for (const [key, value] of entries) {
out[key] = translateValue(value); // key may be __proto__
}
return out;
}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 readsGrounding 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.
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
- Trace whether any object built from untrusted keys reaches an authorization or validation path.
- Use null-prototype targets for translation and copy loops over external keys.
- In security checks, read with Object.hasOwn rather than bare property access.