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 programatic access keys for another IAM user.
Elastic rule (View on GitHub)
1[metadata]
2creation_date = "2024/06/13"
3integration = ["aws"]
4maturity = "production"
5updated_date = "2024/07/06"
6min_stack_comments = "ES|QL rule type in technical preview as of 8.13"
7min_stack_version = "8.13.0"
8
9[rule]
10author = ["Elastic"]
11description = """
12An adversary with access to a set of compromised credentials may attempt to persist or escalate privileges by
13creating a new set of credentials for an existing user. This rule looks for use of the IAM `CreateAccessKey` API operation
14to create new programatic access keys for another IAM user.
15"""
16false_positives = [
17 """
18 While this can be normal behavior, it should be investigated to ensure validity.
19 Verify whether the user identity should be using the IAM `CreateAccessKey` for the targeted user.
20 """,
21]
22from = "now-6m"
23language = "esql"
24license = "Elastic License v2"
25name = "AWS IAM User Created Access Keys For Another User"
26note = """## Triage and analysis
27
28### Investigating AWS IAM User Created Access Keys For Another User
29
30AWS access keys created for IAM users or root user are long-term credentials that provide programatic access to AWS.
31With access to the `iam:CreateAccessKey` permission, a set of compromised credentials could be used to create a new
32set 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/master/rules-ui-create.html#create-esql-rule)
33to look for use of the `CreateAccessKey` operation where the user.name is different from the user.target.name.
34
35
36#### Possible investigation steps
37
38- Identify both related accounts and their role in the environment.
39- Review IAM permission policies for the user identities.
40- Identify the applications or users that should use these accounts.
41- Investigate other alerts associated with the accounts during the past 48 hours.
42- 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.
43- Contact the account owners and confirm whether they are aware of this activity.
44- Considering the source IP address and geolocation of the user who issued the command:
45 - Do they look normal for the calling user?
46 - 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?
47 - 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?
48- 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.
49 - Determine what other API calls were made by the user.
50 - Assess whether this behavior is prevalent in the environment by looking for similar occurrences involving other users.
51
52### False positive analysis
53
54- 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.
55
56### Response and remediation
57
58- Initiate the incident response process based on the outcome of the triage.
59- Disable or limit the account during the investigation and response.
60 - Rotate user credentials
61 - Remove the newly created credentials from the affected user(s)
62- Identify the possible impact of the incident and prioritize accordingly; the following actions can help you gain context:
63 - Identify the account role in the cloud environment.
64 - Assess the criticality of affected services and servers.
65 - Work with your IT team to identify and minimize the impact on users.
66 - Identify if the attacker is moving laterally and compromising other accounts, servers, or services.
67 - Identify any regulatory or legal ramifications related to this activity.
68- Investigate credential exposure on systems compromised or used by the attacker to ensure all compromised accounts are identified.
69 - Rotate secrets or delete API keys as needed to revoke the attacker's access to the environment.
70 - Work with your IT teams to minimize the impact on business operations during these actions.
71- Remove unauthorized new accounts, and request password resets for other IAM users.
72- Consider enabling multi-factor authentication for users.
73- Review the permissions assigned to the implicated user to ensure that the least privilege principle is being followed.
74- Implement security best practices [outlined](https://aws.amazon.com/premiumsupport/knowledge-center/security-best-practices/) by AWS.
75- Take the actions needed to return affected systems, data, or services to their normal operational levels.
76- Identify the initial vector abused by the attacker and take action to prevent reinfection via the same vector.
77- 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).
78"""
79references = [
80 "https://hackingthe.cloud/aws/exploitation/iam_privilege_escalation/#iamcreateaccesskey",
81 "https://cloud.hacktricks.xyz/pentesting-cloud/aws-security/aws-persistence/aws-iam-persistence",
82 "https://permiso.io/blog/lucr-3-scattered-spider-getting-saas-y-in-the-cloud",
83 "https://docs.aws.amazon.com/IAM/latest/APIReference/API_CreateAccessKey.html",
84]
85risk_score = 47
86rule_id = "696015ef-718e-40ff-ac4a-cc2ba88dbeeb"
87severity = "medium"
88tags = [
89 "Domain: Cloud",
90 "Data Source: AWS",
91 "Data Source: Amazon Web Services",
92 "Data Source: AWS IAM",
93 "Use Case: Identity and Access Audit",
94 "Tactic: Privilege Escalation",
95 "Tactic: Persistence",
96 "Resources: Investigation Guide",
97]
98timestamp_override = "event.ingested"
99type = "esql"
100
101query = '''
102from logs-aws.cloudtrail-*
103| where event.provider == "iam.amazonaws.com" and event.action == "CreateAccessKey" and event.outcome == "success" and user.name != user.target.name
104'''
105
106
107[[rule.threat]]
108framework = "MITRE ATT&CK"
109[[rule.threat.technique]]
110id = "T1098"
111name = "Account Manipulation"
112reference = "https://attack.mitre.org/techniques/T1098/"
113[[rule.threat.technique.subtechnique]]
114id = "T1098.001"
115name = "Additional Cloud Credentials"
116reference = "https://attack.mitre.org/techniques/T1098/001/"
117
118[rule.threat.tactic]
119id = "TA0003"
120name = "Persistence"
121reference = "https://attack.mitre.org/tactics/TA0003/"
122
123[[rule.threat]]
124framework = "MITRE ATT&CK"
125[[rule.threat.technique]]
126id = "T1098"
127name = "Account Manipulation"
128reference = "https://attack.mitre.org/techniques/T1098/"
129[[rule.threat.technique.subtechnique]]
130id = "T1098.001"
131name = "Additional Cloud Credentials"
132reference = "https://attack.mitre.org/techniques/T1098/001/"
133
134[rule.threat.tactic]
135id = "TA0004"
136name = "Privilege Escalation"
137reference = "https://attack.mitre.org/tactics/TA0004/"
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 programatic 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 RDS DB Instance or Cluster Password Modified
- AWS IAM Assume Role Policy Update