Lion Cipher Lab

Prevent SQL injection with parameterized queries (hands-on)

Why it matters

In Part 1 you learned, on paper, why gluing user input into a SQL command is dangerous and why parameterized queries make it impossible. Reading that is not the same as believing it in your gut. This lab closes that gap: you build a small, deliberately vulnerable login program on your own machine, type the classic ' OR '1'='1 into it, and watch it hand back every account in the database — then you change a single line to a parameterized query, feed it the exact same input, and watch the attack simply stop working. That before-and-after, run with your own hands on your own toy app, is what…

What you'll learn

Steps in this lab

  1. From Part 1's paper to your own keyboard
  2. Set up: confirm Python works and make a folder
  3. Build the toy database (three fake users)
  4. Write the VULNERABLE login (the bug, on purpose)
  5. Prove the injection works (watch it dump every user)
  6. Fix it: one line becomes a parameterized query
  7. Re-test: confirm the injection is dead
  8. The one spot ? cannot cover: allow-list the rest
  9. What you did — and the reflex to keep

Open the full interactive lab →