Choose a theme

BOLA: The Top Risk in API Security

An application may verify who a user is without checking whether the requested data belongs to them. That gap is BOLA, and it ranks first on the OWASP API Security Top 10.

  • API
  • Authorization
  • Bug Bounty

Overview

Most applications check one thing: is the user logged in? That is authentication. The more important question is whether the requested object belongs to that user. That is authorization.

When this second check is missing, changing a number in a URL is enough to access another user's data. The flaw is called Broken Object Level Authorization, BOLA for short, and it ranks first in the OWASP API Security Top 10 for 2023.

Example

User A requests their invoice:

http
GET /api/v1/invoices/1041 HTTP/1.1
Host: shop.example
Authorization: Bearer <token-A>

The same user then changes the number to 1042, an invoice that belongs to user B:

http
GET /api/v1/invoices/1042 HTTP/1.1
Host: shop.example
Authorization: Bearer <token-A>

If the server responds with 200 OK and the invoice data, the application is vulnerable to BOLA.

Why automated scanners miss it

From the outside, the vulnerable response looks entirely normal:

  • The scanner sees 200 OK and well-formed data, and treats the response as valid.
  • The scanner has no information about who owns invoice 1042.
  • Detection requires context the scanner does not have: at least two accounts, and knowledge of who owns each object.

Testing procedure

  1. Create two accounts with the same privileges: A and B.
  2. Record the requests from account A that contain identifiers (IDs).
  3. Replay the same requests using account B's token.
  4. Compare the results: if account B can read or modify account A's data, the vulnerability is present.

Testing should not stop at GET requests. It should also cover PUT, PATCH and DELETE, and look for identifiers in the request body, in headers, and in nested paths such as /users/7/orders/31.

Remediation

The fix belongs on the server, at every object access:

python
# Insecure: fetches the invoice by number only
invoice = Invoice.objects.get(id=invoice_id)

# Secure: fetches the invoice only if it belongs to the current user
invoice = Invoice.objects.get(id=invoice_id, owner=request.user)
  • Deny access by default.
  • Keep authorization logic in a single central layer rather than repeating it in every endpoint.
  • Random identifiers such as UUIDs make guessing harder, but they are not a fix.

Testing scope

We test only systems we own, systems we have written permission to test, or targets listed in the scope of a published bug bounty program. Anything outside that is off limits, even for learning purposes.