- Reference
Why authorization is harder to solve than authentication
- Abstract
Authentication is a one-time check; authorization needs to be checked everywhere.
- Date filed
- 28 August 2026
- Category
- Application Security
- Reading time
- 2 min
Authentication and Authorization are two parts of the AAA framework for computer security, the third being Accounting.
Here is a summary:
- Authentication: Who you are
- Authorization: What you can do
- Accounting; What you did
Authentication is difficult to setup, but you usually only have to do it once. Authorization in the other hand needs to be setup at every endpoint and for every action.
Why is this so?
Authentication failures are immediately obvious - users can't log in and web requests begin failing. It usually gets fixed immediately and is tested hard. At it's core, the problem is a simple binary: You are who you say you are, or you are not.
Authorization failures on the other hand are much harder to catch - the user loads a part of the site or system they don't have access to, and there is no alert generated and nothing suspicious in the logs. When testing, devs and IT teams usually check if the user can access resources they are authorized to use, but often the reverse is not checked.
A typical codebase might have 1000s of authorization checks, only one of them has to go wrong to give everyone involved a very bad day,
Bad coding and configuration practices
Authentication is default deny, since protected routes check for authentication tokens like cookies, API keys, JWTs or other methods of proving you are who you say you are. Authorization, by contrast, defaults to accept. Most authorization bugs are caused not by bad logic, but by no logic
For example, a dev adds the route below to load an invoice record from DB, parse it and send the results to the user. The code inherits authentication from middleware automatically, so the endpoint is protected, but the code simply never checks if the user has any relationship to the record being fetched.
# The bug here is not the line of code itself but the absence of any other code to validate the user's access permissions
invoice = db.query(Invoice).filter(Invoice.id == invoice_id).one()The code snippet looks correct in a review since it looks like any other data fetching line in the codebase, and runs without error. Nobody catches the missing authorization since it does not raise an alert and all tests pass
How do we fix this?
Object Scoping
A good fix is to make the unscoped query simply impossible to write, rather than making the same decision across hundreds of callers. If the data access layer needs a defined actor, the lack of authorization checks become a compile-time error, not a runtime one, and is more easily caught in review.
invoice = invoices.for_actor(curr_user).get(invoice_id).one()Test the negative case
Access control testing usually checks if the right person can access the resource, this test passes even if authorization hasn't been set up. An actually valuable test also checks the other way around - the wrong person should not be able to access the resource. It is best practice to return a 404 (not found) compared to a 403 (forbidden) status code since it provides useful information to an attacker (this resource exists vs this resource may not exist)
Improved review methodology
In review, authentication usually stands out first. We can easily check if the code invokes an authentication check. Authorization on the other hand needs you to think unprompted: "What code here checks if an authenticated user can provide the ID for a resource they don't own and get a response?"