
Demonstrates CVE-2023-27524 Broken Object Level Authorization (BOLA) vulnerability with vulnerable and fixed Flask API implementations for security education.
# π Broken Object Level Authorization (BOLA) Demonstration
## CVE-2023-27524 Security Analysis & Fix
---
## π Project Overview
This project demonstrates a real-world **Broken Object Level Authorization (BOLA)** vulnerability and its secure remediation using a Flask-based API.
The vulnerability is modeled after **CVE-2023-27524**, which involves improper authorization controls that allow attackers to access or manipulate unauthorized objects by modifying object identifiers (IDs) in API requests.
This repository includes:
- β vulnerable_api.py: A vulnerable version of the API
- β
fixed_vulnerable_api.py: A secure fixed version implementing proper object-level authorization
---
## β οΈ What is BOLA?
**Broken Object Level Authorization (BOLA)** occurs when an application:
- Exposes object IDs (e.g., `/profile?id=2`)
- Fails to verify whether the authenticated user is authorized to access that object
### π΄ Impact:
Attackers can:
- Access other users' private data
- Modify or delete unauthorized resources
- Perform horizontal privilege escalation
---
## π₯ Vulnerable Implementation
### Example (Vulnerable Code)
```python
@app.route('/profile')
def profile():
user_id = request.args.get("id")
return users.get(int(user_id))
/profile?id=1 β Alice data
/profile?id=2 β Bob data (unauthorized access)
@app.route('/profile')
def profile():
requested_id = int(request.args.get("id", session["user_id"]))
# Object-level authorization check
if requested_id != session["user_id"]:
return "403 Forbidden - Access Denied", 403
return users.get(requested_id)
This implementation prevents BOLA by enforcing:
β Session-based authentication β Object ownership validation β Server-side authorization checks β Prevention of ID tampering attacks
Never trust user-supplied object identifiers without verifying authorization on the server side.
Authentication is NOT enough β authorization must be enforced at the object level.
User β API Request (/profile?id=2) β Direct DB Access β Data Leak
User β API Request β Session Check β Ownership Validation β Allowed/Denied
pip install flask
python fixed_vulnerable_api.py or vulnerable_api.py
http://127.0.0.1:5000
api-bola-demo/
β
βββ vulnerable_api.py # insecure version
βββ fixed_vulnerable_api.py # Fixed BOLA version
βββ README.md