Fall 2026
  • Discord
  • Gradescope
  • Syllabus

On this page

  • Start
  • Attack and repair
  • Check and submit

Lab: Capture the Flag

Due: Wednesday, December 16 at 11:59pm (one week after it is assigned) · Worth: 5 points

A login form should treat usernames and passwords as data. In this lab you’ll investigate a login bug in a local app and fix how it passes those values to SQLite.

Start

Download and extract the starter ZIP. Open the inner lab-ctf folder in VS Code, then initialize and publish your repository as lab-ctf. Activate a Python environment, then run:

python -m pip install -r requirements.txt
python ctf_target.py

Open http://127.0.0.1:8000. Try bob with the password password and check that the login fails. This deliberately vulnerable target uses a throwaway database. Test only this local copy.

Attack and repair

Start with the password box. Enter bob as the username and ' OR '1'='1 as the password. Look at the SQL string in login in ctf_target.py and work out how your input changes its condition. Record the flag and a short explanation in answers.md.

Next, try to log in as admin by changing the username input. Don’t use the admin password from the source. A useful SQL feature here is --, which makes the rest of a line a comment. Work out where a quote would end the username value and what you would want SQL to ignore after that. Record the username you used, the flag, and why the attack worked.

Repair login in ctf_target.py by binding both credentials as parameters. SQLite should receive the SQL statement and the two input values separately. Keep the existing form, routes, and db connection so the grader can test different accounts. See parameter binding in the reading.

  • Record the guided password attack and the first flag in answers.md.

  • Find a username input that logs in as admin, and record it and the admin flag.

  • Repair login in ctf_target.py using bound parameters. Correct credentials must still log in to the right account.

  • The repaired login must reject wrong passwords, unknown users, and injection attempts without a SQL error.

Check and submit

Restart the server after editing. Repeat both injections and try a lone quote: none should log in or cause a SQL error. Then use the real credentials in the target source to confirm that legitimate logins still work, and a wrong password to confirm that it is rejected.

Commit and sync ctf_target.py and answers.md. On Gradescope, choose GitHub and submit lab-ctf and the branch containing your work. The submission guide explains resubmission.