IAM Abuse and Privilege Escalation
In the cloud, IAM (Identity and Access Management) is the system that decides who can do what. It’s, in effect, the new perimeter: compromising an identity with the right permissions equals being an administrator. Cloud privilege escalation rarely exploits a bug: it chains legitimate, misassigned permissions to go from a limited identity to full control of the account. It’s the heart of cloud pentesting.
Threat model
Section titled “Threat model”IAM policies are complex and it’s easy to over-grant. Certain permissions, however innocuous they look, let you grant yourself more privileges: create users, attach policies, assume roles, modify functions that run with privileged roles. The attacker controlling an identity hunts for those “escalation permissions” and chains them up to admin. There’s no exploit: it’s all legitimate API calls, which makes them stealthy if logging isn’t audited.
flowchart LR
A[Limited identity] --> B{Escalation permission?}
B -->|iam:AttachUserPolicy| C[Attach AdministratorAccess]
B -->|iam:PassRole + RunInstances| D[EC2 with admin role -> IMDS]
B -->|iam:PassRole + CreateFunction| E[Lambda as admin role]
B -->|sts:AssumeRole| F[Assume privileged role]
C --> G[Account admin]
D --> G
E --> G
F --> G
Theory: enumerate what you can do (first)
Section titled “Theory: enumerate what you can do (first)”Before escalating, you must know exactly what the current identity allows:
# AWS: who am I and what permissions do I have?aws sts get-caller-identityaws iam get-account-authorization-details # if allowedenumerate-iam --access-key AKIA... --secret-key ... # brute-force of permissions# escalation-path mapping tools# Pacu (iam__privesc_scan), cloudsplaining, PMapperRed Team
Section titled “Red Team”Escalation permissions in AWS (the classics)
Section titled “Escalation permissions in AWS (the classics)”Rhino Security Labs catalogued ~20 paths. The most common:
iam:CreateAccessKey→ create a key for ANOTHER user (admin).iam:AttachUserPolicy/iam:PutUserPolicy→ attachAdministratorAccessto yourself.iam:CreatePolicyVersion→ rewrite a policy you’re bound to.iam:PassRole+ec2:RunInstances→ launch EC2 with an admin role and use its IMDS.iam:PassRole+lambda:CreateFunction→ function running as an admin role.sts:AssumeRole→ assume a more privileged role (if the trust policy allows).iam:UpdateAssumeRolePolicy→ modify who can assume a role.
Direct example: with iam:AttachUserPolicy on yourself, you attach AdministratorAccess → admin.
aws iam attach-user-policy \ --user-name me \ --policy-arn arn:aws:iam::aws:policy/AdministratorAccessPassRole: the most dangerous permission
Section titled “PassRole: the most dangerous permission”iam:PassRole lets you “pass” a role to a service (EC2, Lambda, ECS…). If you can pass an admin role to a function or instance you control, you execute code as that role. A policy granting PassRole without scoping the resource is a door to escalation:
{ "Version": "2012-10-17", "Statement": [ { "Effect": "Allow", "Action": ["iam:PassRole", "lambda:CreateFunction", "lambda:InvokeFunction"], "Resource": "*" } ]}With that you create a Lambda running as an admin role, or launch an EC2 and steal its credentials via IMDS (see Metadata Service (IMDS)).
Azure and GCP (equivalents)
Section titled “Azure and GCP (equivalents)”- Azure: roles with
Microsoft.Authorization/roleAssignments/write→ assign yourself Owner; abuse of Managed Identities, Automation Accounts, and app consent. Tools: AzureHound, ROADtools, MicroBurst (see Azure Pentesting). - GCP:
iam.serviceAccounts.getAccessToken/actAs→ impersonate a privileged SA;setIamPolicy→ grant yourself roles; abuse of Cloud Functions/Compute with an admin SA (see GCP Pentesting).
Methodology
Section titled “Methodology”- Enumerate identity and permissions (
sts/az/gcloud+enumerate-iam). - Hunt for escalation permissions (Pacu / PMapper / cloudsplaining).
- Identify the shortest path to admin.
- Execute the escalation (attach policy, pass role, assume role, impersonate).
- Confirm privileges and document impact.
Blue Team
Section titled “Blue Team”- Real least privilege: no
*:*, review dangerous permissions (iam:*, broadPassRole/AssumeRole). - Access analyzers: AWS IAM Access Analyzer, cloudsplaining, PMapper — detect escalation paths before the attacker.
- Separate service roles and scope trust policies (who can
AssumeRole/actAs). - Permission boundaries and SCPs (AWS) / conditions (Azure/GCP) to cap the maximum scope.
- Logging (CloudTrail) and alerts on sensitive IAM actions (
AttachPolicy,CreateAccessKey,PassRole,UpdateAssumeRolePolicy).
Checklist
Section titled “Checklist”- Enumerate identity and permissions (
sts/az/gcloud+ enumerate-iam) - Hunt for escalation permissions (Pacu/PMapper/cloudsplaining)
-
AttachUserPolicy/PutUserPolicy→ AdministratorAccess -
PassRole+RunInstances/CreateFunction→ admin role -
AssumeRole/UpdateAssumeRolePolicy - Azure:
roleAssignments/write→ Owner; Managed Identities (Azure Pentesting) - GCP:
actAs/getAccessToken→ impersonate admin SA (GCP Pentesting) - Confirm privileges and map the path