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.
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
| SCP | Permissions boundary | Session policy | |
|---|---|---|---|
| Set on | Org root, OU, account | One IAM user or role | One session at creation |
| Applies to | All principals in member accounts, including root user | That user or role only | That session only |
| Set by | Organizations admin | IAM admin | Caller of AssumeRole or GetFederationToken |
| Grants permissions | No | No | No |
| Skips | Management account, service-linked roles | Resource policy naming the user ARN or session ARN | Resource policy naming the session ARN |
| Typical use | Region lock, deny leaving the org, protect security tooling | Let developers create roles without escalating | Narrow 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.
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 toarn: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.
| Control | Detail |
|---|---|
Scope the Resource | List exact role ARNs or a name prefix such as role/EC2-roles-for-XYZ-*. |
Add iam:PassedToService | Restrict a role to one service principal, such as ec2.amazonaws.com. |
| Same account only | You 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 tags | Controlling PassRole with ResourceTag conditions is unreliable. |
Pair with iam:GetRole | Consoles need it to show the role. |
| Service-linked roles | PassRole is needed only if you name the SLR explicitly. |
| Auditing | No 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:AssociatedResourceArnnarrows 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 role | Service-linked role | |
|---|---|---|
| Who defines permissions | You | The service |
| Can you edit it | Yes | Only the description |
| Needs PassRole | Yes, when you attach it | No |
| Limited by SCP/RCP | Yes | No |
Scenarios
Requiring the boundary at creation caps any new role, and locking the boundary stops teams removing or rewriting it. Denying CreateRole outright breaks the requirement that teams keep creating roles. MFA proves who the caller is, not what they may grant. Policy generation helps trim roles later but doesn't prevent an over-privileged one.
The risk is passing any role, including admin roles, to an instance. Limiting PassRole to the app path and to EC2 removes that. Instance profiles still need PassRole to attach, so removing it breaks launches. Boundaries on instance roles don't stop the developer passing a role that has no boundary, and the developer isn't calling AssumeRole at all, the EC2 service is.
Service-linked roles are exempt from SCPs, so services can keep doing the work you enabled. The management account detail is irrelevant because this role is in a member account, SCPs do apply to roles, and there's no such aws:SourceRegion key for this purpose. To stop it, disable the service or its multi-Region recording.
Related
- Policy evaluation logic
- Organizations SCPs, RCPs and declarative policies
- Access Analyzer, policy simulator and least privilege tools
- IAM identities and policy types
- Instance profiles and role switching
Further reading
Amazon Verified Permissions
Externalized, fine-grained authorization for custom applications using Cedar policies, and how it differs from IAM.
Organizations SCPs, RCPs and declarative policies
Service control policies, resource control policies, declarative policies and AI opt-out policies. What each guards, what it cannot touch, how they combine and how they build data perimeters.