Get Started
Protect your app and website

Mission 4 of 10

Close the four classic input bugs for good.

Every one of these bugs is a user's value being treated as code. You'll see each attack once against a lab app on your own machine, then apply the one change that closes it.

75 minIntermediateFreeStep 1 free

What you'll do

Break a local lab app

See SQL injection, XSS, SSRF and path traversal work against a deliberately broken app that only runs on your machine.

Apply the fix for each

Parameterise, encode, allowlist and contain, then confirm each attack no longer works.

Add database safety nets

Use Row Level Security and least-privilege roles so a bug you miss still can't read another user's rows.

  • One validation layer that rejects malformed input
  • Safe file-upload rules
Before you start
  • Python 3.11+ and uv, and curl
  • Having done the attacks overview helps but isn't required
  • A browser, to see the XSS fire and then not fire
  • Optional: a Postgres database (local or Supabase) for the RLS section. The code reads fine without one
Your progress0/6
01/06Stand up the lab, and the one idea behind every bug here0 done
STEP 01 of 06~8 min

Stand up the lab, and the one idea behind every bug here

You'll run deliberately broken endpoints on your own machine. First, the sentence that explains all four.

The one idea

Every bug in this mission comes down to one idea, so it's worth having it clear before you touch any code.

A program has a boundary between code and data, and every bug in this mission is a value crossing from the data side to the code side.

A string becomes part of a SQL statement. A comment becomes part of the HTML. A link becomes a request your server makes. A filename becomes a path your server opens.

The fix is always the same shape: keep the value on the data side. Parameterise, encode, allowlist, contain.

Set up the lab

Now the lab itself. It's a local FastAPI app with a handful of endpoints, a throwaway SQLite database, and a files folder.

Nothing listens beyond your machine and nothing here touches the internet except one SSRF demo you point at your own ports.

  1. Create the project folder, set it up with uv and add the packages the lab needs:

    Terminal
    mkdir input-lab; cd input-lab
    uv init --bare
    uv add "fastapi[standard]" httpx pydantic

    You'll build the vulnerable and the fixed version side by side as you go, one bug at a time, rather than pasting one big file.

    Each step is: see the bug, understand why, apply the fix, confirm it's closed.

  2. Start the lab app directory now and keep two terminals open, one for the server and one for curl.

    Warning
    This lab is for your machine only. The techniques here work against any site, and using them on a site you don't own is an offence under the Computer Misuse Act 1990. The whole point of a local lab is that the only system you attack is yours.
Checkpoint
uv run python -c "import fastapi, httpx, pydantic; print('ok')" prints ok, and you have an empty input-lab folder ready. That means the packages are installed.
Stuck? Ask the community
Next mission · Protect your app and websiteThreat-model your own app in 60 minutes and leave with a one-page plan
→