Course map

Topic 163 / Core

RBAC and ABAC: resource-level authorization, privilege escalation prevention

Chapter 10.2 · Identity and Access

What and why

Topic 159 separated authentication from authorization but left the authorization model open; this topic names the two common ones. RBAC (role-based access control) assigns permissions to roles and roles to users — coarse, simple, cheap to reason about. ABAC (attribute-based access control) evaluates policies over attributes of the user, the resource, and the environment at request time — fine-grained, more expressive, and more complex to build and debug. Both still need resource-level authorization: a role or policy that grants "may edit documents" is not the same as "may edit this document," and the gap between the two is where privilege escalation — a caller gaining rights they were never granted — tends to happen. Builds on: → 162 (JWT and session management — the claims a token carries often drive these decisions).

Diagram

Model Granularity Example rule Complexity
RBAC Coarse — per role "editor" role may edit any document Low — easy to audit, prone to role explosion
ABAC Fine — per attribute combination May edit if resource.team == user.team Higher — expressive, harder to trace a decision
Resource-level check (either model) Per object Does this document belong to this caller's team/ownership Required underneath both models

How it works

  1. RBAC: assign roles to users, permissions to roles; check role membership at the access point.
  2. ABAC: define policies over attributes — user attributes, resource attributes, environment (time, location, device) — evaluated per request for finer-grained rules RBAC's fixed roles can't express.
  3. Resource-level authorization: whichever model grants the coarse permission, still check the specific object — "has the 'editor' role" is not "owns or was shared this document" (the same gap topic 39 named first).
  4. Combine when needed: RBAC for coarse role boundaries, a resource-level or ABAC check for the per-object decision underneath it.
  5. Privilege escalation prevention: no self-service role grants — a user cannot grant themselves or others a higher role; role changes go through a separate, privileged workflow; every such change is audited (→ 171).
  6. Apply least privilege (→ 158) to role and policy design itself — default to the narrowest role or policy that still does the job.

Practical example

(illustrative). A naive RBAC implementation: role "editor" may edit any document. A caller with that role edits a document belonging to a different team — the role check passed, but no resource-level check existed. The fix adds an ABAC-style rule: may-edit requires both the "editor" role and resource.team == user.team — the role grants the coarse capability, the attribute check scopes it to the right objects.

When to use it

  • Use RBAC when: the set of permissions is small, stable, and coarse — most products start here.
  • Use ABAC when: access rules genuinely depend on dynamic attributes (ownership, time, location) that a fixed role can't express.
  • Avoid: building an ABAC policy engine when RBAC plus one resource-level check already covers every real rule — this is rule 7 (no forced complexity) applied to access control.
  • Failure scenarios: role explosion in RBAC (a new role invented for every edge case until the role list is unmanageable); policy sprawl in ABAC (rules that contradict each other and nobody can predict the outcome for a given request); privilege escalation via a self-service "make me admin" path that was never explicitly blocked.
  • Simpler alternative: for a two-role app (user/admin), a hardcoded role check is enough — skip a general policy engine until a third role or a per-object exception actually shows up.

Practice

(Decision kind — judge scenarios and defend the choice; 15–20 min, no lab services). For each of these four scenarios, decide RBAC, ABAC, or a resource-level check alone, and defend it in one sentence: (1) only "user" and "admin" exist; (2) a document may be edited only by its owner or someone on the same team; (3) an action is allowed only during business hours from a corporate device; (4) a support agent may view, but not edit, any customer's account. Done when every scenario has a named model and a one-sentence justification that names the attribute or role the decision actually turns on.

Key takeaway

RBAC is simple and coarse, ABAC is expressive and complex, and both still need a resource-level check underneath; privilege escalation is prevented by making role and policy changes a separate, audited action. Done when you can: pick the right model for a given access rule and point to the specific check that stops privilege escalation. Used next in → 171 (privilege escalation and admin actions audited); Project 3; Project 20.

References

None — this topic makes no external claims.

Source directory

Search the guide