Authentication vs Authorization (RBAC, ABAC, ReBAC & BOLA)
How authentication and authorization differ, how RBAC, ABAC, and ReBAC model permissions, and how to prevent Broken Object-Level Authorization (BOLA).
TL;DR
Authentication (AuthN) proves who you are; Authorization (AuthZ) decides what you can touch. Most real-world breaches in A01:2025 Broken Access Control happen when an API checks AuthN and route-level roles, but forgets object-level ownership (BOLA).
Intent
Separate identity verification from policy enforcement, choose between RBAC, ABAC, and ReBAC for your domain, and enforce deny-by-default object checks on every server handler.
Problem
Teams often treat "logged in" as "allowed", or hide admin buttons in the frontend while leaving /api/invoices/:id open to any authenticated user who guesses another tenant's numeric ID. Without a clear boundary between AuthN and AuthZ, permission checks get scattered across controllers and silently missed on new endpoints.
Solution
Enforce deny-by-default authorization in a central policy layer after authentication succeeds:
- RBAC (Role-Based Access Control): Assign permissions to roles (
viewer,editor,admin). Example:role === 'editor'can publish blog posts. - ABAC (Attribute-Based Access Control): Evaluate attributes of the subject, resource, and environment. Example:
user.department === resource.department && request.ip in corpCIDR. - ReBAC (Relationship-Based Access Control): Evaluate graph relationships between users and objects. Example:
useris anowneroffolder_A, which containsdoc_42. - Permission boundaries & BOLA prevention: Always scope database queries by the authenticated
principal.idortenant.idfrom the server session—never trustuserIdorrolesent in the request body or query string.
Real-world analogy
▶ Flow: watch it work
Request → AuthN → AuthZ Policy Check → Resource (with Deny Path)
Press Start or tap any step dot to trace the path.
▸All steps (8)
Code
Always pair authentication with an explicit object-level authorization check on the server:
// UNSAFE: checks AuthN (user is logged in), but trusts :id without ownership check (BOLA)
app.get('/api/orders/:id', requireAuth, async (req, res) => {
const order = await db.orders.findUnique({ where: { id: req.params.id } });
return res.json(order);
});
// SAFE: scopes the lookup/policy check to the authenticated principal (ASVS V8)
app.get('/api/orders/:id', requireAuth, async (req, res) => {
const order = await db.orders.findUnique({ where: { id: req.params.id } });
if (!order) return res.status(404).json({ error: 'Not found' });
const isOwner = order.ownerId === req.user.id;
const isSupportAdmin = req.user.role === 'admin' && req.user.tenantId === order.tenantId;
if (!isOwner && !isSupportAdmin) {
return res.status(403).json({ error: 'Forbidden' });
}
return res.json(order);
});When to use / when to avoid
- Use RBAC when permissions map cleanly to a small, stable set of job roles (viewer, editor, admin).
- Use ABAC when access depends on dynamic context (department, tenant plan, IP range, time window).
- Use ReBAC when sharing and nested ownership graphs drive access (Google Drive-style folders and teams).
- Never rely on frontend route guards or hidden UI buttons as an authorization boundary.
- Do not encode mutable permissions into long-lived JWTs if role revocations must take effect immediately.
How to implement
Authenticate once at the boundary
Validate the session or token in middleware and attach an immutable principal object to the request context.
Deny by default
Reject any route that does not declare an explicit authorization policy.
Enforce object- and function-level checks
Check both can this role call this endpoint (no BFLA) and can this user access this specific record (no BOLA).
Test negative paths
Write integration tests where User A requests User B's resource ID and assert 403 (or 404).
Pros / Cons
- Centralized policy checks make security audits and unit tests straightforward.
- Scoping queries by principal/tenant prevents BOLA even when a developer forgets an if-statement.
- RBAC alone suffers from role explosion as exceptions accumulate.
- ReBAC requires maintaining an authorization graph or relationship store alongside application data.
Relations
Check yourself
Check Yourself
1. User A logs in with a valid token and requests GET /api/invoices/500, which belongs to User B, and the server returns it. What vulnerability is this?
2. Which access control model checks whether a user is a member of a parent team that owns a specific document?
Sources
Related Notes
Threat Modeling with STRIDE
How to run a lightweight STRIDE threat model before writing code, with a data-flow diagram and worked example for this static site, localStorage, and its RSS inbox workflow.
Passwords, Hashing, MFA & Rate Limiting
OWASP Password Storage Cheat Sheet parameters for Argon2id/bcrypt/scrypt, NIST SP 800-63B password rules, MFA choices, and rate limiting vs account lockout.