Skip to content

Commit 5512520

Browse files
authored
[Rule Tuning] AWS User Created Access Keys For Another User (#5212)
* [Rule Tuning] AWS User Created Access Key For Another User Telemetry looks good for this rule, no way to change this from ESQL as we need to be able to compare fields. - added event.dataset to query - added source.ip, cloud.account.id, event.dataset, aws.cloudtrail.user_identity.access_key_id, and source.geo.* fields to `keep` - added to highlighted fields - updated IG * toml-lint
1 parent 7e1f815 commit 5512520

File tree

1 file changed

+86
-44
lines changed

1 file changed

+86
-44
lines changed

rules/integrations/aws/persistence_iam_user_created_access_keys_for_another_user.toml

Lines changed: 86 additions & 44 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
creation_date = "2024/06/13"
33
integration = ["aws"]
44
maturity = "production"
5-
updated_date = "2025/07/24"
5+
updated_date = "2025/10/13"
66

77
[rule]
88
author = ["Elastic"]
@@ -23,56 +23,91 @@ license = "Elastic License v2"
2323
name = "AWS IAM User Created Access Keys For Another User"
2424
note = """## Triage and analysis
2525
26+
> **Disclaimer**:
27+
> This investigation guide was created using generative AI technology and has been reviewed to improve its accuracy and relevance. While every effort has been made to ensure its quality, we recommend validating the content and adapting it to suit your specific environment and operational needs.
28+
29+
2630
### Investigating AWS IAM User Created Access Keys For Another User
2731
28-
AWS access keys created for IAM users or root user are long-term credentials that provide programmatic access to AWS.
29-
With access to the `iam:CreateAccessKey` permission, a set of compromised credentials could be used to create a new
30-
set of credentials for another user for privilege escalation or as a means of persistence. This rule uses [ESQL](https://www.elastic.co/guide/en/security/current/rules-ui-create.html#create-esql-rule)
31-
to look for use of the `CreateAccessKey` operation where the user.name is different from the user.target.name.
32+
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.
33+
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.
3234
35+
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.
3336
3437
#### Possible investigation steps
3538
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.
39+
- **Confirm both user identities and intent.**
40+
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.
41+
42+
- **Review CloudTrail event details.**
43+
Check the following fields directly in the alert or corresponding CloudTrail record:
44+
- `source.ip` — does it align with expected corporate ranges or known admin automation?
45+
- `user_agent.original` — AWS Console, CLI, SDK, or custom client? Unexpected user agents (for example, non-SDK scripts) may indicate manual or unauthorized use.
46+
- `source.geo` fields — verify the location details are expected for the identity.
47+
48+
- **Correlate with related IAM activity.**
49+
In CloudTrail, search for subsequent or nearby events such as:
50+
- `AttachUserPolicy`, `AttachGroupPolicy`, `UpdateAssumeRolePolicy`, or `CreateUser`.
51+
These can indicate privilege escalation or lateral movement.
52+
Also review whether the same principal recently performed `CreateAccessKey` for multiple users or repeated this action across accounts.
53+
54+
- **Inspect the new access key’s usage.**
55+
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.
56+
57+
- **Assess the risk of credential compromise.**
58+
If you suspect malicious behavior, consider the following indicators:
59+
- A non-admin user invoking `CreateAccessKey` for another user.
60+
- Creation outside of normal automation pipelines.
61+
- Use of the new key from a different IP or AWS account soon after creation.
62+
63+
- **Scope related activity.**
64+
Review all activity from the calling user in the past 24–48 hours, focusing on `iam:*` API calls and resource creation events.
65+
Correlate any S3, EC2, or KMS access attempts made using the new key to identify potential impact or data exposure.
4966
5067
### False positive analysis
5168
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.
69+
- **Expected credential rotation.**
70+
Some environments delegate credential rotation responsibilities to centralized automation or specific admin roles. Confirm if the calling user is authorized for such actions.
71+
- **Administrative workflows.**
72+
Account provisioning systems may legitimately create keys on behalf of users. Check for standard tags, automation tools, or user agents that indicate managed operations.
73+
- **Service-linked roles or external IAM automation.**
74+
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.
5375
5476
### Response and remediation
5577
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).
78+
> AWS IR playbooks classify unauthorized credential creation as a **Priority-1 incident** because it may allow persistence or privilege escalation.
79+
> The following steps scale for organizations with or without a dedicated IR team.
80+
81+
**1. Immediate containment**
82+
- Deactivate or delete the access key from the target IAM user immediately using the AWS Console, CLI, or API (`DeleteAccessKey`).
83+
- Rotate or reset credentials for both the calling and target users to eliminate possible compromise.
84+
- Restrict risky principals. Temporarily deny `iam:CreateAccessKey` and `iam:UpdateAccessKey` permissions for non-administrative roles while scoping the incident.
85+
- Enable or confirm MFA on both accounts involved, if not already enforced.
86+
87+
**2. Evidence preservation**
88+
- Export all related `CreateAccessKey`, `DeleteAccessKey`, and `UpdateAccessKey` events within ±30 minutes of the alert to an evidence bucket.
89+
- Preserve CloudTrail, GuardDuty, and AWS Config data for the same period.
90+
- Record key event details: caller ARN, target user, `accessKeyId`, `source.ip`, `userAgent`, and timestamps.
91+
92+
**3. Scoping and investigation**
93+
- Search CloudTrail for usage of the new access key ID after creation. Identify any API activity or data access tied to it.
94+
- Review IAM policy changes, group modifications, or new role assumptions around the same time.
95+
- Determine if any additional credentials or trust policy changes were made by the same actor.
96+
- Check for GuardDuty findings referencing anomalous credential usage or suspicious API behavior.
97+
98+
**4. Recovery and hardening**
99+
- Remove or disable any unauthorized keys and re-enable only verified credentials.
100+
- Implement least-privilege IAM policies to limit which users can perform `CreateAccessKey`.
101+
- Monitor for future `CreateAccessKey` events where `userIdentity.arn != request_parameters.userName`.
102+
- Ensure Cloudtrail, GuardDuty and Security Hub are active across all regions.
103+
- Educate administrative users on secure key rotation processes and the risk of cross-user key creation.
104+
105+
### Additional information
106+
107+
- **[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.
108+
- **[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.
109+
- **AWS Documentation:** [Best practices for managing access keys](https://docs.aws.amazon.com/IAM/latest/UserGuide/id_credentials_access-keys.html).
110+
- **Security Best Practices:** [AWS Knowledge Center – Security Best Practices](https://aws.amazon.com/premiumsupport/knowledge-center/security-best-practices/).
76111
"""
77112
references = [
78113
"https://hackingthe.cloud/aws/exploitation/iam_privilege_escalation/#iamcreateaccesskey",
@@ -98,24 +133,30 @@ type = "esql"
98133

99134
query = '''
100135
from logs-aws.cloudtrail-* metadata _id, _version, _index
101-
| where event.provider == "iam.amazonaws.com"
136+
| where event.dataset == "aws.cloudtrail"
137+
and event.provider == "iam.amazonaws.com"
102138
and event.action == "CreateAccessKey"
103139
and event.outcome == "success"
104140
and user.name != user.target.name
105141
| keep
106142
@timestamp,
143+
cloud.account.id,
107144
cloud.region,
108145
event.provider,
109146
event.action,
110147
event.outcome,
148+
event.dataset,
111149
user.name,
112150
source.address,
151+
source.ip,
113152
user.target.name,
114153
user_agent.original,
115154
aws.cloudtrail.request_parameters,
116155
aws.cloudtrail.response_elements,
117156
aws.cloudtrail.user_identity.arn,
118-
aws.cloudtrail.user_identity.type
157+
aws.cloudtrail.user_identity.type,
158+
aws.cloudtrail.user_identity.access_key_id,
159+
source.geo.*
119160
'''
120161

121162

@@ -158,15 +199,16 @@ reference = "https://attack.mitre.org/tactics/TA0004/"
158199
field_names = [
159200
"@timestamp",
160201
"user.name",
161-
"source.address",
202+
"user_agent.original",
203+
"source.ip",
162204
"aws.cloudtrail.user_identity.arn",
163205
"aws.cloudtrail.user_identity.type",
164-
"user_agent.original",
206+
"aws.cloudtrail.user_identity.access_key_id",
165207
"user.target.name",
166208
"event.action",
167209
"event.outcome",
168210
"cloud.region",
169-
"event.provider",
211+
"cloud.account.id",
170212
"aws.cloudtrail.request_parameters",
171213
"aws.cloudtrail.response_elements",
172214
]

0 commit comments

Comments
 (0)