RBAC vs ABAC: choosing an authorisation model that survives growth
RBAC grants by role, ABAC decides from attributes at request time. How each works, the same rule in Rego, and when to combine them.
Start with RBAC: it is easy to reason about, easy to audit and covers most coarse permissions. Add ABAC when decisions depend on the resource or the context (owner, tenant, department, data classification, device, time) and you catch yourself minting a new role per combination. In practice most mature systems are RBAC for the coarse grant plus attribute checks for the fine one, evaluated by a single policy engine.
| RBAC | ABAC | |
|---|---|---|
| Decision input | User's roles | Subject, resource, action and environment attributes |
| Reference | ANSI INCITS 359 (NIST RBAC model) | NIST SP 800-162 |
| Granularity | Coarse: per action and resource type | Fine: per resource instance and context |
| Typical question | Can editors publish articles? | Can this user read this invoice from this device now? |
| Audit: who can do X? | Easy: list role members | Hard: must evaluate policy over all attributes |
| Failure mode | Role explosion | Policy sprawl and attribute drift |
| Data it needs | Role assignments | Trusted, fresh attributes on users and resources |
| Change cost | Add a role or assignment | Edit policy, test it, ship it |
| Tooling | IdP groups, app role tables, Kubernetes RBAC | OPA/Rego, Cedar, XACML, AWS IAM conditions |
| Multi-tenant fit | Weak alone (role per tenant) | Strong (tenant attribute match) |
01How each model actually decides
RBAC is two lookups: user to roles, role to permissions. A permission is an (action, resource type) pair. The NIST model adds role hierarchies (senior roles inherit junior permissions) and separation of duty constraints (no one holds both 'raise payment' and 'approve payment'). Nothing about the specific resource or the request context enters the decision.
ABAC evaluates a policy over four attribute sets: subject (department, clearance, employment type), resource (owner, tenant, classification), action, and environment (time, IP, device posture, MFA used). The policy decision point (PDP) returns permit or deny; a policy enforcement point (PEP) in the app or gateway calls it with the attributes it has, and a policy information point (PIP) fetches the rest.
Relationship-based access control (Zanzibar style: OpenFGA, SpiceDB) decides from a graph of relationships, such as 'user is editor of folder that contains doc'. It is the right tool for sharing models like Google Drive, and it is neither RBAC nor ABAC, though people often reach for ABAC when they actually need ReBAC.
02The same rule in both models (OPA Rego)
Task: finance staff can read invoices. With RBAC that is a role grant. With ABAC we also require the invoice to belong to the reader's department and tenant, and the session to have used MFA. Both written in OPA 1.0 syntax, where if and contains are mandatory.
package authz.rbac
default allow := false
# data.user_roles: {"u-123": ["finance-reader"]}
# data.role_permissions: {"finance-reader": [{"action": "read", "type": "invoice"}]}
allow if {
some role in data.user_roles[input.user.id]
some perm in data.role_permissions[role]
perm.action == input.action
perm.type == input.resource.type
}package authz.abac
default allow := false
allow if {
input.action == "read"
input.resource.type == "invoice"
input.user.department == "finance"
input.user.tenant == input.resource.tenant
input.user.department == input.resource.owning_department
input.context.mfa == true
}The RBAC policy never changes when a new tenant arrives; its data does. The ABAC policy never changes either, but it now depends on resource.tenant and context.mfa being correct, so the hard work moves to attribute quality.
03When to pick which
- Pick RBAC when permissions are about job function, the number of distinct roles is small (tens, not thousands) and auditors ask 'who can approve payments?'.
- Pick ABAC when the answer depends on the specific record (ownership, tenant, classification) or on context (MFA, managed device, network, time).
- Signal you have outgrown RBAC: roles named like
emea-finance-readonly-contractor. That is attributes encoded into role names. - Signal ABAC is overkill: every policy reduces to
user.role == X. You built RBAC with extra moving parts. - Hybrid default: roles come from the IdP as a subject attribute, ABAC conditions add tenant, ownership and context. One engine, one decision log.
04Common mistakes and migration notes
- Trusting client-supplied attributes.
departmentmust come from the IdP or directory, never from the request body. - Stale attributes. A mover keeps old department access until the attribute syncs; wire SCIM and short token lifetimes.
- Filtering lists in the app after fetching everything. Push the tenant and owner conditions into the query (OPA partial evaluation, or a WHERE clause) or you leak counts and burn CPU.
- No deny-by-default. Both policies above set
default allow := false; an engine that defaults to permit on error fails open. - Migrating RBAC to ABAC by rewriting everything. Keep roles, expose them as an attribute, and add conditions one endpoint at a time behind decision logging in shadow mode.
To answer 'who can read invoice 42?' you must evaluate the policy across every user. Plan for it: keep policies small, log every decision with its inputs, and test policies in CI like code.
05How to say it in an interview
RBAC answers 'what can people in this job do', ABAC answers 'can this person do this to this thing right now'. I start with RBAC because it is simple and auditable, then add attribute conditions for tenant isolation, ownership and context such as MFA, all in one policy engine with deny by default. The real risk in ABAC is attribute integrity, so attributes come from the IdP or the resource store, never the client, and every decision is logged with its inputs.
Questions people ask
Q1Is ABAC more secure than RBAC?+
Not by itself. ABAC is more expressive, which lets you enforce least privilege more precisely, but it is only as good as the attributes it reads. A sloppy ABAC policy with untrusted attributes is worse than a tight RBAC model.
Q2What is role explosion?+
Creating a new role for every combination of function, region, tenant and data class until you have thousands of roles nobody can audit. It is the classic sign that some of those dimensions should be attributes.
Q3Can you use RBAC and ABAC together?+
Yes, and most systems should. Treat roles as one subject attribute and write policies that check the role plus resource and context attributes. AWS IAM with condition keys and OPA policies both work this way.
Q4Is Kubernetes RBAC or ABAC?+
Kubernetes supports both authorisers, but RBAC is the default and the recommended mode. The ABAC authoriser exists, needs a restart to change policy and is rarely used. Admission controllers or policy engines cover attribute-style checks.
Q5Where does ReBAC fit?+
ReBAC decides from relationships in a graph, such as membership and ownership chains. Use it for sharing and nested hierarchies like folders and organisations, where ABAC would need to precompute ancestry into attributes.