Lesson 4 of 4 IAM Policies and Authorization

Scaling Access with Attribute-Based Access Control

This lesson explains attribute-based access control (ABAC), which grants access when attributes of the principal match attributes of the resource, so one policy covers every team instead of one policy per team or project.

Learning outcomes

After completing this lesson, you will be able to:

  • Distinguish ABAC from RBAC.
  • Identify where principal attributes come from, such as session tags.
  • Explain why the tags that ABAC relies on must be protected.
  • Write one ABAC policy that serves every project team.

ABAC and RBAC

Role-based access control (RBAC) groups permissions by job function into roles or permission sets, and each role lists the resources it can use. When a new project starts, new roles or policy changes are needed, so the number of roles grows with the number of projects. IAM paths help organise them.

Attribute-based access control (ABAC) allows access when attributes match, such as a principal tag equal to a resource tag: aws:PrincipalTag/project = aws:ResourceTag/project. One policy then covers every project, and a new project needs only tags. ABAC is only as secure as its tags, so policies must require tags when resources are created, using aws:RequestTag and aws:TagKeys. They must also prevent users from changing the tags that control access. The following table summarises the comparison.

ABAC
IdeaAllow when attributes match, for example aws:PrincipalTag/project = aws:ResourceTag/project
ScalingOne policy covers every project; new projects need only tags
Watch out forRequire tags at creation (aws:RequestTag, aws:TagKeys); stop users changing access-control tags
RBAC
IdeaPermissions grouped by job function into roles or permission sets
ScalingNumber of roles grows with projects
Watch out forUse IAM paths to group roles
Sort into groups

ABAC or RBAC?

Exam skills 4.2.2

Decide which access control model each statement describes.

Log in to try this activity Interactive activities are free with an account.

Where principal attributes come from

Attribute-based access control depends on attributes attached to principals. The following list describes where these attributes come from.

  • IAM role and user tags.
  • Session tags passed in AssumeRole or SAML federation.
  • Attributes for access control in IAM Identity Center, such as department or cost centre from the identity provider.
True or false

Sources of principal attributes

Exam skills 4.2.2

Check where the attributes used in ABAC come from.

Log in to try this activity Interactive activities are free with an account.

Protecting the tags

ABAC is only as strong as the control over tags. If users can add their own project tag to another team's resource, they can grant themselves access. Policies must deny tagging and untagging resources outside the user's own attribute values, and SCPs or tag policies can reserve access-control tag keys for administrators.

The following diagram shows what each statement allows or denies.

One attribute-based policy for every project team. Sessions carry a project tag from the identity provider; reads are allowed where the secret's project tag equals the principal's, new secrets must carry the caller's own project tag, and retagging another project's secret is denied, closing the classic ABAC loophole.
ABAC stands for attribute-based access control.
Worked example

One ABAC policy for every project team

Engineers in many project teams need access to their own team's secrets and nothing else. Their sessions carry a project tag from the identity provider. One policy works for all teams, now and in future:

{
  "Version": "2012-10-17",
  "Statement": [
    { "Sid": "ReadOwnProjectSecrets", "Effect": "Allow",
      "Action": ["secretsmanager:GetSecretValue", "secretsmanager:DescribeSecret"],
      "Resource": "*",
      "Condition": { "StringEquals": { "aws:ResourceTag/project": "${aws:PrincipalTag/project}" } } },
    { "Sid": "CreateOnlyTaggedWithOwnProject", "Effect": "Allow",
      "Action": ["secretsmanager:CreateSecret", "secretsmanager:TagResource"],
      "Resource": "*",
      "Condition": { "StringEquals": { "aws:RequestTag/project": "${aws:PrincipalTag/project}" },
                     "ForAllValues:StringEquals": { "aws:TagKeys": ["project", "owner"] } } },
    { "Sid": "NoRetaggingOtherProjects", "Effect": "Deny",
      "Action": ["secretsmanager:TagResource", "secretsmanager:UntagResource"],
      "Resource": "*",
      "Condition": { "StringNotEquals": { "aws:ResourceTag/project": "${aws:PrincipalTag/project}" } } }
  ]
}

The third statement closes the classic ABAC loophole: without it, a user could add their own project tag to another team's secret and then read it. Adding a new project requires no policy change at all, only tags.

Check yourself

Why must the tags used for ABAC be protected?

Show answer

If users could change them, they could grant themselves access to other projects' resources.

Exam Tips

Remember for the exam

  • To cover hundreds of projects with one policy, use ABAC with matching tags.
  • To pass a department from the identity provider for authorisation, use session tags or attributes for access control.
  • Protect the tags used for access control from being changed.
  • Require tags at creation with aws:RequestTag and aws:TagKeys.
  • ABAC needs no policy change when new projects are added.