AWS IAM User Created Access Keys For Another User
An adversary with access to a set of compromised credentials may attempt to persist or escalate privileges by creating a
new set of credentials for an existing user. This rule looks for use of the IAM CreateAccessKey API operation to
create new programmatic access keys for another IAM user.
Elastic rule (View on GitHub)
1[metadata]
2creation_date = "2024/06/13"
3integration = ["aws"]
4maturity = "production"
5updated_date = "2026/01/16"
6
7[rule]
8author = ["Elastic"]
9description = """
10An adversary with access to a set of compromised credentials may attempt to persist or escalate privileges by creating a
11new set of credentials for an existing user. This rule looks for use of the IAM `CreateAccessKey` API operation to
12create new programmatic access keys for another IAM user.
13"""
14false_positives = [
15 """
16 While this can be normal behavior, it should be investigated to ensure validity. Verify whether the user identity
17 should be using the IAM `CreateAccessKey` for the targeted user.
18 """,
19]
20from = "now-6m"
21language = "esql"
22license = "Elastic License v2"
23name = "AWS IAM User Created Access Keys For Another User"
24note = """## Triage and analysis
25
26### Investigating AWS IAM User Created Access Keys For Another User
27
28AWS IAM access keys are long-term credentials that grant programmatic access to AWS resources. The `iam:CreateAccessKey` permission allows an IAM principal to generate new access keys for an existing IAM user.
29While this operation can be legitimate (for example, credential rotation), it can also be abused to establish persistence or privilege escalation if one user creates keys for another account without authorization.
30
31This rule identifies `CreateAccessKey` API calls where the calling user (`aws.cloudtrail.user_identity.arn`) differs from the target user (`aws.cloudtrail.request_parameters.userName`), indicating one IAM identity creating credentials for another.
32
33#### Possible investigation steps
34
35- **Confirm both user identities and intent.**
36 Identify the calling user (who performed `CreateAccessKey`) and the target user (whose access key was created). Contact both account owners or application teams to confirm if this operation was expected.
37
38- **Review CloudTrail event details.**
39 Check the following fields directly in the alert or corresponding CloudTrail record:
40 - `source.ip` — does it align with expected corporate ranges or known admin automation?
41 - `user_agent.original` — AWS Console, CLI, SDK, or custom client? Unexpected user agents (for example, non-SDK scripts) may indicate manual or unauthorized use.
42 - `source.geo` fields — verify the location details are expected for the identity.
43
44- **Correlate with related IAM activity.**
45 In CloudTrail, search for subsequent or nearby events such as:
46 - `AttachUserPolicy`, `AttachGroupPolicy`, `UpdateAssumeRolePolicy`, or `CreateUser`.
47 These can indicate privilege escalation or lateral movement.
48 Also review whether the same principal recently performed `CreateAccessKey` for multiple users or repeated this action across accounts.
49
50- **Inspect the new access key’s usage.**
51 Search for the newly created key ID (`aws.cloudtrail.response_elements.accessKey.accessKeyId`) in CloudTrail events following creation. Determine if it was used from unusual IP addresses, geographies, or services.
52
53- **Assess the risk of credential compromise.**
54 If you suspect malicious behavior, consider the following indicators:
55 - A non-admin user invoking `CreateAccessKey` for another user.
56 - Creation outside of normal automation pipelines.
57 - Use of the new key from a different IP or AWS account soon after creation.
58
59- **Scope related activity.**
60 Review all activity from the calling user in the past 24–48 hours, focusing on `iam:*` API calls and resource creation events.
61 Correlate any S3, EC2, or KMS access attempts made using the new key to identify potential impact or data exposure.
62
63### False positive analysis
64
65- **Expected credential rotation.**
66 Some environments delegate credential rotation responsibilities to centralized automation or specific admin roles. Confirm if the calling user is authorized for such actions.
67- **Administrative workflows.**
68 Account provisioning systems may legitimately create keys on behalf of users. Check for standard tags, automation tools, or user agents that indicate managed operations.
69- **Service-linked roles or external IAM automation.**
70 Some AWS services create or rotate credentials automatically. Validate if the caller is a service-linked role or an automation IAM role used by a known deployment process.
71
72### Response and remediation
73
74**Immediate containment**
75- Deactivate or delete the access key from the target IAM user immediately using the AWS Console, CLI, or API (`DeleteAccessKey`).
76- Rotate or reset credentials for both the calling and target users to eliminate possible compromise.
77- Restrict risky principals. Temporarily deny `iam:CreateAccessKey` and `iam:UpdateAccessKey` permissions for non-administrative roles while scoping the incident.
78- Enable or confirm MFA on both accounts involved, if not already enforced.
79
80**Evidence preservation**
81- Export all related `CreateAccessKey`, `DeleteAccessKey`, and `UpdateAccessKey` events within ±30 minutes of the alert to an evidence bucket.
82- Preserve CloudTrail, GuardDuty, and AWS Config data for the same period.
83- Record key event details: caller ARN, target user, `accessKeyId`, `source.ip`, `userAgent`, and timestamps.
84
85**Scoping and investigation**
86- Search CloudTrail for usage of the new access key ID after creation. Identify any API activity or data access tied to it.
87- Review IAM policy changes, group modifications, or new role assumptions around the same time.
88- Determine if any additional credentials or trust policy changes were made by the same actor.
89- Check for GuardDuty findings referencing anomalous credential usage or suspicious API behavior.
90
91**Recovery and hardening**
92- Remove or disable any unauthorized keys and re-enable only verified credentials.
93- Implement least-privilege IAM policies to limit which users can perform `CreateAccessKey`.
94- Monitor for future `CreateAccessKey` events where `userIdentity.arn != request_parameters.userName`.
95- Ensure Cloudtrail, GuardDuty and Security Hub are active across all regions.
96- Educate administrative users on secure key rotation processes and the risk of cross-user key creation.
97
98### Additional information
99
100- **[AWS IR Playbooks](https://github.com/aws-samples/aws-incident-response-playbooks/blob/c151b0dc091755fffd4d662a8f29e2f6794da52c/playbooks/):** Reference “Credential Compromise” and “IAM Misuse” procedures for containment and recovery.
101- **[AWS Customer Playbook Framework](https://github.com/aws-samples/aws-customer-playbook-framework/):** See “Identity Access Review” and “Unauthorized Access Key Creation” for example response flows.
102- **AWS Documentation:** [Best practices for managing access keys](https://docs.aws.amazon.com/IAM/latest/UserGuide/id_credentials_access-keys.html).
103- **Security Best Practices:** [AWS Knowledge Center – Security Best Practices](https://aws.amazon.com/premiumsupport/knowledge-center/security-best-practices/).
104"""
105references = [
106 "https://hackingthe.cloud/aws/exploitation/iam_privilege_escalation/#iamcreateaccesskey",
107 "https://cloud.hacktricks.xyz/pentesting-cloud/aws-security/aws-persistence/aws-iam-persistence",
108 "https://permiso.io/blog/lucr-3-scattered-spider-getting-saas-y-in-the-cloud",
109 "https://docs.aws.amazon.com/IAM/latest/APIReference/API_CreateAccessKey.html",
110]
111risk_score = 47
112rule_id = "696015ef-718e-40ff-ac4a-cc2ba88dbeeb"
113severity = "medium"
114tags = [
115 "Domain: Cloud",
116 "Data Source: AWS",
117 "Data Source: Amazon Web Services",
118 "Data Source: AWS IAM",
119 "Use Case: Identity and Access Audit",
120 "Tactic: Privilege Escalation",
121 "Tactic: Persistence",
122 "Resources: Investigation Guide",
123]
124timestamp_override = "event.ingested"
125type = "esql"
126
127query = '''
128from logs-aws.cloudtrail-* metadata _id, _version, _index
129| where event.dataset == "aws.cloudtrail"
130 and event.provider == "iam.amazonaws.com"
131 and event.action == "CreateAccessKey"
132 and event.outcome == "success"
133 and user.name != user.target.name
134| keep
135 @timestamp,
136 cloud.account.id,
137 cloud.region,
138 event.provider,
139 event.action,
140 event.outcome,
141 event.dataset,
142 user.name,
143 source.address,
144 source.ip,
145 user.target.name,
146 user_agent.original,
147 aws.cloudtrail.request_parameters,
148 aws.cloudtrail.response_elements,
149 aws.cloudtrail.user_identity.arn,
150 aws.cloudtrail.user_identity.type,
151 aws.cloudtrail.user_identity.access_key_id,
152 source.geo.*,
153 _id,
154 _version,
155 _index
156'''
157
158
159[[rule.threat]]
160framework = "MITRE ATT&CK"
161[[rule.threat.technique]]
162id = "T1098"
163name = "Account Manipulation"
164reference = "https://attack.mitre.org/techniques/T1098/"
165[[rule.threat.technique.subtechnique]]
166id = "T1098.001"
167name = "Additional Cloud Credentials"
168reference = "https://attack.mitre.org/techniques/T1098/001/"
169
170
171
172[rule.threat.tactic]
173id = "TA0003"
174name = "Persistence"
175reference = "https://attack.mitre.org/tactics/TA0003/"
176[[rule.threat]]
177framework = "MITRE ATT&CK"
178[[rule.threat.technique]]
179id = "T1098"
180name = "Account Manipulation"
181reference = "https://attack.mitre.org/techniques/T1098/"
182[[rule.threat.technique.subtechnique]]
183id = "T1098.001"
184name = "Additional Cloud Credentials"
185reference = "https://attack.mitre.org/techniques/T1098/001/"
186
187
188
189[rule.threat.tactic]
190id = "TA0004"
191name = "Privilege Escalation"
192reference = "https://attack.mitre.org/tactics/TA0004/"
193
194[rule.investigation_fields]
195field_names = [
196 "@timestamp",
197 "user.name",
198 "user_agent.original",
199 "source.ip",
200 "aws.cloudtrail.user_identity.arn",
201 "aws.cloudtrail.user_identity.type",
202 "aws.cloudtrail.user_identity.access_key_id",
203 "user.target.name",
204 "event.action",
205 "event.outcome",
206 "cloud.region",
207 "cloud.account.id",
208 "aws.cloudtrail.request_parameters",
209 "aws.cloudtrail.response_elements",
210]
Triage and analysis
Investigating AWS IAM User Created Access Keys For Another User
AWS IAM access keys are long-term credentials that grant programmatic access to AWS resources. The iam:CreateAccessKey permission allows an IAM principal to generate new access keys for an existing IAM user.
While this operation can be legitimate (for example, credential rotation), it can also be abused to establish persistence or privilege escalation if one user creates keys for another account without authorization.
This rule identifies CreateAccessKey API calls where the calling user (aws.cloudtrail.user_identity.arn) differs from the target user (aws.cloudtrail.request_parameters.userName), indicating one IAM identity creating credentials for another.
Possible investigation steps
-
Confirm both user identities and intent.
Identify the calling user (who performedCreateAccessKey) and the target user (whose access key was created). Contact both account owners or application teams to confirm if this operation was expected. -
Review CloudTrail event details.
Check the following fields directly in the alert or corresponding CloudTrail record:source.ip— does it align with expected corporate ranges or known admin automation?user_agent.original— AWS Console, CLI, SDK, or custom client? Unexpected user agents (for example, non-SDK scripts) may indicate manual or unauthorized use.source.geofields — verify the location details are expected for the identity.
-
Correlate with related IAM activity.
In CloudTrail, search for subsequent or nearby events such as:AttachUserPolicy,AttachGroupPolicy,UpdateAssumeRolePolicy, orCreateUser.
These can indicate privilege escalation or lateral movement.
Also review whether the same principal recently performedCreateAccessKeyfor multiple users or repeated this action across accounts.
-
Inspect the new access key’s usage.
Search for the newly created key ID (aws.cloudtrail.response_elements.accessKey.accessKeyId) in CloudTrail events following creation. Determine if it was used from unusual IP addresses, geographies, or services. -
Assess the risk of credential compromise.
If you suspect malicious behavior, consider the following indicators:- A non-admin user invoking
CreateAccessKeyfor another user. - Creation outside of normal automation pipelines.
- Use of the new key from a different IP or AWS account soon after creation.
- A non-admin user invoking
-
Scope related activity.
Review all activity from the calling user in the past 24–48 hours, focusing oniam:*API calls and resource creation events.
Correlate any S3, EC2, or KMS access attempts made using the new key to identify potential impact or data exposure.
False positive analysis
- Expected credential rotation.
Some environments delegate credential rotation responsibilities to centralized automation or specific admin roles. Confirm if the calling user is authorized for such actions. - Administrative workflows.
Account provisioning systems may legitimately create keys on behalf of users. Check for standard tags, automation tools, or user agents that indicate managed operations. - Service-linked roles or external IAM automation.
Some AWS services create or rotate credentials automatically. Validate if the caller is a service-linked role or an automation IAM role used by a known deployment process.
Response and remediation
Immediate containment
- Deactivate or delete the access key from the target IAM user immediately using the AWS Console, CLI, or API (
DeleteAccessKey). - Rotate or reset credentials for both the calling and target users to eliminate possible compromise.
- Restrict risky principals. Temporarily deny
iam:CreateAccessKeyandiam:UpdateAccessKeypermissions for non-administrative roles while scoping the incident. - Enable or confirm MFA on both accounts involved, if not already enforced.
Evidence preservation
- Export all related
CreateAccessKey,DeleteAccessKey, andUpdateAccessKeyevents within ±30 minutes of the alert to an evidence bucket. - Preserve CloudTrail, GuardDuty, and AWS Config data for the same period.
- Record key event details: caller ARN, target user,
accessKeyId,source.ip,userAgent, and timestamps.
Scoping and investigation
- Search CloudTrail for usage of the new access key ID after creation. Identify any API activity or data access tied to it.
- Review IAM policy changes, group modifications, or new role assumptions around the same time.
- Determine if any additional credentials or trust policy changes were made by the same actor.
- Check for GuardDuty findings referencing anomalous credential usage or suspicious API behavior.
Recovery and hardening
- Remove or disable any unauthorized keys and re-enable only verified credentials.
- Implement least-privilege IAM policies to limit which users can perform
CreateAccessKey. - Monitor for future
CreateAccessKeyevents whereuserIdentity.arn != request_parameters.userName. - Ensure Cloudtrail, GuardDuty and Security Hub are active across all regions.
- Educate administrative users on secure key rotation processes and the risk of cross-user key creation.
Additional information
- AWS IR Playbooks: Reference “Credential Compromise” and “IAM Misuse” procedures for containment and recovery.
- AWS Customer Playbook Framework: See “Identity Access Review” and “Unauthorized Access Key Creation” for example response flows.
- AWS Documentation: Best practices for managing access keys.
- Security Best Practices: AWS Knowledge Center – Security Best Practices.
References
Related rules
- AWS IAM AdministratorAccess Policy Attached to Group
- AWS IAM AdministratorAccess Policy Attached to Role
- AWS IAM AdministratorAccess Policy Attached to User
- AWS IAM API Calls via Temporary Session Tokens
- AWS IAM Group Creation