Lesson 3 of 4 IAM Policies and Authorization

Delegating Safely with Permissions Boundaries and Session Policies

This lesson explains how permissions boundaries and session policies set maximum permissions without granting anything, so that least privilege scales across many teams through safe delegation and narrower sessions.

Learning outcomes

After completing this lesson, you will be able to:

  • Use permissions boundaries to delegate role creation safely.
  • Explain how a session policy restricts a single session.
  • Explain how SCPs, RCPs, boundaries and session policies combine.

Permissions boundaries and delegation

A permissions boundary is a managed policy attached to a user or role that sets the maximum permissions the identity can have. It does not grant anything by itself: the effective permissions are the intersection of the identity-based policies and the boundary, so an action is allowed only if both allow it. Its classic use is delegated administration, which lets developers create roles for their own applications without being able to create roles more powerful than themselves. Delegation works as follows.

  1. Developers may create roles only with a particular boundary, enforced by a condition on iam:PermissionsBoundary.
  2. A deny statement prevents removing the boundary or editing the boundary policy.
  3. As a result, developers cannot create a role more powerful than the boundary allows, so there is no privilege escalation.
Select all that apply

Safe delegation with boundaries

Exam skills 4.2.3

Pick the statements that make delegated role creation safe.

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

Session policies

Session policies are passed when assuming a role or federating, and restrict that single session, for example limiting a shared role to one S3 prefix per user. The effective permissions are the intersection of the role's policies and the session policy.

How the limits combine

Four policy types set maximum permissions, each at a different scope. An SCP limits what principals in member accounts can do, and an RCP limits what can be done to resources in member accounts, including by principals from outside the organisation. A permissions boundary limits one user or role, which lets administrators delegate the creation of roles without allowing those roles to exceed the boundary. A session policy limits one session when a role is assumed. The effective permissions are the intersection: an action must be allowed by every applicable limit. The following table summarises the scopes.

PolicyLimits
SCPPrincipals in member accounts
RCPResources in member accounts
Permissions boundaryOne user or role
Session policyOne session

None of these grant permissions; an identity or resource policy must still allow the action.

The following diagram shows the two statements that let developers create roles only within a permissions boundary, and the effective permissions that result.

Delegating role creation with a permissions boundary. Developers may create app-* roles only with DeveloperBoundary attached and cannot remove or edit it. Whatever policies they attach, a role's effective permissions are the overlap with the boundary, so no role is more powerful than allowed.
The circles are not to scale.
Match the pairs

What each limit applies to

Exam skills 4.2.3 · 6.1.3

Match each limiting policy with what it limits.

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

Letting developers create roles safely

Developers must create roles for their Lambda functions without being able to create a role more powerful than themselves. Their policy allows role creation only with the developer boundary attached, and denies removing it:

{
  "Version": "2012-10-17",
  "Statement": [
    { "Sid": "CreateRolesWithBoundary", "Effect": "Allow",
      "Action": ["iam:CreateRole", "iam:PutRolePolicy", "iam:AttachRolePolicy"],
      "Resource": "arn:aws:iam::111111111111:role/app-*",
      "Condition": { "StringEquals": {
        "iam:PermissionsBoundary": "arn:aws:iam::111111111111:policy/DeveloperBoundary" } } },
    { "Sid": "NoBoundaryRemovalOrEdit", "Effect": "Deny",
      "Action": ["iam:DeleteRolePermissionsBoundary", "iam:CreatePolicyVersion", "iam:DeletePolicy"],
      "Resource": ["arn:aws:iam::111111111111:role/*",
                   "arn:aws:iam::111111111111:policy/DeveloperBoundary"] }
  ]
}

Whatever policies a developer attaches to an app- role, its effective permissions never exceed the boundary. For one-off narrowing, such as a support session limited to one customer's data, a session policy passed on AssumeRole restricts that session alone.

Check yourself

How can one assumed-role session be restricted further than the role?

Show answer

With a session policy passed when the role is assumed.

Exam Tips

Remember for the exam

  • To let developers create roles without escalating privileges, require a permissions boundary on CreateRole.
  • Deny removing boundaries and editing the boundary policy.
  • To restrict one assumed session further, use a session policy.
  • Effective permissions are the intersection of identity policies and every applicable limit.
  • Boundaries, session policies, SCPs and RCPs never grant permissions.