Skip to content

Commit 1491aa7

Browse files
Merge branch '8.19' into issue-1618
2 parents a9e634b + 9e9d45a commit 1491aa7

File tree

213 files changed

+18199
-705
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

213 files changed

+18199
-705
lines changed
Lines changed: 212 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,212 @@
1+
[[prebuilt-rule-8-19-7-aws-access-token-used-from-multiple-addresses]]
2+
=== AWS Access Token Used from Multiple Addresses
3+
4+
This rule identifies potentially suspicious activity by detecting instances where a single IAM user's temporary session token is accessed from multiple IP addresses within a short time frame. Such behavior may suggest that an adversary has compromised temporary credentials and is utilizing them from various locations. To enhance detection accuracy and minimize false positives, the rule incorporates criteria that evaluate unique IP addresses, user agents, cities, and networks. These additional checks help distinguish between legitimate distributed access patterns and potential credential misuse. Detected activities are classified into different types based on the combination of unique indicators, with each classification assigned a fidelity score reflecting the likelihood of malicious behavior. High fidelity scores are given to patterns most indicative of threats, such as multiple unique IPs, networks, cities, and user agents. Medium and low fidelity scores correspond to less severe patterns, enabling security teams to effectively prioritize alerts.
5+
6+
*Rule type*: esql
7+
8+
*Rule indices*: None
9+
10+
*Severity*: medium
11+
12+
*Risk score*: 47
13+
14+
*Runs every*: 5m
15+
16+
*Searches indices from*: now-32m ({ref}/common-options.html#date-math[Date Math format], see also <<rule-schedule, `Additional look-back time`>>)
17+
18+
*Maximum alerts per execution*: 100
19+
20+
*References*:
21+
22+
* https://www.sygnia.co/blog/sygnia-investigation-bybit-hack/
23+
24+
*Tags*:
25+
26+
* Domain: Cloud
27+
* Data Source: AWS
28+
* Data Source: Amazon Web Services
29+
* Data Source: AWS IAM
30+
* Data Source: AWS CloudTrail
31+
* Tactic: Initial Access
32+
* Use Case: Identity and Access Audit
33+
* Resources: Investigation Guide
34+
35+
*Version*: 103
36+
37+
*Rule authors*:
38+
39+
* Elastic
40+
41+
*Rule license*: Elastic License v2
42+
43+
44+
==== Investigation guide
45+
46+
47+
48+
*Triage and Analysis*
49+
50+
51+
52+
*Investigating AWS Access Token Used from Multiple Addresses*
53+
54+
55+
Access tokens are bound to a single user. Usage from multiple IP addresses may indicate the token was stolen and used elsewhere. By correlating this with additional detection criteria like multiple user agents, different cities, and different networks, we can improve the fidelity of the rule and help to eliminate false positives associated with expected behavior, like dual-stack IPV4/IPV6 usage.
56+
57+
58+
*Possible Investigation Steps*
59+
60+
61+
- **Identify the IAM User**: Examine the `aws.cloudtrail.user_identity.arn` stored in `user_id` and correlate with the `source.ips` stored in `ip_list` and `unique_ips` count to determine how widely the token was used.
62+
- **Correlate Additional Detection Context**: Examine `activity_type` and `fidelity_score` to determine additional cities, networks or user agents associated with the token usage.
63+
- **Determine Access Key Type**: Examine the `access_key_id` to determine whether the token is short-term (beginning with ASIA) or long-term (beginning with AKIA).
64+
- **Check Recent MFA Events**: Determine whether the user recently enabled MFA, registered devices, or assumed a role using this token.
65+
- **Review Workload Context**: Confirm whether the user was expected to be active across multiple cities, networks or user agent environments.
66+
- **Trace Adversary Movement**: Pivot to related actions (e.g., `s3:ListBuckets`, `iam:ListUsers`, `sts:GetCallerIdentity`) to track further enumeration.
67+
68+
69+
*False Positive Analysis*
70+
71+
72+
- Automation frameworks that rotate through multiple IPs or cloud functions with dynamic egress IPs may cause this alert to fire.
73+
- Confirm geolocation and workload context before escalating.
74+
75+
76+
*Response and Remediation*
77+
78+
79+
- **Revoke the Token**: Disable or rotate the IAM credentials and invalidate the temporary session token.
80+
- **Audit the Environment**: Look for signs of lateral movement or data access during the token's validity.
81+
- **Strengthen Controls**: Require MFA for high-privilege actions, restrict access via policy conditions (e.g., IP range or device).
82+
83+
84+
*References*
85+
86+
87+
- https://docs.aws.amazon.com/IAM/latest/UserGuide/id_credentials_access-keys.html[IAM Long-Term Credentials]
88+
- https://docs.aws.amazon.com/IAM/latest/UserGuide/id_credentials_temp.html[STS Temporary Credentials]
89+
- https://docs.aws.amazon.com/IAM/latest/UserGuide/id_credentials_temp_enable-regions.html[Using MFA with Temporary Credentials]
90+
- https://docs.aws.amazon.com/securityhub/latest/userguide/securityhub-standards-fsbp-controls.html[AWS Threat Detection Use Cases]
91+
92+
93+
==== Rule query
94+
95+
96+
[source, js]
97+
----------------------------------
98+
from logs-aws.cloudtrail* metadata _id, _version, _index
99+
| where @timestamp > now() - 30 minutes
100+
and event.dataset == "aws.cloudtrail"
101+
and aws.cloudtrail.user_identity.arn is not null
102+
and aws.cloudtrail.user_identity.type == "IAMUser"
103+
and source.ip is not null
104+
and aws.cloudtrail.user_identity.access_key_id is not null
105+
and not (
106+
user_agent.original like "*Terraform*" or
107+
user_agent.original like "*Ansible*" or
108+
user_agent.original like "*Pulumi*"
109+
)
110+
and `source.as.organization.name` != "AMAZON-AES"
111+
and not ((
112+
`source.as.organization.name` == "AMAZON-02" and aws.cloudtrail.event_category == "Data"))
113+
and event.provider not in (
114+
"health.amazonaws.com", "monitoring.amazonaws.com", "notifications.amazonaws.com",
115+
"ce.amazonaws.com", "cost-optimization-hub.amazonaws.com",
116+
"servicecatalog-appregistry.amazonaws.com", "securityhub.amazonaws.com",
117+
"account.amazonaws.com", "budgets.amazonaws.com", "freetier.amazonaws.com"
118+
)
119+
120+
| eval
121+
Esql.time_window_date_trunc = date_trunc(30 minutes, @timestamp),
122+
Esql.aws_cloudtrail_user_identity_arn = aws.cloudtrail.user_identity.arn,
123+
Esql.aws_cloudtrail_user_identity_access_key_id = aws.cloudtrail.user_identity.access_key_id,
124+
Esql.source_ip = source.ip,
125+
Esql.user_agent_original = user_agent.original,
126+
Esql.source_ip_string = to_string(source.ip),
127+
Esql.source_ip_user_agent_pair = concat(Esql.source_ip_string, " - ", user_agent.original),
128+
Esql.source_ip_city_pair = concat(Esql.source_ip_string, " - ", source.geo.city_name),
129+
Esql.source_geo_city_name = source.geo.city_name,
130+
Esql.source_network_org_name = `source.as.organization.name`,
131+
Esql.source_ip_network_pair = concat(Esql.source_ip_string, "-", `source.as.organization.name`),
132+
Esql.event_timestamp = @timestamp
133+
134+
| stats
135+
Esql.event_action_values = values(event.action),
136+
Esql.event_provider_values = values(event.provider),
137+
Esql.aws_cloudtrail_user_identity_access_key_id_values = values(Esql.aws_cloudtrail_user_identity_access_key_id),
138+
Esql.aws_cloudtrail_user_identity_arn_values = values(Esql.aws_cloudtrail_user_identity_arn),
139+
Esql.source_ip_values = values(Esql.source_ip),
140+
Esql.user_agent_original_values = values(Esql.user_agent_original),
141+
Esql.source_ip_user_agent_pair_values = values(Esql.source_ip_user_agent_pair),
142+
Esql.source_geo_city_name_values = values(Esql.source_geo_city_name),
143+
Esql.source_ip_city_pair_values = values(Esql.source_ip_city_pair),
144+
Esql.source_network_org_name_values = values(Esql.source_network_org_name),
145+
Esql.source_ip_network_pair_values = values(Esql.source_ip_network_pair),
146+
Esql.source_ip_count_distinct = count_distinct(Esql.source_ip),
147+
Esql.user_agent_original_count_distinct = count_distinct(Esql.user_agent_original),
148+
Esql.source_geo_city_name_count_distinct = count_distinct(Esql.source_geo_city_name),
149+
Esql.source_network_org_name_count_distinct = count_distinct(Esql.source_network_org_name),
150+
Esql.timestamp_first_seen = min(Esql.event_timestamp),
151+
Esql.timestamp_last_seen = max(Esql.event_timestamp),
152+
Esql.event_count = count()
153+
by Esql.time_window_date_trunc, Esql.aws_cloudtrail_user_identity_access_key_id
154+
155+
| eval
156+
Esql.activity_type = case(
157+
Esql.source_ip_count_distinct >= 2 and Esql.source_network_org_name_count_distinct >= 2 and Esql.source_geo_city_name_count_distinct >= 2 and Esql.user_agent_original_count_distinct >= 2, "multiple_ip_network_city_user_agent",
158+
Esql.source_ip_count_distinct >= 2 and Esql.source_network_org_name_count_distinct >= 2 and Esql.source_geo_city_name_count_distinct >= 2, "multiple_ip_network_city",
159+
Esql.source_ip_count_distinct >= 2 and Esql.source_geo_city_name_count_distinct >= 2, "multiple_ip_and_city",
160+
Esql.source_ip_count_distinct >= 2 and Esql.source_network_org_name_count_distinct >= 2, "multiple_ip_and_network",
161+
Esql.source_ip_count_distinct >= 2 and Esql.user_agent_original_count_distinct >= 2, "multiple_ip_and_user_agent",
162+
"normal_activity"
163+
),
164+
Esql.activity_fidelity_score = case(
165+
Esql.activity_type == "multiple_ip_network_city_user_agent", "high",
166+
Esql.activity_type == "multiple_ip_network_city", "high",
167+
Esql.activity_type == "multiple_ip_and_city", "medium",
168+
Esql.activity_type == "multiple_ip_and_network", "medium",
169+
Esql.activity_type == "multiple_ip_and_user_agent", "low"
170+
)
171+
172+
| keep
173+
Esql.time_window_date_trunc,
174+
Esql.activity_type,
175+
Esql.activity_fidelity_score,
176+
Esql.event_count,
177+
Esql.timestamp_first_seen,
178+
Esql.timestamp_last_seen,
179+
Esql.aws_cloudtrail_user_identity_arn_values,
180+
Esql.aws_cloudtrail_user_identity_access_key_id_values,
181+
Esql.event_action_values,
182+
Esql.event_provider_values,
183+
Esql.source_ip_values,
184+
Esql.user_agent_original_values,
185+
Esql.source_ip_user_agent_pair_values,
186+
Esql.source_geo_city_name_values,
187+
Esql.source_ip_city_pair_values,
188+
Esql.source_network_org_name_values,
189+
Esql.source_ip_network_pair_values,
190+
Esql.source_ip_count_distinct,
191+
Esql.user_agent_original_count_distinct,
192+
Esql.source_geo_city_name_count_distinct,
193+
Esql.source_network_org_name_count_distinct
194+
195+
| where Esql.activity_type != "normal_activity"
196+
197+
----------------------------------
198+
199+
*Framework*: MITRE ATT&CK^TM^
200+
201+
* Tactic:
202+
** Name: Initial Access
203+
** ID: TA0001
204+
** Reference URL: https://attack.mitre.org/tactics/TA0001/
205+
* Technique:
206+
** Name: Valid Accounts
207+
** ID: T1078
208+
** Reference URL: https://attack.mitre.org/techniques/T1078/
209+
* Sub-technique:
210+
** Name: Cloud Accounts
211+
** ID: T1078.004
212+
** Reference URL: https://attack.mitre.org/techniques/T1078/004/
Lines changed: 128 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,128 @@
1+
[[prebuilt-rule-8-19-7-aws-dynamodb-scan-by-unusual-user]]
2+
=== AWS DynamoDB Scan by Unusual User
3+
4+
Identifies when an AWS DynamoDB table is scanned by a user who does not typically perform this action. Adversaries may use the Scan operation to collect sensitive information or exfiltrate data from DynamoDB tables. This rule detects unusual user activity by monitoring for the Scan action in CloudTrail logs. This is a New Terms rule that only flags when this behavior is observed by a user or role for the first time.
5+
6+
*Rule type*: new_terms
7+
8+
*Rule indices*:
9+
10+
* filebeat-*
11+
* logs-aws.cloudtrail-*
12+
13+
*Severity*: low
14+
15+
*Risk score*: 21
16+
17+
*Runs every*: 5m
18+
19+
*Searches indices from*: now-6m ({ref}/common-options.html#date-math[Date Math format], see also <<rule-schedule, `Additional look-back time`>>)
20+
21+
*Maximum alerts per execution*: 100
22+
23+
*References*:
24+
25+
* https://docs.aws.amazon.com/amazondynamodb/latest/developerguide/Scan.html
26+
27+
*Tags*:
28+
29+
* Domain: Cloud
30+
* Data Source: AWS
31+
* Data Source: Amazon Web Services
32+
* Data Source: AWS DynamoDB
33+
* Resources: Investigation Guide
34+
* Use Case: Threat Detection
35+
* Tactic: Exfiltration
36+
37+
*Version*: 4
38+
39+
*Rule authors*:
40+
41+
* Elastic
42+
43+
*Rule license*: Elastic License v2
44+
45+
46+
==== Investigation guide
47+
48+
49+
50+
*Triage and analysis*
51+
52+
53+
54+
*Investigating AWS DynamoDB Scan by Unusual User*
55+
56+
57+
This rule identifies when an AWS DynamoDB table is scanned by a user who does not typically perform this action. Adversaries may use the Scan operation to collect sensitive information or exfiltrate data from DynamoDB tables. This rule detects unusual user activity by monitoring for the Scan action in CloudTrail logs.
58+
59+
This is a https://www.elastic.co/guide/en/security/current/rules-ui-create.html#create-new-terms-rule[New Terms] rule that only flags when this behavior is observed for the first time.
60+
61+
62+
*Possible Investigation Steps*
63+
64+
65+
- Identify the Actor: Review the `aws.cloudtrail.user_identity.arn` field to identify the user who requested the subscription. Verify if this actor typically performs such actions and has the necessary permissions. It may be unusual for this activity to originate from certain user types, such as an assumed role or federated user.
66+
- Review the Source IP: Check the `source.ip` field to determine the source of the request. If the request comes from an unexpected location or IP address, it may indicate a compromised account or unauthorized access.
67+
- Analyze the Request Parameters: Examine the `aws.cloudtrail.request_parameters` field to understand the details of the Scan request. Look for any unusual parameters or patterns that may indicate malicious intent. This also details the DynamoDB table being scanned.
68+
- Review Access Key: Check the `aws.cloudtrail.user_identity.access_key_id` field to identify the access key used for the request. Determine if this key is associated with a legitimate user or if it has been compromised.
69+
70+
71+
72+
*False Positive Analysis*
73+
74+
75+
- Historical User Actions: If the user has a history of scanning DynamoDB tables for legitimate purposes, this may not be a false positive. Review the user's activity logs to determine if this behavior is consistent with their normal actions.
76+
- Automated Processes: Some automated processes or applications may perform scans on DynamoDB tables as part of their functionality. If the user is associated with such a process, this may not be a false positive.
77+
78+
79+
*Response and Remediation*
80+
81+
82+
- Immediate Review and Reversal: If the Scan action is determined to be unauthorized, immediately revoke the user's access to the DynamoDB table and any associated resources. This may involve disabling the user's account or removing their permissions.
83+
- Investigate Compromise: If the Scan action is determined to be malicious, investigate the source of the request and any potential compromise of the user's account. This may involve reviewing access logs, resetting passwords, and enabling multi-factor authentication (MFA) for the affected user. If export options were used with the CLI or SDK, they may have been saved locally or to a remote location.
84+
- Review IAM Policies: Review the IAM policies associated with the user to ensure that they have the appropriate permissions for their role. If necessary, update the policies to restrict access to sensitive resources.
85+
- Monitor for Future Activity: Continue to monitor the user's activity for any further suspicious behavior. Set up additional alerts or logging to detect any future unauthorized access attempts.
86+
87+
88+
*Additional Information*
89+
90+
91+
For further guidance on managing and securing DynamoDB in AWS environments, refer to the https://docs.aws.amazon.com/amazondynamodb/latest/developerguide/security.html[AWS DynamoDB documentation] and AWS best practices for security.
92+
93+
94+
==== Setup
95+
96+
97+
DynamoDB data events must be enabled in CloudTrail to capture the Scan action. Ensure that the AWS CloudTrail service is configured to log data events for DynamoDB tables.
98+
99+
==== Rule query
100+
101+
102+
[source, js]
103+
----------------------------------
104+
event.dataset: "aws.cloudtrail"
105+
and event.provider: "dynamodb.amazonaws.com"
106+
and event.action: "Scan"
107+
and event.outcome: "success"
108+
109+
----------------------------------
110+
111+
*Framework*: MITRE ATT&CK^TM^
112+
113+
* Tactic:
114+
** Name: Exfiltration
115+
** ID: TA0010
116+
** Reference URL: https://attack.mitre.org/tactics/TA0010/
117+
* Technique:
118+
** Name: Exfiltration Over Web Service
119+
** ID: T1567
120+
** Reference URL: https://attack.mitre.org/techniques/T1567/
121+
* Tactic:
122+
** Name: Collection
123+
** ID: TA0009
124+
** Reference URL: https://attack.mitre.org/tactics/TA0009/
125+
* Technique:
126+
** Name: Data from Cloud Storage
127+
** ID: T1530
128+
** Reference URL: https://attack.mitre.org/techniques/T1530/

0 commit comments

Comments
 (0)