RBAC or ABAC?

RBAC decides access by role; ABAC decides it with rules over attributes. Here’s how they differ, where each breaks down, and why most products end up using both.

By the NestedBit team · Updated

The short answer

Role-based access control (RBAC) attaches permissions to roles and gives roles to people: editors can update articles. NIST’s RBAC model is the standard reference. It’s simple to explain and easy to audit, but it strains when access depends on context, such as who owns a record, which team it belongs to, or how much money it involves.

Attribute-based access control (ABAC) decides each request with rules over attributes of the user, the resource, the action and the situation: a manager can approve an expense from their own department, up to their limit, if they didn’t submit it. NIST defines it in SP 800-162. It handles context well, but it’s harder to see at a glance who can do what.

Most products end up with both: roles for job functions, plus a few attribute conditions such as “only their own records” and “only within their organization”.

We build access control into products, but we don’t sell a policy engine or an identity product, so this guide doesn’t steer you to one. The one tool of ours it links is a free matrix builder.

Side by side

RBACABAC
Decides withRoles assigned to usersRules over attributes of user, resource, action and context
ExampleManagers can approve expensesManagers can approve expenses from their own department, up to their limit
Who can do what?Read it from the role matrixWork it out by evaluating the rules
Granting accessAssign a roleSet an attribute, or change a rule
Grows byAdding rolesAdding attributes and rules
Breaks down asRole explosion: dozens of near-identical rolesRules nobody can review with confidence
Common toolsRole tables, Casbin, Postgres rolesOPA (Rego), Cedar, Casbin with attributes

What RBAC looks like

An RBAC system is a matrix: one row for each action on each resource, one column for each role. In code, it becomes a lookup from roles to permissions:

// Check permissions, not role names, so changing a role never means changing code.
const PERMISSIONS = {
  viewer: ['article:read'],
  editor: ['article:read', 'article:create', 'article:update'],
  admin: ['article:read', 'article:create', 'article:update', 'article:delete'],
};

const can = (user, permission) =>
  user.roles.some((role) => PERMISSIONS[role]?.includes(permission));

Roles can inherit from one another, so an admin gets everything an editor can do, plus more. As long as roles map to real jobs, anyone can review the matrix and spot mistakes. You can lay one out and export it as code with the free RBAC Matrix Builder.

Role explosion: where RBAC breaks

Trouble starts when access depends on something other than the job. Sales reps may see only their own region’s deals, so “Sales rep” splits into one role per region. Managers need the same split, then support does, and the role list multiplies. Signs you’re there:

  • Role names that include a team, region, customer or person.
  • Pairs of roles that differ by one permission.
  • New roles created for a single exception, and never removed.

Each of those is a condition dressed up as a role. That’s the point to add attributes.

What ABAC looks like

An ABAC rule names the attributes it compares. Here’s the expense rule in Rego, the language of Open Policy Agent:

# An expense can be approved by someone in the same department,
# within their approval limit, who didn't submit it.
allow if {
	input.action == "approve"
	input.resource.type == "expense"
	input.user.department == input.resource.department
	input.resource.amount <= input.user.approval_limit
	input.resource.submitted_by != input.user.id
}

No role is mentioned. Anyone whose attributes fit can approve, which makes new teams and limits easy to support: change the attribute, not the rules. The price is visibility. To answer “who can approve this expense?”, you have to evaluate the rule for every user.

Using both

The usual answer is roles for the coarse question (what kind of user is this?) and attributes for the fine one (which records, under what conditions?). Cedar, the policy language behind Amazon Verified Permissions, makes that mix explicit:

// A role decides who may read deals; an attribute decides which ones.
permit (
  principal in Role::"sales_rep",
  action == Action::"read",
  resource is Deal
)
when { resource.region == principal.region };

The two conditions most products need are ownership (a user edits their own records) and tenancy (a user acts only within their own organization). Both fit cleanly on top of roles. The RBAC matrix builder has them built in: mark a cell “Own”, switch on multi-tenant, and every export, from Rego and Cedar to Postgres row-level security, carries the conditions through.

The line between them is thin, because a role can be treated as one more attribute of the user. A 2010 paper with a NIST lead author, Adding Attributes to Role-Based Access Control, ties role explosion to dynamic attributes such as time of day, and considers attributes as a way to make RBAC simpler and more flexible.

One app, modeled three ways

Take a small CRM. It has sales reps and managers in three regions. Reps read deals in their own region. Managers read them too, and approve discounts in their region, some up to 10% and some up to 25%.

With roles alone

Region and limit have nowhere to go except the role name. That gives three rep roles and six manager roles, nine in all, such as sales_rep_emea and manager_emea_25, each with permissions tied to its region. Nothing here is hard to read, but every new region or limit adds more of them.

With attributes alone

Two rules cover every region and every limit, and the job becomes an attribute like the others. In Rego:

package crm

default allow := false

# Anyone in sales reads deals in their own region.
allow if {
	input.action == "read"
	input.resource.type == "deal"
	input.user.job in {"sales_rep", "manager"}
	input.user.region == input.resource.region
}

# Managers approve discounts in their region, up to their limit.
allow if {
	input.action == "approve_discount"
	input.resource.type == "deal"
	input.user.job == "manager"
	input.user.region == input.resource.region
	input.resource.discount_percent <= input.user.discount_limit_percent
}

With both

Two roles remain, for the two jobs, and the rules narrow them by region and limit. In Cedar:

// Reps read deals in their own region. Managers do too,
// because Role::"manager" is a member of Role::"sales_rep".
permit (
  principal in Role::"sales_rep",
  action == Action::"read",
  resource is Deal
)
when { resource.region == principal.region };

// Managers approve discounts in their region, up to their limit.
permit (
  principal in Role::"manager",
  action == Action::"approve_discount",
  resource is Deal
)
when {
  resource.region == principal.region &&
  resource.discount_percent <= principal.discount_limit_percent
};

What changes later

Roles aloneAttributes aloneBoth
Model9 roles2 rules2 roles, 2 rules
Add a fourth region3 new rolesSet the region on its usersSet the region on its users
Add a 40% limit3 new rolesSet the limit on those managersSet the limit on those managers
Who can approve this discount?Read the matrixRun the rule for every userList the managers, then filter by region and limit
Where a mistake hidesA user holding the wrong roleA rule or an attribute that’s wrongEither, though there are fewer of each

For this app, both is the best fit. The two jobs stay visible in a matrix you can review, and new regions don’t mean new roles. Lay the jobs out in the RBAC matrix builder, then add the region and limit conditions by hand.

Trade-offs that decide it

  • Access reviews. Reviews ask who can do what. RBAC answers from the matrix; ABAC needs the rules run against your users.
  • Listing records. “Show everything this user can see” turns roles and ownership into a simple query filter. Complex attribute rules are much harder to turn into SQL.
  • Speed of a check. A role check is a lookup, often against roles and permissions claims the token already carries. An attribute check needs the attributes at decision time, which can mean extra queries.
  • Change. A new condition in RBAC often means new roles. In ABAC it’s one more attribute or rule.

When to use which

Three questions, in order. Stop at the first yes.

  1. Does the person’s job alone decide their access?

    Yes Use RBAC. It’s the simplest to build, and access reviews read straight from the matrix.

  2. Do users share individual objects, or does access follow folders and teams?

    Yes Add ReBAC. Keep roles for job-based access, and use relationships for the sharing.

  3. Are the extra conditions few, such as ownership, tenant, team, region or amount?

    Yes Use roles plus attribute conditions. This is where most products land.

  4. All no Lead with ABAC. The rules are the product, as with data classified by sensitivity. You’ll need a policy engine and the discipline to test its rules.

Moving from roles to attributes

You don’t need a rewrite. The change can go one condition at a time:

  1. Put every check behind one function, such as can(user, action, resource), so routes stop comparing role names themselves.
  2. List the roles that hide an attribute. A region, team or customer in a role name is the sign, and a group that differs only by that word is your first candidate.
  3. Add the attribute and write the rule, then run it beside the old check and log every disagreement without enforcing it.
  4. Switch over once the two agree, and merge the old roles into one.
  5. Keep a test for each decision that matters, including the ones that must be refused.

Other models you’ll see

ReBAC

Relationship-based access control (ReBAC) grants access through relationships between users and objects: you can edit a document because you’re a member of the team that owns the folder it’s in. It’s the model behind sharing in Google Docs, described in Google’s 2019 Zanzibar paper, and implemented by open-source projects such as OpenFGA and SpiceDB. Reach for it when users share individual objects with each other; for job-based access, roles with a few conditions are simpler.

DAC

In discretionary access control, the owner of an object decides who else can use it, as with file permissions on a shared drive. It’s easy to use, but access spreads with every owner’s choices, so it’s hard to govern centrally.

MAC

In mandatory access control, a central authority sets the policy and owners can’t change it. Military classification is the usual example. You’ll meet it in government and defense work, and rarely in a typical SaaS product.

PBAC

Policy-based access control is the loosest of these terms. The NIST glossary carries two meanings: an authorization policy flexible in what it evaluates, and a mix of business roles with policies. When someone says PBAC, ask what the policies evaluate and where they run. The answer is usually ABAC, with rules managed outside the app.

Questions that come up

Is ABAC more secure than RBAC?

Not by itself. ABAC can express tighter rules, which helps limit access to what’s needed. But a rule nobody can review is its own risk, and a broad role is a risk in RBAC. The safer system is the one your team can check and test.

Should roles and attributes go in the token?

Keep it small: a coarse role or two is fine in JWT claims, if tokens are short-lived. Look up attributes that change, such as limits and record ownership, at decision time.

What about AI agents?

Give an agent its own identity and the narrowest role that does its job, rather than a person’s access. Attribute conditions then limit which records it can touch. See AI agent use cases for how much freedom to give each kind of job.

Free tool · No sign-up

RBAC Matrix Builder

Lay out roles, resources and actions in a grid, then export the matrix or working policy code.

Starts with a free 30-minute intro call, or email hello@nestedbit.com.