Overview
The Auth Security Demo consists of two separate Flask applications that demonstrate the contrast between vulnerable and secure coding practices:- Vulnerable App: Port 5000 - Demonstrates common security flaws
- Secure App: Port 5001 - Implements security best practices
Starting the Applications
- Development Mode
- Production Mode (Gunicorn)
- Background Mode
Start the vulnerable application
Open a terminal and run:Expected output:
The vulnerable app runs on port 5000 with debug mode disabled for realistic testing.
Start the secure application
Open a new terminal (keep the first one running) and run:Expected output:
The secure app runs on port 5001 to avoid conflicts.
Accessing the Applications
Vulnerable Application
Local Access:Default Credentials:
- Admin:
admin/admin123 - User:
usuario/password123
Secure Application
Local Access:Default Credentials:
- Admin:
admin/admin123 - User:
usuario/password123
Application Features
Both applications include the same features to allow direct comparison:Authentication System
Authentication System
- Login Page (
/login): User authentication - Register Page (
/register): New user registration - Logout (
/logout): Session termination
| Username | Password | Role |
|---|---|---|
| admin | admin123 | admin |
| usuario | password123 | user |
Protected Routes
Protected Routes
- Dashboard (
/dashboard): Main landing page after login - Profile (
/profile): User profile with query parameter?id=X
Database Operations
Database Operations
Both apps use SQLite with the same schema:Key Difference:
- Vulnerable: Passwords stored in plain text
- Secure: Passwords hashed with bcrypt
Configuration Details
- Vulnerable App Configuration
- Secure App Configuration
Insecure Practices:
- Hardcoded secret key
- No CSRF protection
- No security headers
- SQL injection vulnerable
- XSS vulnerable
- IDOR vulnerable
Network Access
- Localhost Only (Default)
- Restrict to Localhost
- Remote Access (Lab Only)
By default, both apps listen on
0.0.0.0, making them accessible from:http://localhost:5000(or 5001)http://127.0.0.1:5000(or 5001)http://<your-local-ip>:5000(or 5001)
Monitoring and Logs
View real-time logs
When running in development mode, logs appear in the terminal:
The vulnerable app prints SQL queries to console for educational purposes.
Check for SQL queries (vulnerable app)
The vulnerable app logs raw SQL queries:This helps you see exactly how SQL injection works.
Stopping the Applications
- Interactive Mode
- Background Processes
- Gunicorn
If running in a terminal, press:This sends a SIGINT signal to gracefully stop the Flask server.
Quick Reference
| Application | Port | URL | Purpose |
|---|---|---|---|
| Vulnerable | 5000 | http://localhost:5000 | Demonstrate vulnerabilities |
| Secure | 5001 | http://localhost:5001 | Show secure implementations |
Next Steps
Test Vulnerabilities
Learn how to exploit the vulnerable application
Troubleshooting
Fix common issues with running the apps