Overview
This guide provides hands-on instructions for testing each vulnerability in the Auth Security Demo. Each test includes:- Vulnerability description and severity
- Step-by-step exploitation instructions
- Expected results
- Comparison with secure implementation
Testing Environment
Before testing, ensure both applications are running:Vulnerable App
Secure App
Vulnerability #1: SQL Injection
Severity: Critical (CVSS 9.8) | CWE: CWE-89
What is SQL Injection?
SQL Injection occurs when user input is directly concatenated into SQL queries without sanitization, allowing attackers to execute arbitrary database commands.Vulnerable Code Location
vulnerable/app.py:26
Testing SQL Injection
- Method 1: Authentication Bypass
- Method 2: Comment Injection
- Method 3: UNION-based Injection
Navigate to vulnerable login
Open http://localhost:5000/login in your browser
Enter malicious payload
Use these credentials:Username:Password:
This payload closes the password string and adds a condition that’s always true.
Test on Secure Version
Try the same payloads on http://localhost:5001/login:Vulnerability #2: Cross-Site Scripting (XSS)
Severity: High (CVSS 7.5) | CWE: CWE-79
What is XSS?
XSS allows attackers to inject malicious JavaScript that executes in victims’ browsers, potentially stealing cookies, sessions, or performing actions on their behalf.Vulnerable Code Location
vulnerable/app.py:82-86
Testing XSS
- Reflected XSS
- DOM Manipulation
Test on Secure Version
Try the same payloads on http://localhost:5001/dashboard:Vulnerability #3: Insecure Direct Object Reference (IDOR)
Severity: Medium (CVSS 6.5) | CWE: CWE-639
What is IDOR?
IDOR occurs when an application exposes direct references to internal objects (like user IDs) without proper authorization checks, allowing users to access others’ data.Vulnerable Code Location
vulnerable/app.py:95-101
Testing IDOR
- Access Other Users' Profiles
- Automated Enumeration
Login as regular user
- Username:
usuario - Password:
password123
Access admin profile
Change the ID parameter:✅ Success: You can view the admin’s profile including email and role.
Test on Secure Version
Try the same on http://localhost:5001/profile:Vulnerability #4: Insecure Password Storage
Severity: Critical (CVSS 9.1) | CWE: CWE-256
What is the Issue?
Passwords stored in plain text can be immediately used if the database is compromised through SQL injection or other means.Comparing Password Storage
Testing Password Storage
Extract passwords via SQL injection
Using the SQL injection technique, extract passwords:Payload:On vulnerable app: Passwords are visible as
admin123, password123Vulnerability #5: Missing CSRF Protection
Severity: Medium (CVSS 6.5) | CWE: CWE-352
What is CSRF?
Cross-Site Request Forgery tricks authenticated users into submitting malicious requests without their knowledge.Testing CSRF
Test on vulnerable app
- Login to http://localhost:5000
- Open
csrf-attack.htmlin the same browser - The form auto-submits and creates a user
Test on secure app
Try the same attack on http://localhost:5001❌ Protected: Flask-WTF blocks the request due to missing CSRF token.Error: “400 Bad Request: The CSRF token is missing”
Testing Checklist
SQL Injection Tests
SQL Injection Tests
- Authentication bypass with
' OR '1'='1 - Comment injection with
admin' -- - UNION-based data extraction
- Error-based SQL injection
- Verify secure app blocks all attempts
XSS Tests
XSS Tests
- Basic alert payload
<script>alert('XSS')</script> - Cookie theft via
document.cookie - DOM manipulation
- Image-based XSS with
onerror - Verify secure app escapes all HTML
IDOR Tests
IDOR Tests
- Access other users’ profiles by changing ID
- Enumerate all user IDs
- Try accessing admin profile as regular user
- Verify secure app enforces authorization
Password Storage Tests
Password Storage Tests
- Extract passwords via SQL injection
- Inspect database directly
- Verify vulnerable app stores plain text
- Verify secure app uses bcrypt hashes
CSRF Tests
CSRF Tests
- Create malicious form
- Test auto-submission on vulnerable app
- Verify secure app requires CSRF token
Impact Summary
| Vulnerability | Vulnerable App | Secure App | Impact |
|---|---|---|---|
| SQL Injection | ✅ Exploitable | ❌ Protected | Full database access |
| XSS | ✅ Exploitable | ❌ Protected | Session theft, defacement |
| IDOR | ✅ Exploitable | ❌ Protected | Unauthorized data access |
| Plain Text Passwords | ✅ Present | ❌ Hashed | Credential compromise |
| CSRF | ✅ Exploitable | ❌ Protected | Unauthorized actions |
Next Steps
Troubleshooting
Fix issues encountered during testing
Vulnerability Details
Learn more about each vulnerability