Lion Cipher Lab

Exploit and fix insecure deserialization (Python pickle)

Why it matters

Insecure deserialization is OWASP Top 10 A08:2025 (Software or Data Integrity Failures) and CWE-502, and it is one of the highest-impact web bugs precisely because it so rarely LOOKS dangerous. Serialization is turning an in-memory object into bytes you can store or send; deserialization is turning those bytes back into an object. It feels like plumbing. The trap is that some deserializers can also invoke code while they rebuild the object — and Python's pickle is the clearest example: it is not a data format, it is a tiny stack-based virtual machine, and an object's __reduce__ method tells…

What you'll learn

Steps in this lab

  1. What insecure deserialization is — the vocabulary and the ground rules
  2. Set up: confirm Python, make a folder, install Flask
  3. Build the VULNERABLE app (a 'remember me' cookie it trusts)
  4. Prove the code execution (a cookie that runs a command)
  5. Why pickle is dangerous by design — and why this bug is everywhere
  6. Fix it: don't deserialize untrusted data with pickle — use JSON
  7. What you did — and the reflex to keep

Open the full interactive lab →