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
| RBAC | ABAC | |
|---|---|---|
| Permissions tied to | Role (job function) | Tag match between principal, resource and request |
| New resource | Update role policies to name it | Tag it. Existing policy already covers it |
| Number of policies | Grows with teams and resources | Few, reusable |
| Granularity | Per role | Per attribute combination, such as department and project |
| Risk | Rushed policy edits drift from least privilege | Anyone who can change tags can change access |
| Best fit | Small stable set of well-defined roles | Many 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 AWS | Permission sets, IAM roles, Cognito groups | aws: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
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 allowsts: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
| Key | Compares |
|---|---|
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:TagKeys | Set 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
| Source | How |
|---|---|
| IAM tag on user or role | Static, set by an administrator |
Session tag passed at AssumeRole | Needs sts:TagSession in the trust policy |
| SAML or OIDC federation | PrincipalTag attributes or the https://aws.amazon.com/tags claim |
| IAM Identity Center | Attributes for access control map directory attributes to session tags |
| Role chain | Only 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
ABAC with session tags from the IdP needs one policy, and new projects work as soon as instances are tagged. Forty permission sets with ARN lists is the RBAC approach the company wants to avoid. OUs and SCPs don't grant permissions, and Identity Center users aren't IAM users, so IAM groups don't apply.
Related
- STS, roles and cross-account access
- Federation with SAML, OIDC and IAM Identity Center
- Amazon Verified Permissions
- Cognito and API Gateway authorizers