Toutes les vulnérabilités
CRITICALAppSec

APPSEC-PROTOTYPE-POLLUTION

Web app · Prototype Pollution

Résumé

Prototype pollution is a JavaScript-specific flaw where attacker-controlled keys such as __proto__, constructor, or prototype reach a recursive object-merge, clone, or path-set operation that writes to Object.prototype instead of an own property, so the injected property silently appears on every object in the runtime. The code-level mechanism is an unsafe deep-merge that recurses on keys without checking for these magic names, for example assigning target[key] when key is __proto__; this enables denial of service, property injection that flips security flags, and gadget chains to remote code execution. CVE-2019-10744 (published 25 July 2019, CVSS 9.1) affected lodash before 4.17.12: its defaultsDeep could be tricked with a payload nesting constructor.prototype because the safe-get path did not block the constructor key, polluting Object.prototype globally. A related real exploit, CVE-2019-7609 in Kibana's Timelion, chained prototype pollution via __proto__ to set Node child_process options and achieve full remote code execution. Prototype pollution maps to CWE-1321.

Comment l’éviter dans votre code

  • In merge/set/clone helpers, skip keys equal to __proto__, constructor, and prototype.
  • Create data objects with Object.create(null) so they lack a prototype chain to pollute.
  • Freeze Object.prototype at startup with Object.freeze to block writes.
  • Validate parsed JSON against a strict schema and reject unexpected keys.
  • Upgrade vulnerable libraries (lodash >= 4.17.12) and prefer Map over plain objects for untrusted key/value data.

Références

Vulnérabilités liées

Tout AppSec →