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

Permissions boundaries and iam:PassRole

Boundary versus SCP versus session policy, safe delegation of IAM administration, preventing privilege escalation through PassRole, and service-linked roles.

Exam tasks: 4.2 (Skills 4.2.1 authorization controls for human, application and system access, 4.2.3 least-privilege policies with permission boundaries)

The decision: how do you let a team create and attach IAM roles for their own workloads without letting them create a role more powerful than themselves?

A permissions boundary is a managed policy set on one user or role. It caps what identity-based policies can grant. It grants nothing. Effective permissions are the intersection of identity policy and boundary.

capsgrantscapsAssumeRolecapsSCP on OUIdentity policyBoundaryRoleSession policyRole session
Three independent caps narrow the same identity policy. Each one only removes permissions.

What a boundary is

  • A managed policy set as the permissions boundary of a user or role. One boundary per entity.
  • Effective permissions are the intersection of the identity policies and the boundary. The boundary never grants anything by itself.
  • It doesn't limit resource-based policies that name the user or role session directly (same account), and it doesn't apply to groups.
  • An explicit deny in the boundary works like any other explicit deny.

Boundary, SCP and session policy

SCPPermissions boundarySession policy
Set onOrg root, OU, accountOne IAM user or roleOne session at creation
Applies toAll principals in member accounts, including root userThat user or role onlyThat session only
Set byOrganizations adminIAM adminCaller of AssumeRole or GetFederationToken
Grants permissionsNoNoNo
SkipsManagement account, service-linked rolesResource policy naming the user ARN or session ARNResource policy naming the session ARN
Typical useRegion lock, deny leaving the org, protect security toolingLet developers create roles without escalatingNarrow a broker-issued session per customer

Exam trap

A permissions boundary cannot be applied to a group or a service-linked role. Attaching AdministratorAccess to a bounded user still yields only the boundary actions. Removing the boundary needs iam:DeleteUserPermissionsBoundary, so deny that action to delegated admins.

Delegating role creation safely

The pattern: developers in account 7788 may create roles for their Lambda functions, but every role they create must carry the dev-workload-boundary policy, and they can't remove or weaken it.

AWS accountattachediam:CreateRoleiam:PermissionsBoundaryDeveloperCreateRole onlywith boundaryNew roleApprovedboundary
The condition on iam:PermissionsBoundary forces every new role to carry the boundary, so a role cannot exceed it.

Write the boundary (dev-workload-boundary): the most any workload role may ever do, for example the app's data services in two Regions, and nothing in IAM, Organizations or the security tooling.

Require it on create. Allow iam:CreateRole and iam:PutRolePermissionsBoundary only when iam:PermissionsBoundary equals the boundary's ARN.

Protect it. Deny iam:DeleteRolePermissionsBoundary, and deny iam:CreatePolicyVersion, iam:SetDefaultPolicyVersion and iam:DeletePolicy on the boundary policy itself.

Limit the names. Restrict role and policy actions to a path or prefix such as role/app/*, so developers can't edit the platform's own roles.

Apply the boundary to the developers too, so they can't simply attach AdministratorAccess to themselves.

{
  "Sid": "CreateRolesOnlyWithBoundary",
  "Effect": "Allow",
  "Action": ["iam:CreateRole", "iam:PutRolePermissionsBoundary", "iam:AttachRolePolicy", "iam:PutRolePolicy"],
  "Resource": "arn:aws:iam::778899001122:role/app/*",
  "Condition": {
    "StringEquals": {
      "iam:PermissionsBoundary": "arn:aws:iam::778899001122:policy/dev-workload-boundary"
    }
  }
}

Let users manage only their own credentials with ${aws:username} in the resource ARN.

Exam signal

"Allow developers to create IAM roles, but prevent privilege escalation" is the permissions boundary question. The answer always includes the iam:PermissionsBoundary condition on role creation plus a deny on removing or editing the boundary. "No account in the organization may ever do X" is an SCP.

Boundary without protection

A boundary that developers can detach (DeleteRolePermissionsBoundary) or rewrite (CreatePolicyVersion on the boundary policy) is decoration. Answers that set the boundary but don't lock those actions miss the point.

IAM paths

  • Paths such as /app/ or /platform/security/ are part of the ARN, so policies can scope actions to arn:aws:iam::*:role/app/*.
  • They're organisational only: a path grants nothing and can't be changed on an existing role. Use them with boundaries to separate what teams can touch.

iam:PassRole

iam:PassRole is a permission, not an API call. It lets a principal attach a role to an AWS service resource such as a Lambda function, EC2 instance profile or ECS task. The service then assumes the role later. Without a scoped PassRole, a user with limited rights can create a Lambda function using a powerful execution role and act through it.

createPassRoleassumesfull accessLimited userNew functionAdmin roleData bucket
Escalation path when PassRole is granted on Resource star. Scoping the role ARN closes it.
ControlDetail
Scope the ResourceList exact role ARNs or a name prefix such as role/EC2-roles-for-XYZ-*.
Add iam:PassedToServiceRestrict a role to one service principal, such as ec2.amazonaws.com.
Same account onlyYou cannot pass a role from account A to a service in account B. Create a role in B that trusts A, then pass that.
Do not use tagsControlling PassRole with ResourceTag conditions is unreliable.
Pair with iam:GetRoleConsoles need it to show the role.
Service-linked rolesPassRole is needed only if you name the SLR explicitly.
AuditingNo CloudTrail event for PassRole. Read the event that created the resource, such as CreateFunction.

Exam trap

Access Analyzer policy generation also omits iam:PassRole because CloudTrail does not record it. Add it by hand, scoped to the exact role.

  • iam:AssociatedResourceArn narrows which resource the role can be attached to, for services that support it.
{
  "Sid": "PassAppRolesToLambdaOnly",
  "Effect": "Allow",
  "Resource": "arn:aws:iam::778899001122:role/app/*",
  "Action": "iam:PassRole",
  "Condition": { "StringEquals": { "iam:PassedToService": "lambda.amazonaws.com" } }
}

The role trust policy isn't enough

A role whose trust policy allows ec2.amazonaws.com still can't be attached by a user who lacks iam:PassRole on it. And the reverse: PassRole doesn't help if the trust policy doesn't trust the service. Both must line up.

Service-linked roles

  • Created and owned by an AWS service (AWSServiceRoleFor...), with a trust policy and permissions you can't edit. Some are created automatically when you first use a feature.
  • SCPs and RCPs don't restrict them. That's by design, so services keep working, and it means you can't use an SCP to stop, say, a service writing to its own resources with its linked role.
  • Creating one needs iam:CreateServiceLinkedRole. You can deny that in an SCP to block a service being set up, which is an indirect control.
  • Deleting one usually requires cleaning up the service's resources first.
Service roleService-linked role
Who defines permissionsYouThe service
Can you edit itYesOnly the description
Needs PassRoleYes, when you attach itNo
Limited by SCP/RCPYesNo

Scenarios

Scenario · choose 2
Platform engineers at a logistics company let application teams create IAM roles for their ECS tasks. An audit finds that one team created a role with AdministratorAccess and used it from a task. The company wants teams to keep creating their own roles. Which combination prevents this? (Choose TWO.)
Scenario
A developer has ec2:RunInstances and iam:PassRole on arn:aws:iam::*:role/*. A security review flags this as a privilege-escalation risk. What is the most precise fix?
Scenario
A company attaches an SCP denying all actions outside two approved Regions. A few weeks later, CloudTrail shows actions in a third Region performed by a role named AWSServiceRoleForConfig. Why wasn't it blocked?

Further reading

On this page