How it works
BOLA is a missing ownership check. The server knows who the caller is, receives the ID of a record, and hands back or modifies that record without asking whether it belongs to the caller.
Almost every API call names an object. The ID may sit in the path (/shipments/88213), the query string, a JSON body, a header or a GraphQL argument. The client chooses that value, so the server has to treat it as untrusted. When a handler loads a record by ID alone, every logged-in user can reach every record just by trying other IDs.
OWASP ranks it first among API risks.
What it looks like
user_a asks for a shipment that belongs to a different account. The only thing changed from a normal request is the number at the end of the path.
GET /api/shipments/88214 HTTP/1.1
Host: api.acme.test
Authorization: Bearer <user_a token>HTTP/1.1 200 OK
Content-Type: application/json
{"id": 88214, "account": "acct_user_b", "recipient": "B. Example", "address": "12 Sample Street"}The account field shows the problem: a token for one account returned a record owned by another. The request is well formed and carries a valid token, so scanners and firewalls usually miss it.
The same mistake appears in several shapes:
- Writes. The read endpoint is protected, while
PUTorDELETEon the same path is not. - Nested objects.
/accounts/7/shipments/88214checks that you may see account 7 and never checks that the shipment is inside it. - Tenant IDs. Swapping a workspace or organization ID in a header or body opens a different customer's data.
- GraphQL. One resolver that loads any object by ID exposes that type everywhere. Introspection often lists the fields that take IDs.
How to test for it
You need two accounts that should not see each other's data. This makes BOLA testing a core part of authenticated penetration testing.
- Set up two test users,
user_aanduser_b, in separate tenants if the product has them. Give each a few records of every type. - List every request that carries an object ID, and note where the ID sits.
- Collect the IDs that belong to
user_b. - Replay
user_a's requests withuser_b's IDs. Keep the token and change only the ID. - Cover every method on each path, including update, delete and actions such as export or share.
- Compare responses. A success status with
user_b's data, or a confirmed change touser_b's record, is a finding.
Only modify records in accounts you control.
How to fix it
Make the ownership check part of the data lookup, so a record the caller may not see cannot be loaded at all.
# Vulnerable: the record is loaded by ID only.
shipment = Shipment.query.get(shipment_id)
# Fixed: the lookup is scoped to the caller's account.
shipment = Shipment.query.filter_by(
id=shipment_id,
account_id=current_user.account_id,
).first()
if shipment is None:
abort(404)Practices that make the fix stick:
- Scope in the data layer. A repository method that requires an account ID, or row-level security in the database, protects routes that a developer forgot.
- Take identity from the session. A
user_idoraccount_idin the request is attacker input. - Answer
404for records the caller may not see. A403confirms that the ID exists. - Write two-user tests. For each endpoint, assert that one user cannot fetch or change the other's record, and run the tests on every build.
Random IDs such as UUIDs make guessing harder. They are not a fix. IDs turn up in shared URLs, exported files, logs and other API responses, and the check is still missing.
BOLA, IDOR and BFLA
Insecure direct object reference (IDOR) is the older name for the same weakness, used mostly for web applications. BOLA is the name the OWASP API Security Top 10 gave it. Both map to CWE-639, and both are forms of broken access control.
Broken function level authorization is the neighbor. BOLA is about which record a user may touch. BFLA is about which operation a user may run. Reading another customer's invoice is BOLA. Calling the admin-only "delete customer" endpoint is BFLA.