Authentication is not authorisation
A valid session proves who is calling. It does not prove the caller may act on this object.
Authentication answers “who is calling?”. Authorisation answers “may this caller act on this specific object?”. A valid session proves identity; it says nothing about the account ID in the URL.
IDOR and BOLA
An Insecure Direct Object Reference (IDOR), called Broken Object Level Authorisation (BOLA) in the OWASP API Security Top 10, happens when an ID from the request selects a record and nothing checks that the record belongs to the caller.
Why the owner goes in the query
If you read the record and check ownership in a separate step, it is easy to forget the check in one branch. Putting the owner in the same query means other users' records simply do not exist for the caller.
Function-level access (BFLA)
The same idea applies to actions. An admin-only endpoint must check the role on the server. Hiding a button, or a middleware that only checks that a cookie exists, is not a control.
Questions to ask yourself
- Where does the owner of this record come from?
- Is the check on the server, and in the same query?
- What does a non-owner receive: a 403, a 404, or the data?
Practise this
- Another customer's balance · Authorization
- Account lookup by id in Spring Kotlin · Authorization