← All lessons Stage 4 · Lesson 2
20 min

BOLA — the number one API bug

Stage 4 · Lesson 2 · 20 minutes · Requires Lesson 1


The one-line answer

Broken Object Level Authorization (BOLA) is when an API returns or changes an object — an order, a profile, a document — for anyone who asks with its ID, without checking that the caller is allowed to access that object.

The boundary: never "just try" the next ID on a real API. It's unauthorised access and, with personal data, a DPDP Act problem. Use two accounts you control, on labs only.


Why you should care

BOLA is API1 — the top entry — in the OWASP API Security Top 10. It's common, easy to exploit, and often exposes large amounts of personal data in one go, because APIs are built to return data efficiently.

If you did Stage 3 Lesson 4, you already know this bug: BOLA is IDOR's API sibling. Same mistake, different setting.


How it actually works

The bug

A food-delivery app's front-end loads your order:

GET /api/v2/orders/88213 HTTP/2
Authorization: Bearer <your token>

The API checks the token is valid (you're authenticated), then fetches order 88213 and returns it. It never asks whether order 88213 is yours (authorisation). Change the ID to 88212 and you get a stranger's name, phone number and home address.

Why APIs make it worse

Compared to a classic web page:

  • IDs are everywhere. Almost every endpoint takes one: /users/{id}, /orders/{id}, /invoices/{id}/pdf, /chats/{id}/messages.
  • Responses carry more data. An API often returns the full object as JSON — sometimes far more than the app shows.
  • Many clients. The web app might check ownership, while the mobile app's endpoint doesn't. The API is only as strong as its weakest endpoint.
  • Easy to automate. Structured requests and responses make it trivial to loop through IDs (Stage 2 Lesson 2) — which is why rate limits matter (Lesson 5).

Where object IDs appear in APIs

LocationExample
PathGET /api/users/1043/addresses
Query stringGET /api/invoice?id=7781
JSON body{"order_id": 88213, "action": "cancel"}
HeadersX-User-Id: 1043
Nested objects{"shipment": {"order": 88213}}

Check them all — including IDs inside requests that change data (PUT, PATCH, DELETE), not just reads.

BOLA vs BFLA

A related bug you'll see in the OWASP list:

  • BOLA — you can access another user's object with a function you're allowed to use (viewing orders).
  • BFLA (Broken Function Level Authorization) — you can use a function you shouldn't have at all, e.g. a normal user calling DELETE /api/admin/users/1043.

Both are failures of the same rule: check permissions on the server for every request.

Testing method (authorised targets)

The same two-account approach as Stage 3 Lesson 4:

  1. User A creates or owns an object. Note its ID.
  2. User B sends a request for that ID — with User B's token.
  3. Try every method the endpoint supports: GET, PUT/PATCH, DELETE.
  4. If User B can read or modify User A's object, it's BOLA.

Tip: in Burp, Repeater tabs for User A and User B side by side make the comparison clear. Swap only the ID — change one thing (Stage 2 Lesson 2).


See it yourself

  1. Read the OWASP API Top 10 entry for API1: BOLA (link below).
  2. On PortSwigger, do the access control apprentice labs involving a user ID controlled by a request parameter — the same bug, applied through a request you control.
  3. In OWASP Juice Shop on your own machine, create two accounts. As account B, try to view account A's basket by changing the basket ID in the API request. (This is one of Juice Shop's intended challenges.)
  4. Write down which endpoint, which ID location, and which check was missing.

How attackers abuse this

Attackers sign up for a normal account, capture the app's API calls (often from the mobile app), find an endpoint with an ID, and loop through IDs to download everyone's data. Real-world incidents of this kind have exposed millions of customer records — names, phone numbers, addresses, ID documents — through a single unprotected endpoint.

The defensive fix:

  • Check object-level authorisation in every endpoint that takes an ID, for every method. The question is always: is the authenticated caller allowed this action on this specific object?
  • Derive ownership from the token, not the request. Use the user identity from the verified token (or session) — never a user_id the client sends.
  • Query through the user: SELECT ... FROM orders WHERE id = ? AND owner_id = ? with the caller's ID.
  • Centralise the policy (authorisation middleware or a policy library) so new endpoints get it by default.
  • Random IDs (UUIDs) as an extra layer, not the fix.
  • Automated tests with two users trying each other's objects, for every endpoint.
  • Monitor and rate-limit: one account requesting many different object IDs quickly is a strong signal (Lesson 5, Stage 5).

Common mistakes

  • Checking only that the token is valid. That's authentication. You need authorisation per object.
  • Trusting a user_id in the request body or header. The client wrote it.
  • Protecting GET but not PUT/DELETE.
  • Checking in one client's endpoint, not another's (web vs mobile API).
  • Testing with real users' IDs. Always your own two accounts.

Check yourself

  1. What's the difference between BOLA and IDOR?
  2. An API takes {"user_id": 1043} in the body to decide whose profile to update. What's wrong, and what should it use instead?
  3. What's the difference between BOLA and BFLA?
Answers
  1. Essentially none in root cause — both are missing per-object authorisation. BOLA is the name used for APIs (OWASP API Top 10); IDOR is the classic web name.
  2. The client controls user_id, so anyone can update anyone's profile. The API should take the user's identity from the verified token or session and check permission on the server.
  3. BOLA: accessing another user's object through a function you're allowed to use. BFLA: using a function (often admin-only) you shouldn't be able to call at all.

Your lab

  • OWASP API Security Top 10 (read API1 BOLA and API5 BFLA): https://owasp.org/API-Security/
  • PortSwigger Access control labs: https://portswigger.net/web-security/access-control
  • OWASP Juice Shop on your own machine — the basket access challenge.

Writeup: the endpoint, ID location, two-account proof, and the exact server-side check.


Summary in your language

தமிழில் சுருக்கம்

BOLA என்பது ஒரு API, ID கொடுத்தால் யாருக்கும் ஒரு பொருளை (order, profile, document) கொடுப்பது அல்லது மாற்றுவது — அழைப்பவருக்கு அந்தக் குறிப்பிட்ட பொருளின் மீது அனுமதி உள்ளதா என்று சரிபார்க்காமல். இது OWASP API Top 10-இல் முதலிடம்; IDOR-இன் API வடிவம். APIs-இல் ID-கள் எல்லா இடங்களிலும் உள்ளன, response-கள் அதிகத் தரவைக் கொண்டுள்ளன. தீர்வு: ஒவ்வொரு endpoint-இலும், ஒவ்வொரு method-க்கும் பொருள்-நிலை அனுமதிச் சரிபார்ப்பு; பயனர் அடையாளத்தை token-இலிருந்து எடுங்கள், request-இலிருந்து அல்ல.

हिंदी में सारांश

BOLA तब होता है जब API, ID देने पर किसी को भी object (order, profile, document) दे देती है या बदलने देती है — बिना जाँचे कि caller को उस खास object की अनुमति है या नहीं। यह OWASP API Top 10 में पहले नंबर पर है; यह IDOR का API रूप है। APIs में IDs हर जगह होते हैं और responses में ज़्यादा data होता है। इलाज: हर endpoint पर, हर method के लिए object-level authorisation check; user की पहचान token से लें, request से नहीं।

Want this summary in Malayalam, Telugu, Kannada or another language? Tell us — the most requested languages get added next.


What's next

What if the API trusts not just your IDs, but every field you send? Mass assignment and over-posting