This project is designed to:
- Generate Software Bill of Materials (SBOM) with vulnerable dependencies
- Test vulnerability scanning tools across all severity levels
- Demonstrate common security issues in Python applications
-
Remote Code Execution via Pickle (
/load_data)- Insecure deserialization allows arbitrary code execution
- CVSS: 10.0
-
Arbitrary File Upload (
/upload)- No file type or content validation
- Can lead to remote code execution
- CVSS: 9.8
-
Direct Code Execution via eval() (
/calculate)- User input passed directly to eval()
- Complete system compromise possible
- CVSS: 10.0
-
YAML Deserialization RCE (
/load_config)- Unsafe YAML loading with arbitrary code execution
- CVSS: 9.8
- Django 3.2.12 - CVE-2022-28346 (SQL Injection) - CVSS 9.8
- Pillow 8.3.2 - CVE-2022-22817 (Buffer Overflow) - CVSS 9.8
- paramiko 2.10.1 - CVE-2022-24302 (Auth bypass) - CVSS 9.8
-
SQL Injection (
/user)- Unparameterized SQL queries
- Database compromise
- CVSS: 8.8
-
XML External Entity (XXE) (
/parse_xml)- Allows reading arbitrary files
- CVSS: 8.2
-
Server-Side Request Forgery (
/fetch)- Access to internal network resources
- CVSS: 8.6
-
OS Command Injection (
/ping)- Arbitrary system command execution
- CVSS: 8.8
-
Path Traversal (
/read_file)- Read arbitrary files from filesystem
- CVSS: 7.5
-
Hardcoded Secret Key
- Session hijacking possible
- CVSS: 7.4
- Flask 2.0.0 - CVE-2023-30861 (Cookie parsing) - CVSS 7.5
- requests 2.25.0 - CVE-2023-32681 (Header leak) - CVSS 6.1
- Jinja2 2.11.3 - CVE-2024-22195 (XSS) - CVSS 6.1
- lxml 4.6.3 - CVE-2021-43818 (XXE) - CVSS 7.1
- PyYAML 5.3.1 - CVE-2020-14343 (Code execution) - CVSS 9.8
-
Cross-Site Scripting (XSS) (
/search)- Reflected XSS allows script injection
- CVSS: 6.1
-
Server-Side Template Injection (
/hello)- Can lead to information disclosure or RCE
- CVSS: 6.5
-
Missing CSRF Protection (
/transfer)- State-changing operations without tokens
- CVSS: 6.5
-
Insecure Session Management (
/login)- No secure or httponly flags
- CVSS: 5.3
-
Open Redirect (
/redirect)- Unvalidated redirects for phishing
- CVSS: 4.7
-
Debug Mode Enabled
- Exposes sensitive information
- CVSS: 5.3
-
Insecure Cookie Configuration
- Session hijacking risk
- CVSS: 5.3
- Werkzeug 2.0.0 - CVE-2023-25577 (Security bypass) - CVSS 5.3
- cryptography 3.3.1 - CVE-2023-23931 (Cipher weakness) - CVSS 6.5
- certifi 2021.5.30 - CVE-2022-23491 (Cert validation) - CVSS 6.8
-
Information Disclosure (
/divide)- Verbose error messages with stack traces
- CVSS: 3.7
-
Weak Password Requirements (
/register)- No complexity enforcement
- CVSS: 3.1
-
Missing Security Headers (
/page)- No X-Frame-Options, CSP, etc.
- CVSS: 3.1
-
Predictable Resource IDs (
/invoice/<id>)- Sequential IDs enable enumeration (IDOR)
- CVSS: 3.5
-
Verbose Server Banner (
/info)- Information disclosure
- CVSS: 2.7
-
CORS Misconfiguration
- Allows all origins
- CVSS: 3.1
- urllib3 1.26.4 - CVE-2021-33503 (ReDoS) - CVSS 5.9
- setuptools 56.0.0 - CVE-2022-40897 (ReDoS) - CVSS 5.9
-
Total Code Vulnerabilities: 24
- Critical: 4
- High: 6
- Medium: 7
- Low: 7
-
Total Dependency CVEs: 14
- Critical: 3
- High: 5
- Medium: 3
- Low: 2
Additional vulnerabilities in the authentication module:
- Hardcoded Credentials (HIGH) - Default admin credentials in code
- Weak Hashing (MEDIUM) - MD5 used for password hashing
- Insecure Deserialization (CRITICAL) - Pickle vulnerability
- Hardcoded Encryption Key (HIGH) - Static encryption key
- Insecure Random (MEDIUM) - Using random instead of secrets for tokens
- Path Traversal (HIGH) - Unsanitized file path handling
- Plaintext Password Storage (HIGH) - Passwords stored without encryption
- Timing Attack (LOW) - Direct string comparison for authentication
pip install -r requirements.txtDO NOT RUN THIS APPLICATION ON A PUBLIC NETWORK!
For testing purposes only:
python app.pyThe app will run on http://0.0.0.0:5000
POST /load_data- Pickle deserializationPOST /upload- File uploadGET /calculate?expr=1+1- Code executionPOST /load_config- YAML deserialization
GET /user?id=1- SQL injectionPOST /parse_xml- XXE injectionGET /fetch?url=http://example.com- SSRFGET /ping?host=localhost- Command injectionGET /read_file?file=readme.txt- Path traversal
GET /search?q=<script>alert(1)</script>- XSSGET /hello?name={{7*7}}- SSTIPOST /transfer- CSRFPOST /login- Insecure sessionGET /redirect?url=http://evil.com- Open redirect
GET /divide?a=10&b=0- Error disclosurePOST /register- Weak passwordsGET /page- Missing headersGET /invoice/123- IDORGET /info- Information disclosure
Generate SBOM using various tools:
# Using pip-audit
pip-audit -r requirements.txt
# Using CycloneDX
cyclonedx-py -r -i requirements.txt -o sbom.json
# Using Syft
syft dir:. -o cyclonedx-json
# Using SPDX
pip install spdx-toolsTest this application with:
# Bandit
bandit -r . -f json -o bandit_report.json
# Semgrep
semgrep --config=auto .# pip-audit
pip-audit
# Safety
safety check
# Grype
grype dir:.- OWASP ZAP
- Burp Suite
- Nikto
This code is provided for educational and testing purposes only. The vulnerabilities are intentional and should never be deployed to production environments. Use at your own risk.
This is demonstration code for security testing. No warranty provided.