Lion Cipher Lab

Exploit and fix server-side prototype pollution to RCE in a Node.js app

Why it matters

Server-side prototype pollution is the JavaScript-ecosystem bug that most often turns 'we merged some JSON' into 'an attacker runs commands as our Node process.' In JavaScript almost every object inherits from ONE shared object, Object.prototype: read a property an object does not have and the language walks its PROTOTYPE CHAIN -- a series of fallback objects -- until it finds the property or reaches Object.prototype at the top. The vulnerability (MITRE files it as CWE-1321) appears when untrusted input can reach the special keys __proto__ or constructor.prototype during an object operation,…

What you'll learn

Steps in this lab

  1. The vocabulary of SSPP -- prototype, __proto__, sink, gadget, in one breath
  2. Set up: Node.js, a clean folder, and Express
  3. Build the VULNERABLE app -- an unsafe merge, plus a gadget that spawns a worker
  4. The first named failure mode: JSON.parse is NOT the sink -- the merge is
  5. DETECT the pollution BLIND -- no value reflected, but behavior changes
  6. Find the GADGET and reach RCE -- NODE_OPTIONS=--require
  7. The second named failure mode: a gadget is environment-specific
  8. The third named failure mode: the '__proto__' string blocklist is bypassable
  9. FIX it at the ROOT, then re-test the exact same attacks
  10. What you did -- and the reflex to keep

Open the full interactive lab →