Skip to Content
Asterrr's Handbook
4 · Identity and access management

RBAC versus ABAC

When role-based access is enough, how tag-based access control scales with fewer policies, where principal tags come from, and the condition keys that implement it.

Exam tasks: 4.2 (Skill 4.2.2 ABAC from attributes and ABAC and RBAC strategies)

The decision: does access follow the job someone holds (RBAC) or attributes on the person and the resource (ABAC), and where do those attributes come from?

RBAC attaches permissions to roles that mirror job functions. ABAC compares attributes, usually tags, on the principal and on the resource in a single policy. ABAC avoids editing policies each time a resource is added.

Comparison

RBACABAC
Permissions tied toRole (job function)Tag match between principal, resource and request
New resourceUpdate role policies to name itTag it. Existing policy already covers it
Number of policiesGrows with teams and resourcesFew, reusable
GranularityPer rolePer attribute combination, such as department and project
RiskRushed policy edits drift from least privilegeAnyone who can change tags can change access
Best fitSmall stable set of well-defined rolesMany teams, fast-changing resources, multi-tenant, federated attributes
Audit question"Who is in the admins role?" is easy"Who can reach this resource?" needs attribute analysis
In AWSPermission sets, IAM roles, Cognito groupsaws:PrincipalTag vs aws:ResourceTag, Cedar when clauses on attributes
  • Most real designs mix both. A role decides the kind of access, attributes decide which resources.
  • ABAC depends on tag integrity. Control who can set tags (aws:RequestTag, aws:TagKeys, tag policies) or users can grant themselves access.

How ABAC is wired

session tagattachedGetObject if tags matchIdP or IdentityCenterRole session,Department=RadiologyPolicy comparestagsObjects taggedDepartment
The identity provider sends Department as a session tag. The policy lets the session read only objects whose Department tag matches.

Example policy statement.

{
  "Effect": "Allow",
  "Action": "s3:GetObject",
  "Resource": "arn:aws:s3:::HospitalRecords/*",
  "Condition": {
    "StringEquals": {
      "s3:ExistingObjectTag/Department": "${aws:PrincipalTag/Department}"
    }
  }
}

ABAC from IdP attributes

Attributes such as department or cost centre travel from the IdP into the session as principal tags, and policies compare them with resource tags. One policy then covers every team.

  • In Identity Center, turn on attributes for access control and map each key to an identity-store attribute or to the SAML attribute https://aws.amazon.com/SAML/Attributes/AccessControl:<key>.
  • With direct IAM federation, send https://aws.amazon.com/SAML/Attributes/PrincipalTag:<key> in the assertion. The role's trust policy must also allow sts:TagSession.
  • Deny users changing the tags that the policy relies on, or they can tag themselves into access.
{
  "Effect": "Allow",
  "Action": ["ec2:StartInstances", "ec2:StopInstances"],
  "Resource": "arn:aws:ec2:*:*:instance/*",
  "Condition": {
    "StringEquals": { "aws:ResourceTag/costCenter": "${aws:PrincipalTag/costCenter}" }
  }
}

Condition keys

KeyCompares
aws:PrincipalTag/<key>Tag on the calling user or role, including session tags
aws:ResourceTag/<key>Tag on the resource being accessed, for services that support it
aws:RequestTag/<key>Tag value sent in the request, such as in CreateTags or create calls
aws:TagKeysSet of tag keys in the request. Pair with ForAllValues or ForAnyValue
s3:ExistingObjectTag/<key>Tag already on an S3 object

Where principal tags come from

SourceHow
IAM tag on user or roleStatic, set by an administrator
Session tag passed at AssumeRoleNeeds sts:TagSession in the trust policy
SAML or OIDC federationPrincipalTag attributes or the https://aws.amazon.com/tags claim
IAM Identity CenterAttributes for access control map directory attributes to session tags
Role chainOnly keys marked transitive carry forward

Exam trap

A tag in an Allow is only as safe as the control over who can write that tag. Restrict TagRole, TagUser, CreateTags and similar actions, and check aws:RequestTag and aws:TagKeys on tag-on-create calls. Also remember that a missing tag key makes the condition false, so unlabeled resources are denied rather than open.

Exam signal

"Reduce the number of IAM policies as the company launches new projects" or "new resources must be reachable without editing roles" points to ABAC. "Three fixed job functions with clear duties" points to RBAC.

Exam trap

A tag in an Allow is only as safe as the control over who can write that tag. Restrict TagRole, TagUser, CreateTags and similar actions, and check aws:RequestTag and aws:TagKeys on tag-on-create calls. Also remember that a missing tag key makes the condition false, so unlabeled resources are denied rather than open.

Exam signal

"Reduce the number of IAM policies as the company launches new projects" or "new resources must be reachable without editing roles" points to ABAC. "Three fixed job functions with clear duties" points to RBAC.

Scenarios

Scenario
A company wants engineers to start and stop only the EC2 instances that belong to their own project, across 40 projects, without maintaining 40 policies. Project membership is already an attribute in the corporate IdP connected to IAM Identity Center. What should the security engineer do?

Further reading

On this page