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 = "2025/03/20"
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 access keys created for IAM users or root user are long-term credentials that provide programmatic access to AWS.
29With access to the `iam:CreateAccessKey` permission, a set of compromised credentials could be used to create a new
30set of credentials for another user for privilege escalation or as a means of persistence. This rule uses [ES|QL](https://www.elastic.co/guide/en/security/current/rules-ui-create.html#create-esql-rule)
31to look for use of the `CreateAccessKey` operation where the user.name is different from the user.target.name.
32
33
34#### Possible investigation steps
35
36- Identify both related accounts and their role in the environment.
37- Review IAM permission policies for the user identities.
38- Identify the applications or users that should use these accounts.
39- Investigate other alerts associated with the accounts during the past 48 hours.
40- Investigate abnormal values in the `user_agent.original` field by comparing them with the intended and authorized usage and historical data. Suspicious user agent values include non-SDK, AWS CLI, custom user agents, etc.
41- Contact the account owners and confirm whether they are aware of this activity.
42- Considering the source IP address and geolocation of the user who issued the command:
43 - Do they look normal for the calling user?
44 - If the source is an EC2 IP address, is it associated with an EC2 instance in one of your accounts or is the source IP from an EC2 instance that's not under your control?
45 - If it is an authorized EC2 instance, is the activity associated with normal behavior for the instance role or roles? Are there any other alerts or signs of suspicious activity involving this instance?
46- If you suspect the account has been compromised, scope potentially compromised assets by tracking servers, services, and data accessed by the account in the last 24 hours.
47 - Determine what other API calls were made by the user.
48 - Assess whether this behavior is prevalent in the environment by looking for similar occurrences involving other users.
49
50### False positive analysis
51
52- False positives may occur due to the intended usage of the IAM `CreateAccessKey` operation. Verify the `aws.cloudtrail.user_identity.arn` should use this operation against the `user.target.name` account.
53
54### Response and remediation
55
56- Initiate the incident response process based on the outcome of the triage.
57- Disable or limit the account during the investigation and response.
58 - Rotate user credentials
59 - Remove the newly created credentials from the affected user(s)
60- Identify the possible impact of the incident and prioritize accordingly; the following actions can help you gain context:
61 - Identify the account role in the cloud environment.
62 - Assess the criticality of affected services and servers.
63 - Work with your IT team to identify and minimize the impact on users.
64 - Identify if the attacker is moving laterally and compromising other accounts, servers, or services.
65 - Identify any regulatory or legal ramifications related to this activity.
66- Investigate credential exposure on systems compromised or used by the attacker to ensure all compromised accounts are identified.
67 - Rotate secrets or delete API keys as needed to revoke the attacker's access to the environment.
68 - Work with your IT teams to minimize the impact on business operations during these actions.
69- Remove unauthorized new accounts, and request password resets for other IAM users.
70- Consider enabling multi-factor authentication for users.
71- Review the permissions assigned to the implicated user to ensure that the least privilege principle is being followed.
72- Implement security best practices [outlined](https://aws.amazon.com/premiumsupport/knowledge-center/security-best-practices/) by AWS.
73- Take the actions needed to return affected systems, data, or services to their normal operational levels.
74- Identify the initial vector abused by the attacker and take action to prevent reinfection via the same vector.
75- Using the incident response data, update logging and audit policies to improve the mean time to detect (MTTD) and the mean time to respond (MTTR).
76"""
77references = [
78 "https://hackingthe.cloud/aws/exploitation/iam_privilege_escalation/#iamcreateaccesskey",
79 "https://cloud.hacktricks.xyz/pentesting-cloud/aws-security/aws-persistence/aws-iam-persistence",
80 "https://permiso.io/blog/lucr-3-scattered-spider-getting-saas-y-in-the-cloud",
81 "https://docs.aws.amazon.com/IAM/latest/APIReference/API_CreateAccessKey.html",
82]
83risk_score = 47
84rule_id = "696015ef-718e-40ff-ac4a-cc2ba88dbeeb"
85severity = "medium"
86tags = [
87 "Domain: Cloud",
88 "Data Source: AWS",
89 "Data Source: Amazon Web Services",
90 "Data Source: AWS IAM",
91 "Use Case: Identity and Access Audit",
92 "Tactic: Privilege Escalation",
93 "Tactic: Persistence",
94 "Resources: Investigation Guide",
95]
96timestamp_override = "event.ingested"
97type = "esql"
98
99query = '''
100from logs-aws.cloudtrail-* metadata _id, _version, _index
101| where event.provider == "iam.amazonaws.com"
102 and event.action == "CreateAccessKey"
103 and event.outcome == "success"
104 and user.name != user.target.name
105| keep
106 @timestamp,
107 cloud.region,
108 event.provider,
109 event.action,
110 event.outcome,
111 user.name,
112 source.address,
113 user.target.name,
114 user_agent.original,
115 aws.cloudtrail.request_parameters,
116 aws.cloudtrail.response_elements,
117 aws.cloudtrail.user_identity.arn,
118 aws.cloudtrail.user_identity.type
119'''
120
121
122[[rule.threat]]
123framework = "MITRE ATT&CK"
124[[rule.threat.technique]]
125id = "T1098"
126name = "Account Manipulation"
127reference = "https://attack.mitre.org/techniques/T1098/"
128[[rule.threat.technique.subtechnique]]
129id = "T1098.001"
130name = "Additional Cloud Credentials"
131reference = "https://attack.mitre.org/techniques/T1098/001/"
132
133
134
135[rule.threat.tactic]
136id = "TA0003"
137name = "Persistence"
138reference = "https://attack.mitre.org/tactics/TA0003/"
139[[rule.threat]]
140framework = "MITRE ATT&CK"
141[[rule.threat.technique]]
142id = "T1098"
143name = "Account Manipulation"
144reference = "https://attack.mitre.org/techniques/T1098/"
145[[rule.threat.technique.subtechnique]]
146id = "T1098.001"
147name = "Additional Cloud Credentials"
148reference = "https://attack.mitre.org/techniques/T1098/001/"
149
150
151
152[rule.threat.tactic]
153id = "TA0004"
154name = "Privilege Escalation"
155reference = "https://attack.mitre.org/tactics/TA0004/"
156
157[rule.investigation_fields]
158field_names = [
159 "@timestamp",
160 "user.name",
161 "source.address",
162 "aws.cloudtrail.user_identity.arn",
163 "aws.cloudtrail.user_identity.type",
164 "user_agent.original",
165 "user.target.name",
166 "event.action",
167 "event.outcome",
168 "cloud.region",
169 "event.provider",
170 "aws.cloudtrail.request_parameters",
171 "aws.cloudtrail.response_elements",
172]
toml
Triage and analysis
Investigating AWS IAM User Created Access Keys For Another User
AWS access keys created for IAM users or root user are long-term credentials that provide programmatic access to AWS.
With access to the iam:CreateAccessKey
permission, a set of compromised credentials could be used to create a new
set of credentials for another user for privilege escalation or as a means of persistence. This rule uses ES|QL
to look for use of the CreateAccessKey
operation where the user.name is different from the user.target.name.
Possible investigation steps
- Identify both related accounts and their role in the environment.
- Review IAM permission policies for the user identities.
- Identify the applications or users that should use these accounts.
- Investigate other alerts associated with the accounts during the past 48 hours.
- Investigate abnormal values in the
user_agent.original
field by comparing them with the intended and authorized usage and historical data. Suspicious user agent values include non-SDK, AWS CLI, custom user agents, etc. - Contact the account owners and confirm whether they are aware of this activity.
- Considering the source IP address and geolocation of the user who issued the command:
- Do they look normal for the calling user?
- If the source is an EC2 IP address, is it associated with an EC2 instance in one of your accounts or is the source IP from an EC2 instance that's not under your control?
- If it is an authorized EC2 instance, is the activity associated with normal behavior for the instance role or roles? Are there any other alerts or signs of suspicious activity involving this instance?
- If you suspect the account has been compromised, scope potentially compromised assets by tracking servers, services, and data accessed by the account in the last 24 hours.
- Determine what other API calls were made by the user.
- Assess whether this behavior is prevalent in the environment by looking for similar occurrences involving other users.
False positive analysis
- False positives may occur due to the intended usage of the IAM
CreateAccessKey
operation. Verify theaws.cloudtrail.user_identity.arn
should use this operation against theuser.target.name
account.
Response and remediation
- Initiate the incident response process based on the outcome of the triage.
- Disable or limit the account during the investigation and response.
- Rotate user credentials
- Remove the newly created credentials from the affected user(s)
- Identify the possible impact of the incident and prioritize accordingly; the following actions can help you gain context:
- Identify the account role in the cloud environment.
- Assess the criticality of affected services and servers.
- Work with your IT team to identify and minimize the impact on users.
- Identify if the attacker is moving laterally and compromising other accounts, servers, or services.
- Identify any regulatory or legal ramifications related to this activity.
- Investigate credential exposure on systems compromised or used by the attacker to ensure all compromised accounts are identified.
- Rotate secrets or delete API keys as needed to revoke the attacker's access to the environment.
- Work with your IT teams to minimize the impact on business operations during these actions.
- Remove unauthorized new accounts, and request password resets for other IAM users.
- Consider enabling multi-factor authentication for users.
- Review the permissions assigned to the implicated user to ensure that the least privilege principle is being followed.
- Implement security best practices outlined by AWS.
- Take the actions needed to return affected systems, data, or services to their normal operational levels.
- Identify the initial vector abused by the attacker and take action to prevent reinfection via the same vector.
- Using the incident response data, update logging and audit policies to improve the mean time to detect (MTTD) and the mean time to respond (MTTR).
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 Login Profile Added for Root
- AWS IAM Assume Role Policy Update