By Sergio Atenciano9 min read

Authorization is two questions: who, and which one

Most access-control bugs are not missing authentication. They are authentication that answers "who are you?" correctly and never asks "are you allowed this object?".

When an API is designed, authentication usually comes first: who is making the request? There is a login, a token, a session, and once that works, access looks solved. It is not. Authentication answers who you are. Authorization answers two different questions: what you may do and, above all, to which object.

That second question is the one that gets dropped. The server checks that you hold a valid session, assumes the object identifier riding along with the request is yours, and answers. Swap that identifier for someone else's and it hands you their data. This is the class OWASP calls Broken Object Level Authorization (BOLA), and it is the one that turns up most often when you actually audit an API.

The pattern, in one sentence

An object-level authorization bug is any endpoint that checks who you are and never checks whether the object you ask for is yours. The object identifier travels in the URL, the body, a header or inside a token, and the server uses it to read or write without binding that object to the caller.

GET /api/invoices/10482
Authorization: Bearer <valid session for Ana>

200 OK
{ "id": 10482, "owner": "Bruno", "total": "12.50" }

# Ana is authenticated. The invoice is Bruno's.
# The server checked the session and not the owner.
The minimal shape, in pseudo-HTTP

Why it is hard to see from the inside

In development everything works: each person signs in with their own account and sees their own things. The identifier reaching the server is correct because the interface put it there. The bug only shows up when someone changes that identifier by hand, and that does not happen in ordinary testing.

The missing check also tends to live at a different layer than the one being reviewed. The team looks at the session middleware, sees it is fine, and signs off on the route. But "does this object belong to them?" is answered at the data layer, not the session layer, and that is where it is missing.

The variants worth knowing

The same bug wears many disguises. Recognizing the family saves time:

  • Direct read by identifier: change a number in the URL and read someone else's object. The classic.
  • Write, not just read: the same endpoint that reads without an owner check also updates or deletes without one. The read gets reviewed; the write is forgotten.
  • Leak through lists and search: the single-object GET is well guarded, but the list or the search endpoint forgets the tenant filter and returns everyone's.
  • Identifier inside a token that does not cover it: the signature authenticates who you are, but the object sits in a field the signature never spans (there is a whole article on this).
  • Scope that fails open: when the organization identifier arrives empty or null, the filter degrades to "everything" instead of "nothing".

Multi-tenant: the same bug, more expensive

In a system with many customers (multi-tenant), object-level authorization is not an annoyance for one user, it is a leak between companies. A tenant that reads another tenant's objects sees a whole organization's data: invoices, users, vehicles, conversations.

The dangerous pattern is treating the tenant identifier as one more input, rather than as a boundary. If the server accepts the tenant the client claims to be, instead of deriving it from the session, the separation between customers is a suggestion, not a wall.

# Fragile: the tenant comes from the client
SELECT * FROM vehicles WHERE tenant_id = :tenant_from_query

# Robust: the tenant comes from the session, and it is mandatory
SELECT * FROM vehicles WHERE tenant_id = :tenant_from_session
# without that predicate, the query does not run
Two ways to resolve the same list

How it is fixed

The fix is not one more check in the controller, it is a principle about where authorization lives:

  • Authorize on the object, at the data layer. "Does this object belong to the caller?" is answered where the object is read, not by a distant guard a different route can bypass.
  • Derive the tenant from the session, never from the request. The client should not be able to name the organization it operates on.
  • Deny by default. An empty, null or absent identifier must close access, not open it.
  • Cover the whole lifecycle. If create checks the owner, so must update, delete, cancel, reopen and every verb that touches the object.
  • Test lists the way you test objects. The tenant filter is as much authorization as the single-object GET check.

The takeaway

Before calling a route safe, ask the two questions separately. Do I know who you are? Almost always yes. Do I know this object is yours? That is the one that finds the bugs. An API that only answers the first is an API that hands anyone's data to whoever knows how to ask for it by identifier.

Everything here is generic. We never describe a specific flaw in a client or a bug-bounty program, neither while it is unfixed nor after.

Back to research