1. Resources
  2. Identity Threats
  3. AWS

AWS IAM Policy Attachment Privilege Escalation (Attach and Put Policy)

Also known as: AttachUserPolicy privilege escalation, AttachRolePolicy privilege escalation, PutUserPolicy privilege escalation, PutRolePolicy inline policy escalation, AdministratorAccess self-attachment

A principal that can attach a managed policy or write an inline policy on a user, group or role it controls grants itself any permission, including AdministratorAccess, in a single IAM call.

Platform
AWS
Impact
Critical
Last updated
Attack difficulty
Low
Detection difficulty
Low
Privileges required: Specific rights or roles
One of iam:AttachUserPolicy, AttachGroupPolicy, AttachRolePolicy, PutUserPolicy, PutGroupPolicy or PutRolePolicy on the caller's own user, a group it is in, or a role it can assume.
What the attacker gains
Any permission the attacker chooses for an identity it controls: AdministratorAccess through a managed policy, or an arbitrary inline document. Full control of the account.

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* or iam:* on Resource: "*" 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:PolicyARN condition 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 AdministratorAccess in requestParameters.policyArn do not fire. The PutUserPolicy, PutGroupPolicy and PutRolePolicy events still carry the policy name and the document in requestParameters.policyName and requestParameters.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 as iam:CreateAccessKey or sts:AssumeRole. This defeats wildcard matching, not the event.
  • A service-specific managed policy. Attaching IAMFullAccess or a FullAccess policy for one service draws less attention than AdministratorAccess and 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, DeleteUserPolicy and 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, groupName or roleName, 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.policyArn is AdministratorAccess, IAMFullAccess, PowerUserAccess or a service FullAccess policy. 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 and sts: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.arn names the role in requestParameters.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 AccessDenied on 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:PolicyARN condition that allows only the approved policy ARNs or a team path, as the AWS IAM User Guide shows. An attacker then cannot attach AdministratorAccess even where it may attach policies.
  • Limit the targets. Scope the Resource of 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:PermissionsBoundary condition 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*Policy to deployment roles, or deny it with a service control policy where inline policies are not used.
  • Remove wildcard IAM grants. iam:* and iam: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

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.

Does this attack work in your environment?

Forestall maps every identity and the attack paths between them across Active Directory, Entra ID and cloud, read-only and agentless.