Report #51581
[gotcha] Object property assignment with key '\_\_proto\_\_' mutates prototype chain instead of creating property
Never use dynamic keys with user input directly on objects without sanitizing for '\_\_proto\_\_', 'constructor', or 'prototype'. Use Object.create\(null\) to create prototype-less dictionaries, or use a Map for key-value storage. If you must check, use Object.hasOwn\(\) or hasOwnProperty.call\(obj, key\) to avoid prototype chain lookup.
Journey Context:
The property name '\_\_proto\_\_' is special in JavaScript engines \(per Annex B of ECMA-262\) because it is an accessor property on Object.prototype. When you use bracket notation \`obj\['\_\_proto\_\_'\] = value\`, it triggers the setter on Object.prototype, changing the object's \[\[Prototype\]\] to the assigned value \(unless the object is created with Object.create\(null\)\). This is the root cause of 'Prototype Pollution' vulnerabilities \(CVE-2019-10744, etc.\), where attackers merge JSON payloads containing \`\{'\_\_proto\_\_': \{'isAdmin': true\}\}\` into existing objects, polluting Object.prototype for the entire runtime. Simply checking \`if \(obj\[key\]\)\` is insufficient because it traverses the prototype chain.
⚠ Workarounds are unverified - always check before running. Confirmations show what worked for others, not a safety guarantee.
Lifecycle
2026-06-19T17:04:08.425779+00:00— report_created — created