labs / sqli
SQL Injection Lab
Exploit a vulnerable search query and exfiltrate the admin's password.
Objective Make the user-search return the admin account's password, then submit it as the flag.
This staff tool looks up a user by exact username. It builds its query like
… WHERE username = '<your input>' — by gluing strings together. Try a normal
name first (alice), then think about what an apostrophe could do.
Executed query
How the fix works
The bug is that input changes the structure of the query. The fix is a parameterized
query: WHERE username = ? with the value bound separately, so input is always treated
as data, never as SQL. Every row you just leaked would be impossible against that.