You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
[Tuning] AWS IAM Create User via Assumed Role on EC2 Instance (#5063)
- query change : I chose to replace `aws.cloudtrail.user_identity.arn` with `user.id` and a more accurate wildcard pattern. This will reduce the chances of this rule triggering for role sessions outside of those started by EC2 instances. The wildcard pattern looks for a role session name that starts with `i-` this is because when an EC2 instance operates using it's attached Role (instance profile), the session name attached to that role name is the instance id (`i-......`). The `user.id` field appends this session name to the role name via a standard pattern `:[session_name]`, making it a more reliable field to use in this case.
- small edits to description and IG
- reduced execution window
- reduced history window
- edited highlighted fields
Note: the new_terms field here remains `aws.cloudtrail.user_identity.arn` because we are only interested in assumed roles, and even more particular, only those used by an EC2 instance. This means we want to evaluate each individual instance's behavior rather than the broader behavior of the role itself. The arn field will capture each instance id (session name) alongside the role itself.
Copy file name to clipboardExpand all lines: rules/integrations/aws/persistence_iam_create_user_via_assumed_role_on_ec2_instance.toml
+13-11Lines changed: 13 additions & 11 deletions
Original file line number
Diff line number
Diff line change
@@ -2,14 +2,14 @@
2
2
creation_date = "2024/11/04"
3
3
integration = ["aws"]
4
4
maturity = "production"
5
-
updated_date = "2025/01/17"
5
+
updated_date = "2025/09/04"
6
6
7
7
[rule]
8
8
author = ["Elastic"]
9
9
description = """
10
10
Detects the creation of an AWS Identity and Access Management (IAM) user initiated by an assumed role on an EC2
11
11
instance. Assumed roles allow users or services to temporarily adopt different AWS permissions, but the creation of IAM
12
-
users through these roles—particularly from within EC2 instances—may indicate a compromised instance. Adversaries might
12
+
users through these roles, particularly from within EC2 instances, may indicate a compromised instance. Adversaries might
13
13
exploit such permissions to establish persistence by creating new IAM users under unauthorized conditions.
14
14
"""
15
15
false_positives = [
@@ -20,7 +20,7 @@ false_positives = [
20
20
review.
21
21
""",
22
22
]
23
-
from = "now-9m"
23
+
from = "now-6m"
24
24
index = ["filebeat-*", "logs-aws.cloudtrail-*"]
25
25
language = "kuery"
26
26
license = "Elastic License v2"
@@ -35,15 +35,14 @@ This rule detects when an AWS Identity and Access Management (IAM) user is creat
35
35
36
36
- **Identify the Assumed Role and Initiating Instance**:
37
37
- **Role and Instance**: Examine the `aws.cloudtrail.user_identity.arn` field to determine the specific EC2 instance and role used for this action (e.g., `arn:aws:sts::[account-id]:assumed-role/[role-name]/[instance-id]`). Verify if this behavior aligns with expected usage or represents an anomaly.
38
-
- **Session Context**: Check the `session_issuer` fields in `aws.cloudtrail.user_identity.session_context` for details about the role assumed by the instance, along with `mfa_authenticated` to determine if Multi-Factor Authentication (MFA) was used.
39
38
40
39
- **Analyze the Target IAM User**:
41
-
- **New User Details**: Inspect `aws.cloudtrail.flattened.request_parameters.userName` to see the username that was created. Look at `aws.cloudtrail.flattened.response_elements.user.userName` for confirmation of successful user creation, and validate if the user is expected or authorized.
40
+
- **New User Details**: Inspect `aws.cloudtrail.request_parameters` to see the username that was created. Validate if the user is expected or authorized.
42
41
- **Review Creation Time and Context**: Compare the creation time (`@timestamp`) of the user with other activities from the same instance and role to assess if this creation was part of a larger chain of actions.
43
42
44
43
- **Check User Agent and Tooling**:
45
44
- **User Agent Analysis**: Review `user_agent.original` to see if AWS CLI, SDK, or other tooling was used for this request. Identifiers such as `aws-cli`, `boto3`, or similar SDK names can indicate the method used, which may differentiate automation from interactive actions.
46
-
- **Source IP and Location**: Use the `source.address` and `source.geo` fields to identify the IP address and geographic location of the event. Verify if this aligns with expected access patterns for your environment.
45
+
- **Source IP and Location**: Use the `source.ip` and `source.geo` fields to identify the IP address and geographic location of the event. Verify if this aligns with expected access patterns for your environment.
47
46
48
47
- **Evaluate for Persistence Indicators**:
49
48
- **Role Permissions**: Check the permissions associated with the assumed role (`arn:aws:iam::[account-id]:role/[role-name]`) to determine if creating IAM users is a legitimate activity for this role.
@@ -56,7 +55,7 @@ This rule detects when an AWS Identity and Access Management (IAM) user is creat
56
55
### False Positive Analysis
57
56
58
57
- **Expected Automation**: Assumed roles may be used by legitimate automated systems that create users for specific workflows. Confirm if this event aligns with known automation activities.
59
-
- **User Agent and Role Exceptions**: If this action is routine for specific roles or user agents (e.g., `aws-cli`, `boto3`), consider adding those roles or user agents to a monitored exception list for streamlined review.
58
+
- **Role Exceptions**: If this action is routine for specific roles, consider adding those roles to a monitored exception list for streamlined review.
0 commit comments