How it works
BFLA happens when the server confirms that a caller is logged in but does not confirm that the caller's role is allowed to use the function. The user interface hides the button, and the API behind the button stays open to every logged-in user.
APIs group their operations into functions: create a user, issue a refund, change a setting, export a report. Some of these are meant for a small group. If the only thing keeping other users out is that their screen does not show the feature, the protection is cosmetic. Anyone can read the route from the JavaScript bundle, the mobile app, the API documentation or a guess, and send the request by hand.
The result is privilege escalation: a customer acts as support staff, or a team member acts as the workspace owner.
What it looks like
Here user_a is a normal customer. The support console is the only place that issues account credits, and customers never see it. The endpoint accepts the request anyway.
POST /api/v2/support/accounts/acct_2207/credit HTTP/1.1
Host: api.acme.test
Authorization: Bearer <token for user_a, role: customer>
Content-Type: application/json
{"amount_cents": 50000, "reason": "goodwill"}HTTP/1.1 201 Created
Content-Type: application/json
{"account": "acct_2207", "credit_cents": 50000, "issued_by": "user_a"}A correct server answers 403 Forbidden. Nothing in the request is malformed, which is why scanners and web application firewalls rarely notice this class of flaw.
Unprotected functions tend to hide in a few places:
- Predictable admin paths.
/admin,/internal,/supportor/staffprefixes. - Other HTTP methods.
GETon a resource is checked, whileDELETEorPUTon the same path is not. - Old API versions. Version 3 has the check and version 1 is still deployed without it.
- GraphQL mutations. Queries are protected and a privileged mutation is not.
How to test for it
Testing needs at least two accounts with different roles, so it is part of authenticated penetration testing.
- Sign in as the privileged role and use every feature while recording the traffic.
- Build a list of each privileged request: method, path and body.
- Replay every request with the low-privilege account's token, changing nothing else.
- Repeat with no token at all.
- Try other methods and older version prefixes on each path.
- Treat any success response as a finding, then confirm the action really happened by checking from the privileged account.
For write actions, aim at test data you own so that proving the flaw does not damage anything.
How to fix it
Check the role on the server for every function, and deny by default.
// Vulnerable: any logged-in user reaches the handler.
router.post("/support/accounts/:id/credit", requireLogin, issueCredit);
// Fixed: the role is checked on the server before the handler runs.
const requireRole = (...allowed) => (req, res, next) =>
allowed.includes(req.user.role) ? next() : res.status(403).end();
router.post(
"/support/accounts/:id/credit",
requireLogin,
requireRole("support", "admin"),
issueCredit
);Rules that hold in any framework:
- Deny by default. A new route should be unreachable until someone grants a role access to it. Forgetting then fails closed.
- Keep the policy in one place. A central permission map is easier to review than checks scattered across handlers.
- Take the role from the server-side session. Never trust a
rolevalue sent in the request body, a header or an unsigned cookie. - Test it in CI. For each privileged route, assert that a low-privilege user receives
403. - Hiding is not protecting. Removing a menu item or using an unguessable path does not change who is allowed to call the function.
BFLA vs BOLA
Both are authorization failures, and they answer different questions. BFLA asks whether this user may use this function at all. Broken object level authorization asks whether this user may touch this particular record through a function they are allowed to use.
A customer calling the refund endpoint is BFLA. A customer using the normal "view my invoice" endpoint to read another customer's invoice is BOLA. One request can have both problems, and both sit under the wider heading of broken access control.