Privilege Escalation and Trust Boundaries

CWE-266, CWE-269, CWE-286, CWE-501, CWE-602

Real-World Attack Scenarios

Scenario 1: Horizontal Privilege Escalation - User Enumeration

An API endpoint allows viewing user profiles by ID:

GET /api/user/123 → Returns user 123's profile
GET /api/user/124 → Returns user 124's profile

The vulnerability:

No authorization check - any user can access any profile by changing the ID.

The attack:

# Enumerate all users
for i in {1..1000}; do
  curl -H "Authorization: Bearer mytoken" http://example.com/api/user/$i
done

# Collect all user data:
# - Email addresses
# - Phone numbers
# - Physical addresses
# - Payment information
# - Personal information

Result:

  • Complete user database disclosure

  • Privacy violation

  • GDPR/CCPA breach

Finding it: Change IDs in requests. Test if you can access other users' data without authentication.


Scenario 2: Vertical Privilege Escalation - Role Change

An admin panel allows modifying user roles without proper authorization:

The vulnerability:

No authorization check - any authenticated user can promote themselves to admin.

The attack:

Result:

  • Admin access achieved

  • Complete system control

  • Can modify any data, delete accounts, access secrets

Finding it: Look for user/role modification endpoints. Try changing your own role. Check if authorization checked.


Scenario 3: Trust Boundary Violation - Hidden Parameter

An order form has a hidden price field:

The vulnerability:

Application trusts hidden fields without re-validation:

The attack:

Attacker modifies hidden fields in browser:

Or intercepts request with Burp Suite and modifies:

Result:

  • Products purchased for penny

  • Massive financial loss

  • Fraud

Finding it: Intercept POST requests. Modify prices, quantities, discounts. Check if values re-validated server-side.


Scenario 4: Improper Privilege Management - Missing Authorization Check

A resource deletion endpoint doesn't check ownership:

The vulnerability:

No authorization check - any authenticated user can delete any document.

The attack:

Result:

  • Document loss

  • Denial of service

  • Data destruction

Finding it: Find resource deletion endpoints. Try deleting resources belonging to other users.


Scenario 5: Client-Side Security Enforcement Only

A page has admin buttons that are hidden from regular users:

The vulnerability:

Authorization only checked on client - server doesn't validate role.

The attack:

Attacker:

  1. Opens browser console

  2. Removes the if condition

  3. Shows admin button

  4. Clicks it

  5. Browser makes request to admin endpoint

Server doesn't check authorization and processes the request.

Result:

  • Admin actions performed by non-admin

  • Unauthorized data modification

  • System compromise

Finding it: Check if admin features hidden with CSS/JavaScript. Test if backend endpoint checks authorization. Use Burp Suite to craft admin requests.


Scenario 6: Incorrect User Management - Account Takeover

A password reset function uses predictable tokens:

The vulnerability:

Reset tokens are predictable and reusable for any user:

  • User 1: token = md5(1)

  • User 2: token = md5(2)

  • Attacker can calculate tokens for any user

The attack:

Result:

  • Takeover of all accounts

  • Complete system compromise

Finding it: Request password reset. Check if token is randomness. Try using token for multiple users.


How to Identify Access Control Issues During Testing

1. Test horizontal privilege escalation

Change IDs/usernames in requests:

Try accessing other users' data.

2. Test vertical privilege escalation

Look for admin features. Try accessing them as non-admin:

Try modifying your own role/privileges.

3. Test trust boundaries

Intercept requests. Modify:

  • Prices

  • Quantities

  • User IDs

  • Roles

  • Permissions

Check if server re-validates.

4. Test authorization checks

For each endpoint:

  • Is authorization checked?

  • Does it check ownership?

  • Can you access other users' resources?

  • Can you escalate privileges?

5. Check client-side enforcement

Look for:

  • JavaScript hiding features

  • CSS displaying/hiding buttons

  • Client-side role checks

  • Try removing client-side restrictions

6. Test with different roles

Log in as:

  • Admin

  • Regular user

  • Guest

Try accessing same resource with each role.


Mitigation Strategies

Always check authorization on server

Validate resource ownership

Never trust client input for authorization

Re-validate sensitive parameters

Use proper authorization models

  • Role-based access control (RBAC)

  • Attribute-based access control (ABAC)

  • Access control lists (ACL)

Enforce least privilege

  • Give users minimum permissions needed

  • Disable unnecessary features

  • Restrict API access

  • Limit data exposure


Last updated