Lion Cipher Lab

Exploit and fix Prototype Pollution in your own Node.js app

Why it matters

Prototype pollution is the signature server-side bug of the JavaScript ecosystem, and it hides in code that looks completely ordinary. In JavaScript, almost every object inherits from ONE shared object called Object.prototype: when you read a property that an object does not have, the language walks that object's PROTOTYPE CHAIN -- a series of fallback objects -- until it finds the property or reaches the top, which is Object.prototype. That design is why {}.toString() works even though you never defined toString. The vulnerability (MITRE files it as CWE-1321) appears when untrusted input can…

What you'll learn

Steps in this lab

  1. What prototype pollution is -- the vocabulary, in one breath
  2. Set up: confirm Node.js and make a clean folder
  3. Build the VULNERABLE app (an unsafe recursive merge of untrusted JSON)
  4. PROVE pollution: a fresh {} carries a property you never gave it
  5. ESCALATE (benign): flip an auth check from 403 to admin with no password
  6. The NAIVE fix -- and watch it fail live
  7. FIX it durably, then re-test
  8. What you did -- and the reflex to keep

Open the full interactive lab →