Module lessons (4/4)
Prototype Pollution in Deep Merge
Pollute Object.prototype through recursive JSON merging, then harden deep merge helpers against prototype keys.
What you'll learn in this lesson
- Explain how JavaScript prototype-chain lookup allows
{}.isAdminto returntruewhenObject.prototypeis polluted by JSON input. - Exploit naive deep-merge utilities via
constructor.prototypegadgets even when__proto__is explicitly blocked. - Implement recursive prototype-safe merging (
Object.hasOwn+ key blocklist) and harden dot-path configuration setters against nested pollution.
Overview
In JavaScript, JSON.parse() treats "__proto__" as a normal own string key on the parsed object rather than updating its prototype. When a recursive merge or query-string parser blindly copies target[key] = source[key], every {} object in the process can suddenly inherit attacker-chosen properties!
Walk through all four stages of the bug and defense:
Sections covered in this lesson
- 11. How Recursive Merge Corrupts Every Object in Memory
- 22. Interactive Explorer: Gadget Propagation into Client Sinks
- 33. Progressive Labs: Warm-Up → Attack → Defend → Harden
- 44. Checkpoints & Code Review
Unlock "Prototype Pollution in Deep Merge" and the full Application & Web Security curriculum
Pollute Object.prototype through recursive JSON merging, then harden deep merge helpers against prototype keys.
Unlock all 6 hands-on exercises in this lesson plus every advanced WebAssembly module with automated checks.
- Instant access to all advanced modules in Application & Web Security plus 17 more courses
- Hands-on browser exercises with automated test suites and solutions
- 14-day money-back guarantee processed via Paddle.com
14-day guarantee · Cancel anytimeModule 1, all 18 interactive games, and cheatsheets are always free.