A collection of security engineering examples and demonstrations for OWASP Top 10 vulnerabilities.
This module demonstrates SQL injection vulnerabilities and mitigations using a FastAPI login demo.
A05_injection/app.py- FastAPI app with both vulnerable and fixed login flowsA05_injection/setup_db.py- SQLite database setup scriptA05_injection/users.db- Local demo database
- Install dependencies:
python -m pip install "fastapi[standard]"- Initialize the database:
python A05_injection/setup_db.py- Run the application:
cd A05_injection
uvicorn app:app --reload- Open:
http://127.0.0.1:8000
/vulnerable- intentionally vulnerable SQL query built with string concatenation/fixed- protected SQL query using parameterized statements
admin / admin123user / passwordtest / test123
Use this payload in the vulnerable login form to demonstrate bypass behavior:
- Username:
' OR '1'='1 - Password:
anything
Expected result:
/vulnerablemay allow bypass/fixedrejects the payload