|
| 1 | +# Educational Vulnerable Application |
| 2 | + |
| 3 | +**WARNING: This application is intentionally vulnerable and meant for educational purposes only. DO NOT deploy this in any production environment.** |
| 4 | + |
| 5 | +## Overview |
| 6 | +This application demonstrates common security vulnerabilities based on OWASP Top 10 (2021). It consists of two microservices: |
| 7 | +- Auth Service: Handles user authentication with intentional vulnerabilities |
| 8 | +- Profile Service: Manages user profile data with intentional vulnerabilities |
| 9 | + |
| 10 | +## Intentional Vulnerabilities |
| 11 | + |
| 12 | +### 1. Broken Access Control (A01:2021) |
| 13 | +- No role-based access control implementation |
| 14 | +- Direct object references without verification |
| 15 | +- Location: `auth_service/routes.py` - endpoint `/api/user/<id>` |
| 16 | + |
| 17 | +### 2. Cryptographic Failures (A02:2021) |
| 18 | +- Passwords stored with weak hashing (MD5) |
| 19 | +- Sensitive data transmitted without encryption |
| 20 | +- Location: `auth_service/utils.py` - `hash_password()` function |
| 21 | + |
| 22 | +### 3. Injection (A03:2021) |
| 23 | +- SQL injection vulnerability in login query |
| 24 | +- NoSQL injection in profile lookup |
| 25 | +- Location: `auth_service/routes.py` - `/login` endpoint |
| 26 | +- Location: `profile_service/routes.py` - `/profile` endpoint |
| 27 | + |
| 28 | +### 4. Insecure Design (A04:2021) |
| 29 | +- No rate limiting on login attempts |
| 30 | +- Password reset without verification |
| 31 | +- Location: `auth_service/routes.py` - all endpoints |
| 32 | + |
| 33 | +### 5. Security Misconfiguration (A05:2021) |
| 34 | +- Debug mode enabled |
| 35 | +- Default/weak credentials |
| 36 | +- Location: `config.py` - all configuration settings |
| 37 | + |
| 38 | +### 6. Vulnerable Components (A06:2021) |
| 39 | +- Outdated dependencies in requirements.txt |
| 40 | +- Known vulnerable versions of packages |
| 41 | + |
| 42 | +### 7. Authentication Failures (A07:2021) |
| 43 | +- Weak password requirements |
| 44 | +- Session tokens without expiry |
| 45 | +- Location: `auth_service/utils.py` - `validate_password()` function |
| 46 | + |
| 47 | +### 8. Software and Data Integrity Failures (A08:2021) |
| 48 | +- No integrity checks on uploaded files |
| 49 | +- Unsecured deserialization |
| 50 | +- Location: `profile_service/routes.py` - `/upload` endpoint |
| 51 | + |
| 52 | +### 9. Security Logging Failures (A09:2021) |
| 53 | +- No logging of security events |
| 54 | +- Sensitive data in logs |
| 55 | +- Location: Both services lack proper logging |
| 56 | + |
| 57 | +### 10. Server-Side Request Forgery (A10:2021) |
| 58 | +- Unvalidated URL inputs |
| 59 | +- Location: `profile_service/routes.py` - `/fetch-avatar` endpoint |
| 60 | + |
| 61 | +## Setup Instructions |
| 62 | + |
| 63 | +1. Create virtual environment: |
| 64 | +```bash |
| 65 | +python -m venv venv |
| 66 | +source venv/bin/activate # Linux/Mac |
| 67 | +venv\Scripts\activate # Windows |
| 68 | +``` |
| 69 | + |
| 70 | +2. Install dependencies: |
| 71 | +```bash |
| 72 | +pip install -r requirements.txt |
| 73 | +``` |
| 74 | + |
| 75 | +3. Set up MongoDB: |
| 76 | + - Use local MongoDB instance or |
| 77 | + - Create free MongoDB Atlas cluster |
| 78 | + |
| 79 | +4. Configure environment: |
| 80 | +```bash |
| 81 | +cp .env.example .env |
| 82 | +# Edit .env with your MongoDB URI |
| 83 | +``` |
| 84 | + |
| 85 | +5. Run services: |
| 86 | +```bash |
| 87 | +# Terminal 1 |
| 88 | +python auth_service/app.py |
| 89 | + |
| 90 | +# Terminal 2 |
| 91 | +python profile_service/app.py |
| 92 | +``` |
| 93 | + |
| 94 | +## Testing Vulnerabilities |
| 95 | + |
| 96 | +1. SQL Injection: |
| 97 | +``` |
| 98 | +Username: admin' OR '1'='1 |
| 99 | +Password: anything |
| 100 | +``` |
| 101 | + |
| 102 | +2. NoSQL Injection: |
| 103 | +```javascript |
| 104 | +{"$gt": ""} in username field |
| 105 | +``` |
| 106 | + |
| 107 | +3. Weak Passwords: |
| 108 | +``` |
| 109 | +Any password with length > 1 is accepted |
| 110 | +``` |
| 111 | + |
| 112 | +4. SSRF Test: |
| 113 | +``` |
| 114 | +/fetch-avatar?url=file:///etc/passwd |
| 115 | +``` |
| 116 | + |
| 117 | +## Automated Testing |
| 118 | +Run security scanners against http://localhost:5000 and http://localhost:5001 to detect vulnerabilities. |
| 119 | + |
| 120 | +## Disclaimer |
| 121 | +This application is for educational purposes only. It contains intentional security vulnerabilities to demonstrate common security issues. DO NOT use any of this code in production environments. |
0 commit comments