When you build an API, checking that a caller is logged in does not show whether they have permission to perform each action. Function-level authorization checks whether a caller may invoke a specific API action, such as changing system settings or deleting an account. Without that check, a logged-in regular user can invoke a privileged function. Security researchers call this broken function-level authorization, or BFLA.
Check permission on the route or method that performs the action, then check separately whether the caller may act on the specific record they requested. These checks answer different questions. A route guard controls which actions a caller may invoke; an object-level check controls which records they may access. To test both, try privileged actions with a low-privilege account and confirm that the API does not perform them.
Check permission on the action route
Authentication identifies the caller. Authorization decides what that caller may do. An API that checks only whether a token is valid knows who made the request, but not whether that person has permission to call an administrative endpoint.
For example, if an account-deletion route accepts requests from any logged-in user, that user can delete another person’s account. If a system-settings route has the same gap, any logged-in user can change administrative settings. The Express examples from Qodex show these failures and add both a login check and an administrator check to the settings route.
A route-level guard makes the permission requirement visible where the API exposes the action:
app.put(
"/system-settings",
authenticateToken,
requireAdmin,
updateSystemSettings
);
Here, authenticateToken verifies the caller’s identity, and requireAdmin checks whether the caller has the required role. If the caller lacks permission, the API should reject the request before updateSystemSettings runs. Use role and permission names that match your service’s rules; the example does not define a universal role scheme.
Add a guard to every route that exposes a privileged action. A check on a read route does not protect a write route. A caller who can read an order does not automatically have permission to update or delete it. The same applies to invitations: permission to read invitation details does not grant permission to create invitations. NextOrbit’s examples describe failures caused by missing checks for different actions or HTTP methods.
Keep function and record checks separate
A function-level check asks, “May this caller delete an account?” An object-level check asks, “May this caller delete this account?” An API often needs both answers for the same request.
For example, an account-deletion rule can let an administrator delete an account or let a user delete their own account. The route or service must check the caller’s role and compare the caller’s identity with the target account. Confirming only that the caller owns the target account does not protect a different administrative action, such as changing system settings. The Qodex account-deletion example shows these as separate reasons to allow access.
Some frameworks check permission at a method instead of a route. In Spring Security, @EnableMethodSecurity enables annotations such as @PreAuthorize, which evaluates an access expression before invoking a method. An access expression is a rule that decides whether the caller may invoke the method. For example, a method can require an administrator role. Spring’s method-security documentation says that a denied method call raises AccessDeniedException; in an HTTP request, that becomes HTTP 403. The cited documentation is for a snapshot version, so check the documentation for the Spring Security version you use.
Method-level rules can check the caller’s roles or authorities, or compare a method argument with the authenticated user. Spring treats these checks on a method call separately from hasPermission, which sends object-level decisions to a PermissionEvaluator. Keep both checks when the action and target record require them. Also check for methods without annotations: Spring’s documentation warns that method-security annotations do not protect methods without annotations and recommends request-level rules in HttpSecurity as another layer of protection.
Test privileged actions with lower-privilege accounts
Before testing, write down which roles should be allowed to invoke each sensitive function. This expected-permission matrix helps developers and testers tell a defect from intended access. A role-to-function matrix can be as simple as:
| Function | Administrator | Standard user |
|---|---|---|
| Change system settings | Allowed | Denied |
| Delete another user’s account | Allowed | Denied |
| Delete own account | According to the service’s rule | According to the service’s rule |
Then sign in as a standard user and call each privileged route directly. Check the response and what happened: a denial such as HTTP 403 is useful evidence, but the settings must stay unchanged, the account must remain, and the handler must not perform the action. The API testing examples from SecureKhan compare a vulnerable success response with a secure denial.
Test the HTTP methods that change data. If a route supports PUT, PATCH, or DELETE, call those methods as a low-privilege user; a successful GET check does not show that they are protected. One method can lack a guard even when another method for the same resource has one. Authorization testing guidance recommends trying different methods and recording which roles can call each function.
To make the test repeatable, record the endpoint, method, account role, request, response, and whether the sensitive action occurred. Compare the same action using an authorized account and a low-privilege account. This makes a regression easier to spot and confirms that the API blocks the function itself, not just the path one client normally uses. For a related distinction, see testing API authentication and authorization separately.