Abuse of AWS IAM CreateAccessKey API for Persistence
Adversaries with compromised credentials may abuse the AWS IAM CreateAccessKey API to establish persistence or escalate privileges by generating new programmatic keys for other IAM users.
Adversaries possessing compromised AWS credentials can perform account manipulation to ensure long-term access or elevate their privileges. By invoking the iam:CreateAccessKey API operation, an attacker can generate a new set of programmatic access keys for a different IAM user identity. This activity, when performed by an unauthorized principal, is a common tactic used by threat actors to establish persistence in a cloud environment. While legitimate credential rotation by administrators or automated systems involves this API call, malicious use is often identifiable by discrepancies between the calling IAM identity and the target user. This threat is particularly relevant to environments where IAM policies are overly permissive, allowing non-administrative users to manage keys for other accounts. Defenders must distinguish between sanctioned automated workflows and unauthorized manual key creation to effectively mitigate the risk of credential-based persistence.
Attack Chain
- Attacker obtains valid AWS IAM credentials via phishing, exposed environment variables, or other initial access vectors.
- Attacker performs reconnaissance to identify high-value or elevated-privilege IAM users within the target AWS account.
- Attacker invokes the
iam:CreateAccessKeyAPI operation targeting a secondary user account. - AWS IAM validates that the calling user possesses the required permissions to create keys for the target.
- The API call succeeds, and AWS generates a new
accessKeyIdandsecretAccessKeyfor the target user. - Attacker exfiltrates the newly created programmatic credentials for long-term use.
- Attacker uses the new credentials to perform unauthorized API actions, access sensitive S3 buckets, or further move laterally across the infrastructure.
- Attacker maintains persistent access even if their original compromised credentials are rotated or revoked.
Impact
Successful abuse of the CreateAccessKey API allows adversaries to maintain persistent, long-term access to AWS environments, bypassing initial credential revocation. This can result in unauthorized data exfiltration, lateral movement to other AWS services, and full account compromise. The impact is significant for organizations relying on cloud-based infrastructure, as unauthorized key creation often remains undetected in noisy environments, potentially leading to widespread data exposure and operational disruption.
Recommendation
- Implement least-privilege IAM policies to restrict
iam:CreateAccessKeypermissions to only authorized administrative roles or specific automation principals. - Deploy detection rules to alert on
CreateAccessKeyevents where the callinguserIdentity.arndoes not match the targetuserName. - Perform regular audits of IAM access keys to identify and disable any keys that were created outside of established CI/CD or rotation pipelines.
- Integrate CloudTrail, GuardDuty, and AWS Security Hub to monitor for anomalous API activity and suspicious usage patterns from newly created credentials.
- Enforce Multi-Factor Authentication (MFA) for all IAM users to increase the difficulty of unauthorized credential usage following the creation of programmatic access keys.
Immediate actions
Review all IAM policies granting iam:CreateAccessKey to identify over-privileged non-admin users.
Enrichment needed
- Cross-reference newly created access keys with CloudTrail logs for subsequent usage from anomalous IPs. (CTI) Identify if the created key is already being used maliciously.
Mitigations
Enable multi-region CloudTrail logging and GuardDuty to capture all IAM activity.
General account persistence