Lion Cipher Lab

Exploit and fix OS command injection (in your own lab)

Why it matters

OS command injection is a flagship case of OWASP Top 10 A05:2025 (Injection) and its own weakness, CWE-78, and it is one of the highest-impact web bugs because the payoff is direct: run commands on the server as the account the app runs as. The bug appears whenever an application builds a command line out of user input and hands the whole string to a SHELL to run. A shell is the program (sh/bash on macOS/Linux, cmd on Windows) that interprets command lines — and it treats certain characters specially: ';', '|', '&', '&&', '||' and newlines chain or separate commands; '$(...)' and backticks…

What you'll learn

Steps in this lab

  1. What OS command injection is — the vocabulary and the ground rules
  2. Set up: confirm Python, make a folder, install Flask
  3. Build the VULNERABLE app (a 'ping tool' that trusts the shell)
  4. Prove the injection (a host value that runs a second command)
  5. Why blocklisting 'bad characters' is the wrong fix
  6. Fix it: stop using the shell — pass an argument array, then allowlist
  7. What you did — and the reflex to keep

Open the full interactive lab →