1. Resources
  2. Identity Threats
  3. AWS

AWS iam:CreateAccessKey Privilege Escalation and Persistence

Also known as: CreateAccessKey privilege escalation, IAM access key backdoor, Backdoor IAM user, Second access key persistence

A principal with iam:CreateAccessKey issues a long-lived access key for another IAM user, takes over that user's permissions and keeps access that survives password resets and session revocation.

Platform
AWS
Impact
Critical
Last updated
Attack difficulty
Low
Detection difficulty
Medium
Privileges required: Specific rights or roles
iam:CreateAccessKey on another IAM user that has fewer than two access keys. The backdoor user variant needs iam:CreateUser and a way to grant the new user permissions.
What the attacker gains
A long-lived credential for the target IAM user, with every permission that user holds, valid until the key is deactivated or deleted.
Threat groups
Storm-0501APT28APT29APT33APT38APT5HAFNIUMKe3changLAPSUS$NIMBUS MANTICOREScattered SpiderShinyHuntersTeamPCPVOID MANTICOREGroups that MITRE ATT&CK records using T1098.001, T1136.003, T1078.004.

How it works

An IAM user authenticates API requests with an access key: a key id and a secret access key. A user can hold up to two keys at a time, which is what makes rotation without downtime possible. The CreateAccessKey API issues a new key for the user named in the request and returns the secret in the response. That response is the only time AWS ever discloses the secret.

The permission that controls the call, iam:CreateAccessKey, is evaluated against the target user as a resource. A policy that allows it on Resource: "*", or on a path that includes other users, lets the caller mint a credential for someone else. The key then authenticates as that user. No password, MFA prompt or approval from the user is involved, and the user is not notified.

This gives two outcomes from one call:

  • Privilege escalation. The caller creates a key for a user with more permissions than its own, typically an administrator or a deployment user, and acts as that user.
  • Persistence. The caller adds a second key to a user it has already compromised, or to any user whose existing key is in normal use. The extra key is a long-lived secret: it has no expiry and keeps working after passwords are reset and role sessions are revoked.

A third variant creates the identity as well. With iam:CreateUser the attacker adds a new backdoor user, gives it a key, and attaches or inherits permissions through a policy or a group. The name is usually chosen to look like a service or a colleague.

Related operations change the state of existing keys. UpdateAccessKey switches a key between Active and Inactive, so a key that responders disabled can be turned back on by anyone who still holds iam:UpdateAccessKey. DeleteAccessKey frees one of the two slots.

Prerequisites

  • Valid credentials in the target account, for an IAM user or a role session.
  • iam:CreateAccessKey allowed on the target user. When the request names no user, IAM applies it to the user whose key signed the request, so creating a second key for oneself needs only the permission on one's own user.
  • The target user must hold fewer than two access keys. Otherwise the attacker also needs iam:DeleteAccessKey on that user.
  • For the backdoor user variant: iam:CreateUser, plus one of iam:AttachUserPolicy, iam:PutUserPolicy or iam:AddUserToGroup to give the new user permissions.
  • Useful but not required: iam:ListUsers, iam:ListAccessKeys and iam:ListAttachedUserPolicies to pick a target.

Attack steps

For authorized security testing and lab use only. Run these steps against systems you own or have written permission to assess.

1. Choose a target user

# Users in the account
aws iam list-users

# Managed policies attached to a candidate, and how many keys it already has
aws iam list-attached-user-policies --user-name deploy-admin
aws iam list-access-keys --user-name deploy-admin

A user with an administrator policy and one key, or no key at all, is the ideal target. Pacu's iam__privesc_scan module reports this path when the current identity may call CreateAccessKey on other users.

2. Create the key

aws iam create-access-key --user-name deploy-admin

The response contains AccessKeyId and SecretAccessKey. Pacu's iam__backdoor_users_keys module does the same for one or many users in a single run:

Pacu > run iam__backdoor_users_keys

3. Authenticate as the target user

export AWS_ACCESS_KEY_ID=<access-key-id-from-step-2>
export AWS_SECRET_ACCESS_KEY=<secret-access-key-from-step-2>
aws sts get-caller-identity

get-caller-identity returns the ARN of the target user, which confirms the takeover.

Backdoor user variant

aws iam create-user --user-name svc-backup
aws iam attach-user-policy --user-name svc-backup \
    --policy-arn arn:aws:iam::aws:policy/AdministratorAccess
aws iam create-access-key --user-name svc-backup

Reactivating a disabled key

If responders set a stolen key to Inactive instead of deleting it, and the attacker still has a principal with iam:UpdateAccessKey:

aws iam update-access-key --user-name deploy-admin \
    --access-key-id <access-key-id> --status Active

Impact

The attacker holds a credential for the target user that works from anywhere on the internet, with all of that user's permissions. If the user is an administrator, the account is compromised. The credential does not expire. It survives the loss of the original foothold, a password reset on the user, and the revocation of any role session, because none of those actions touch access keys.

A long-term key also feeds other persistence techniques. From it the attacker can request temporary credentials with GetSessionToken or GetFederationToken, which stay valid until they expire even after the key is deleted.

OPSEC and artifacts

  • Blending with rotation. A second key on a user looks like the first half of a normal key rotation. An operator picks a user whose keys are rotated regularly and creates the key during working hours. The CreateAccessKey event still records a caller that differs from the beneficiary in requestParameters.userName, which a real self-service rotation does not.
  • Targeting users with free slots. Choosing a user with zero or one key avoids a DeleteAccessKey call, which would break a workload and draw attention. The credential report and ListAccessKeys then show two active keys with different creation dates.
  • Plausible names for backdoor users. A new user named like a service account avoids a casual glance at the user list. The CreateUser event, followed within minutes by a policy attachment and a key, is a distinctive sequence.
  • Using the key sparingly. A key used rarely, from an address that resembles the organization's, avoids anomaly detection. Every request it signs still carries its key id in userIdentity.accessKeyId, so once the key id is known, all of its activity can be listed.
  • What always remains: the IAM management event with the caller, source address and user agent; responseElements.accessKey.accessKeyId with the id of the issued key; the key's metadata (status and creation date) in ListAccessKeys; and the service, Region and time of last use from GetAccessKeyLastUsed.
  • What is not recorded: the secret itself, and who holds a copy of it. CloudTrail shows that a key was issued and later accepted, not which person used it.

Detection

  • Key created for another user. Alert on CreateAccessKey where the caller is not the user named in requestParameters.userName. A human user rotating its own key calls the API for itself. See the access key detection rules.
  • Any new key on a privileged or human user. In accounts that use federation and roles, a new long-lived key is an exception by definition. Review every one.
  • Key reactivation. UpdateAccessKey with requestParameters.status set to Active on a key that incident response deactivated.
  • New user followed by credentials. CreateUser, then CreateAccessKey, CreateLoginProfile or a policy attachment for the same user name within a short window. See the new IAM user rules.
  • First use of the new key. Join responseElements.accessKey.accessKeyId from the creation event to later events by userIdentity.accessKeyId, and compare the source address and user agent with those of the user's older key.
-- Athena, CloudTrail table: keys created by one principal for another user
SELECT eventtime, useridentity.arn AS caller, useridentity.accesskeyid AS signing_key,
       json_extract_scalar(requestparameters, '$.userName') AS target_user,
       json_extract_scalar(responseelements, '$.accessKey.accessKeyId') AS new_key,
       sourceipaddress, useragent, errorcode
FROM cloudtrail_logs
WHERE eventsource = 'iam.amazonaws.com'
  AND eventname = 'CreateAccessKey'
  AND eventtime >= '2026-11-28T00:00:00Z'
  AND useridentity.arn NOT LIKE concat('%:user/', json_extract_scalar(requestparameters, '$.userName'))
ORDER BY eventtime

A request without userName targets the caller's own user and is excluded by the last condition only when the field is present, so review rows with a null target separately. Amazon GuardDuty lists CreateAccessKey among the APIs behind its Persistence:IAMUser/AnomalousBehavior finding, which fires when the call is unusual for the identity that made it.

Mitigation

  • Remove the need for IAM user keys. Give people federated access through IAM Identity Center and give workloads roles, so that there are few IAM users to add keys to. The IAM Identity Center guide covers the workforce side. See also IAM user versus role.
  • Scope iam:CreateAccessKey to the caller's own user. Where users must manage their own keys, restrict the resource to arn:aws:iam::111122223333:user/${aws:username}. No ordinary identity should hold the permission on *.
  • Deny key creation with a service control policy in accounts that should have no IAM users, with an exception for a break-glass role.
  • Restrict iam:CreateUser, iam:UpdateAccessKey and iam:DeleteAccessKey to the identity administration role. They complete the backdoor user and reactivation variants.
  • Delete, do not only deactivate, compromised keys, and then check for a second key on the same user. After a compromise, list every key created during the incident window across all users.
  • Review keys on a schedule. Use the credential report and GetAccessKeyLastUsed to remove unused keys and to enforce rotation on the ones that must stay.

Detection rules for this attack

Log events to collect

FAQ

Why is a new access key both an escalation and a persistence technique?

The key belongs to the user it was created for, not to the caller. If that user has more permissions than the caller, the caller has escalated. The key is also long-lived: it has no expiry, and it keeps working after the original foothold is closed, until someone deactivates or deletes that specific key.

Does resetting the user's password or enabling MFA remove the attacker's key?

No. The console password and the access keys are separate credentials. Changing the password, or registering an MFA device for console sign-in, leaves every active access key usable for API calls unless the user's policies require MFA for those calls. The key has to be deactivated or deleted by its key id.

Can the secret access key be recovered later for investigation?

No. AWS returns the secret only in the response to the creation call. Afterwards only the key id, status and creation date can be listed. An investigation works from the key id: who created it, when, and which later requests were signed with it.

What stops the attack when a user already has two keys?

IAM allows at most two access keys per user, so the creation call fails. An attacker who also holds iam:DeleteAccessKey or iam:UpdateAccessKey can delete one key, or reactivate an inactive key only if they already know its secret. Deleting a key that a workload uses breaks that workload, which is noisy.

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.