
AWS IAM privilege escalation happens when a principal holds a permission that lets it grant itself, or run code as, a more privileged identity. Those paths are written in policy JSON, so you can enumerate them before an attacker does. Most real findings come from fewer than a dozen primitives.
The short answer
- AWS IAM privilege escalation is a principal using a permission it holds to grant itself, or execute code as, a more privileged identity.
- Check first: CreatePolicyVersion, the Attach/Put/CreateAccessKey family, UpdateAssumeRolePolicy, and iam:PassRole paired with Lambda, EC2, Glue or CloudFormation.
- PassRole has no CloudTrail event of its own; alert on the downstream service call and inspect requestParameters.
- Graph paths with PMapper, gate changes in CI, require iam:PassedToService, and deny policy-version mutation with an SCP.
Key takeaways
- AWS IAM privilege escalation is composition: a small set of primitives chained one or two hops deep, and the paths are visible in policy JSON.
- iam:PassRole is inert alone. It needs a consuming service action and a trust policy that admits that service. Constrain it with iam:PassedToService.
- iam:CreatePolicyVersion with set-as-default does not need SetDefaultPolicyVersion. Deny both with an SCP except for a break-glass role.
- CloudTrail has no PassRole event. The role shows up on the downstream API, and Lambda invokes are data events that management-only trails miss.
- PMapper finds multi-hop paths that Cloudsplaining-style single-policy lints under-report. Agent roles reintroduce the same primitives in front of untrusted text.
What is AWS IAM privilege escalation and how does it actually work?
AWS IAM privilege escalation is any action that widens the permissions a principal can effectively use. There is no kernel to exploit and no local admin group on a host. Identity is the perimeter, so every escalation is an authorization write or an authorization borrow.
AWS evaluates a request against the intersection of identity-based policies, resource-based policies, permissions boundaries, session policies and service control policies (SCPs). An attacker escalates by changing one of those inputs. In practice that is one of three moves:
- Write a policy: create a new policy version, attach a managed policy, or put an inline policy on yourself or a role you occupy.
- Swap identity: mint keys for a more privileged user, set its console password, or rewrite a role trust policy so you can assume it.
- Borrow execution: make Lambda, EC2, Glue or CloudFormation run attacker-chosen code under a stronger role.
An escalation path is a permission you hold plus a resource that executes as something stronger. Real chains are usually two hops: a developer role that can update one Lambda function, whose execution role can attach policies. Single-permission linters miss those chains. Graph tools find them.
Pentesters test the one-shot primitives first, because each can turn a foothold into administrator access in a single API call. Rhino Security Labs catalogued 21 methods; the community list now exceeds that. On every engagement we check these:
iam:CreatePolicyVersionandiam:SetDefaultPolicyVersionon a policy attached to you.iam:AttachUserPolicy,iam:AttachGroupPolicy,iam:AttachRolePolicy: attach AdministratorAccess to yourself or to a role you can assume.iam:PutUserPolicy,iam:PutGroupPolicy,iam:PutRolePolicy: inject an inline policy withAction: *.iam:AddUserToGroup: join an admin group.iam:CreateAccessKey: mint a key for a more privileged IAM user.iam:CreateLoginProfileoriam:UpdateLoginProfile: set another user’s console password.iam:UpdateAssumeRolePolicy: add yourself to a role trust policy, assume it, then revert the change.iam:DeleteUserPermissionsBoundaryandiam:DeleteRolePermissionsBoundary: remove the control that was containing you.
None of these needs a vulnerability. They are grants someone wrote, often on a CI role or an automation user that needed to manage IAM. MFA on the root account does nothing here. iam:CreateAccessKey against an admin IAM user walks straight past it.

How does iam:PassRole enable privilege escalation?
iam:PassRole enables privilege escalation only when it is combined with a service action that runs code as the passed role. On its own it is inert. It is the check AWS performs when a service API accepts a RoleArn or an instance profile, not an action that does anything by itself.
A PassRole escalation needs three conditions at once:
iam:PassRoleon the target role ARN.- Permission to call the consuming action, such as
lambda:CreateFunctionorec2:RunInstances. - A trust policy on the target role that admits that service principal, for example
lambda.amazonaws.com.
The common finding is iam:PassRole on Resource: *. That lets the holder pass any role in the account, including administrator roles, to any service they can also create. The fix is iam:PassedToService: allow PassRole only on a named path such as role/app-*, and only when the receiving service is the one the workload uses. If you fix one thing from this article, fix that.
Lambda, Glue and CloudFormation become pivots because each accepts a role and then executes attacker-controlled logic under it. The shape is the same. Time to execution and the CloudTrail footprint change.
- Lambda:
iam:PassRolepluslambda:CreateFunctionandlambda:InvokeFunctionruns code as the passed role.lambda:UpdateFunctionCodeon an existing privileged function needs no PassRole.lambda:UpdateFunctionConfigurationcan swap the role on a function you already control. - Glue:
glue:CreateDevEndpointwith a role and an attacker SSH key historically gave a shell as that role. AWS has been moving customers off classic development endpoints, so check whether any classic dev endpoints still exist in the account. The path that remains isglue:CreateJobplusglue:StartJobRunwith an attacker-supplied script. - CloudFormation:
cloudformation:CreateStackwith aRoleARNprovisions whatever that role can, including a Lambda-backed custom resource.UpdateStackworks against stacks that already exist. - EC2:
ec2:RunInstanceswith an instance profile, then read credentials from the instance metadata service. Capital One in 2019 is the reference case: the escalation was not policy logic, it was an over-privileged role whose credentials were reachable via an SSRF.
| Service | Actions besides PassRole | Time to code exec | Main CloudTrail signal |
|---|---|---|---|
| Lambda | CreateFunction, InvokeFunction | Seconds | CreateFunction; Invoke only if data events are on |
| EC2 | RunInstances, then SSH, SSM or user-data | Minutes | RunInstances with iamInstanceProfile |
| Glue | CreateJob, StartJobRun | Minutes | CreateJob, StartJobRun |
| CloudFormation | CreateStack | Minutes | CreateStack with roleARN |
Data Pipeline and Step Functions follow the same shape (Data Pipeline is deprecated; check for legacy usage). If a principal can pass a strong role to any of these, treat it as already holding that role.

How does IAM policy version abuse work?
IAM policy version abuse rewrites a customer managed policy that is already attached to you, so the new permissions land without an attach call. There are two variants, and they fail closed in different ways.
Path A, CreatePolicyVersion. With iam:CreatePolicyVersion, an attacker writes a version containing Action: * on Resource: * and sets it as the default (--set-as-default). It is active immediately for every principal the policy is attached to. The call does not require iam:SetDefaultPolicyVersion. Teams often restrict SetDefault and leave CreatePolicyVersion open.
Path B, rollback. With only iam:SetDefaultPolicyVersion, the attacker lists old versions and flips the default to a more permissive one. Rhino Security Labs’ CloudGoat scenario iam_privesc_by_rollback is the standard lab. A managed policy holds at most five versions, so a loose version may already be pruned. The rollback is opportunistic, and it is cheap to check.
| Primitive | What it needs | What it leaves behind | Detectability |
|---|---|---|---|
| CreatePolicyVersion with set-as-default | One permission | A new policy version | CreatePolicyVersion, straightforward to alert on |
| SetDefaultPolicyVersion | One permission, plus an older permissive version | No new document; the default pointer moves | SetDefaultPolicyVersion, easy to miss in review |
An SCP that denies both version calls for every principal except a break-glass role removes the class. It is close to free, and you can prove it by attempting the call from a non-break-glass role.
What is a cross-account IAM trust misconfiguration?
Identity-policy scanners also miss resource-policy writes. s3:PutBucketPolicy, kms:PutKeyPolicy, secretsmanager:PutResourcePolicy, lambda:AddPermission, ecr:SetRepositoryPolicy, and the SQS and SNS attribute setters can grant access without an IAM call. The subject is the resource, not the identity, so identity-only graphs stay quiet. A KMS key policy that adds an external account is exfiltration and persistence in one call. Scope those actions with the Attach and Put family.
A cross-account IAM trust misconfiguration is a role trust policy that admits more principals than its owner intended. The usual entry is arn:aws:iam::111122223333:root. That principal means the account, not the root user. Any principal in that account whose identity policy allows sts:AssumeRole on the role can assume it.
Combine account-root trust with identity policies that grant sts:AssumeRole on Resource: *, and movement reaches every role that trusts the account. “Only roles that trust me can be assumed” is true. It does not help when many roles trust the whole account.
- Third-party roles: require
sts:ExternalId. - Same-organization access: require
aws:PrincipalOrgID. - Service-triggered resource policies: require
aws:SourceArnandaws:SourceAccount. - GitHub Actions OIDC: pin
subtorepo:org/repo:ref:refs/heads/main. Arepo:org/*wildcard lets any repository in the org, and any pull-request workflow that can mint a token, assume the role. - EKS IRSA: pin
system:serviceaccount:namespace:name. Do not use a namespace wildcard.
When chaining hops, a role-chained session is capped at one hour, or the remainder of the source session, whichever is shorter. The target role’s maximum session duration does not lengthen that chain.
How do you find IAM privilege escalation paths before an attacker does?
Build the graph of who can become whom, then fail builds that add new edges. Every primitive above is declarative, so you can find it statically, without executing the path in production.
| Tool | Approach | Best at | Blind spot |
|---|---|---|---|
| PMapper (NCC Group) | Graph of principals and roles | Multi-hop “who can escalate” queries | Needs a fresh account snapshot |
| Cloudsplaining (Salesforce) | Static policy lint | Flagging escalation primitives per policy | Single hop; no chaining |
| Pacu (Rhino Security Labs) | Exploitation framework, iam__privesc_scan |
Proving a path from a given foothold | Issues real API calls; noisy |
| IAM Access Analyzer | Managed findings and policy checks | External access, unused access, CI gating | Not a full escalation-path model |
A workable program: run PMapper against each account weekly, run Cloudsplaining on every policy change, and gate infrastructure-as-code merges with Access Analyzer custom policy checks such as CheckNoNewAccess. iam:GetAccountAuthorizationDetails dumps the account and is loud. Alert on it outside the scanner role.
CloudTrail does not record a standalone iam:PassRole event. The passed role appears only inside requestParameters of the downstream call: the role field on CreateFunction, or the instance-profile block on RunInstances. Confirm the field name per service. Newer integrations do not share one parameter name.
Alert on two groups. On the IAM control plane: CreatePolicyVersion, SetDefaultPolicyVersion, the Attach and Put families, CreateAccessKey, CreateLoginProfile, UpdateLoginProfile, AddUserToGroup, UpdateAssumeRolePolicy, CreateRole, and both Delete*PermissionsBoundary calls. On service calls that imply PassRole: RunInstances, CreateFunction, UpdateFunctionCode, UpdateFunctionConfiguration, CreateJob, StartJobRun, CreateStack, and CreateStateMachine. Join the role in the request to your list of privileged roles.
sts:AssumeRole is a management event logged by default. lambda:InvokeFunction is a data event. A trail that keeps only management events sees the function created and never sees it run. GuardDuty can surface anomalous IAM activity, including odd persistence and credential use from outside AWS. It is not the primary control. A patient operator on a role that already does IAM work can stay under those findings.
How do permissions boundaries and SCPs stop IAM privilege escalation?
Permissions boundaries and SCPs stop escalation by capping what any grant can reach. Neither one grants access. An SCP filters what principals in an account may do. A boundary filters one principal. A permissive SCP plus an empty identity policy is still no access.
Ordered by how much risk each removes per hour of work:
- SCPs denying
iam:CreatePolicyVersion,iam:SetDefaultPolicyVersionand broadiam:PassRole, except for a break-glass role. iam:PassedToServiceon every PassRole grant.- A required permissions boundary on any role a principal can create or modify, enforced by a condition on
iam:CreateRole, plus a deny on deleting that boundary. Otherwise a compromised principal mints an unbounded role. - Attach and Put families restricted to break-glass.
- Access Analyzer external-access findings triaged on a schedule.
- Policy-as-code checks in CI before merge.
Where they fail: SCPs do not apply to the management account, and boundaries do nothing if the attacker can remove them or create a role without one. A principal with iam:* can re-grant almost anything you take away, so the real control is which principals hold iam:* in the first place.
The same graph now shows up on AI agents. An agent with an AWS role turns prompt injection into an authorization primitive: the model chooses the API call, and the role supplies the authority. That is the PassRole pattern with a language model in the middle.
Bedrock agent service roles, Lambda-backed action groups, and MCP servers on ECS or Lambda often share one broad role across every tool. If any tool can reach IAM, Lambda or S3 policy writes, a document, ticket or page the agent reads can steer it there. The tool schema is not a security boundary. The role is. Scope roles per tool, keep the primitives above off every agent role, and test the injection path end to end.

FAQ
What is AWS IAM privilege escalation?
It is when a principal uses a permission it already holds to grant itself, or to run code as, a more privileged identity. Typical paths are policy-version swaps, the Attach and Put families, access-key or login-profile creation, trust-policy edits, and iam:PassRole combined with Lambda, EC2, Glue or CloudFormation.
Is iam:PassRole dangerous on its own?
No. Escalation needs three things together: iam:PassRole on the target role, permission to call the service that accepts that role, and a trust policy that admits the service principal. CloudTrail does not log PassRole as its own event. Look in requestParameters on the downstream call.
Does CreatePolicyVersion need SetDefaultPolicyVersion?
No. CreatePolicyVersion with set-as-default writes a new version and makes it active without SetDefaultPolicyVersion. SetDefaultPolicyVersion alone is a rollback: it can only point at one of the five stored versions, and a permissive version may already have been deleted.
Can GuardDuty detect AWS IAM privilege escalation?
It can flag anomalous IAM behavior and some credential misuse, which catches loud, fast escalation from unusual principals. It should not be the primary control. Alert on the IAM mutation APIs and on service calls that pass a privileged role. A role that already manages IAM every day can stay quiet.
How does this apply to Bedrock agents and MCP servers?
If the agent role can call the primitives in this article, untrusted text the agent reads can drive those calls. Bedrock action groups and MCP tools often share one role. Split roles per tool, deny policy-version mutation and broad PassRole on every agent role, and retest with a poisoned document.
Where do permissions boundaries and SCPs fail?
SCPs do not apply to the management account. A boundary does nothing if the principal can delete it or create a role that has none. iam:* on a workload principal can rebuild the grants you just removed. Limit who holds iam:* before you tune the other controls.
If you want someone to walk your IAM graph the way an attacker would, including multi-hop PassRole chains, cross-account trust and agent roles, our AWS penetration testing engagements start there.