Skip to content

Commit b141ebc

Browse files
imays11MikaayensonAegrah
authored
[Rule Tunings] Reduce Usage of Flattened Fields in AWS Rules (#4892)
* [Rule Tunings] Reduce Usage of Flattened Fields in AWS Rules This PR is in part a response to the following issues regarding the future of flattened fields in AWS, which we use as an essential part of our ruleset. However, this is also in response to the ongoing ruleset audit. Some of the flattened fields used are not truly necessary for the alert to trigger or can be replaced by a different field. Those changes have been made here and our non_ecs file has been edited to remove the unnecessary fields. Additionally, flattened fields have been removed from highlighted fields, and from investigation guides. * Update discovery_ec2_userdata_request_for_ec2_instance.toml updated_date * Update execution_ssm_sendcommand_by_rare_user.toml updated_date * Update non-ecs-schema.json add necessary field for ModifyInstanceAttribute action * Update persistence_ec2_security_group_configuration_change_detection.toml added missing event.action AuthorizeSecurityGroupIngress, narrowed scope for ModifyInstanceAttribute action by adding a necessary flattened_field * Update privilege_escalation_iam_customer_managed_policy_attached_to_role.toml updated min_stack_version for new field target.entity.id * Update privilege_escalation_iam_customer_managed_policy_attached_to_role.toml * Update privilege_escalation_iam_update_assume_role_policy.toml updating min_stack to account of target.entity.id field * Update impact_s3_excessive_object_encryption_with_sse_c.toml adding highlighted fields * Update rules/integrations/aws/exfiltration_dynamodb_table_exported_to_s3.toml * Apply suggestions from code review --------- Co-authored-by: Mika Ayenson, PhD <[email protected]> Co-authored-by: Ruben Groenewoud <[email protected]>
1 parent c2880af commit b141ebc

12 files changed

+147
-189
lines changed

detection_rules/etc/non-ecs-schema.json

Lines changed: 4 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -155,28 +155,18 @@
155155
"auditd.data.a3": "keyword"
156156
},
157157
"logs-aws.cloudtrail-*": {
158-
"aws.cloudtrail.flattened.request_parameters.cidrIp": "keyword",
159-
"aws.cloudtrail.flattened.request_parameters.fromPort": "keyword",
160-
"aws.cloudtrail.flattened.request_parameters.roleArn": "keyword",
161-
"aws.cloudtrail.flattened.request_parameters.roleName": "keyword",
162-
"aws.cloudtrail.flattened.request_parameters.policyArn": "keyword",
158+
"aws.cloudtrail.flattened.request_parameters.ipPermissions.items.ipRanges.items.cidrIp": "keyword",
159+
"aws.cloudtrail.flattened.request_parameters.ipPermissions.items.fromPort": "keyword",
163160
"aws.cloudtrail.flattened.request_parameters.serialNumber": "keyword",
164161
"aws.cloudtrail.flattened.request_parameters.x-amz-server-side-encryption-customer-algorithm": "keyword",
165-
"aws.cloudtrail.flattened.additional_eventdata.SSEApplied": "keyword",
166-
"aws.cloudtrail.flattened.request_parameters.bucketName": "keyword",
167-
"aws.cloudtrail.flattened.request_parameters.key": "keyword",
168162
"aws.cloudtrail.flattened.request_parameters.includeDeprecated": "keyword",
169163
"aws.cloudtrail.flattened.request_parameters.withDecryption": "boolean",
170164
"aws.cloudtrail.flattened.request_parameters.instanceId": "keyword",
171-
"aws.cloudtrail.flattened.request_parameters.dryRun": "boolean",
172-
"aws.cloudtrail.flattened.request_parameters.clientToken": "keyword",
173-
"aws.cloudtrail.flattened.response_elements.s3BucketName": "keyword",
174-
"aws.cloudtrail.flattened.response_elements.tableArn": "keyword",
175165
"aws.cloudtrail.flattened.request_parameters.attribute": "keyword",
176166
"aws.cloudtrail.flattened.request_parameters.reason": "keyword",
177167
"aws.cloudtrail.flattened.request_parameters.omitted": "keyword",
178-
"aws.cloudtrail.flattened.request_parameters.ownersSet.items.owner": "keyword",
179-
"aws.cloudtrail.flattened.response_elements.documentDescription.documentType": "keyword"
168+
"aws.cloudtrail.flattened.response_elements.documentDescription.documentType": "keyword",
169+
"aws.cloudtrail.flattened.request_parameters.groupSet.items.groupId": "keyword"
180170
},
181171
"logs-azure.signinlogs-*": {
182172
"azure.signinlogs.properties.conditional_access_audiences.application_id": "keyword",

rules/integrations/aws/credential_access_retrieve_secure_string_parameters_via_ssm.toml

Lines changed: 23 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -2,27 +2,19 @@
22
creation_date = "2024/04/12"
33
integration = ["aws"]
44
maturity = "production"
5-
updated_date = "2025/01/27"
5+
updated_date = "2025/07/09"
66

77
[rule]
88
author = ["Elastic"]
99
description = """
10-
Detects the first occurrence of a user identity accessing AWS Systems Manager (SSM) SecureString parameters using the
11-
GetParameter or GetParameters API actions with credentials in the request parameters. This could indicate that the user
12-
is accessing sensitive information. This rule detects when a user accesses a SecureString parameter with the
13-
`withDecryption` parameter set to true. This is a
14-
[NewTerms](https://www.elastic.co/guide/en/security/current/rules-ui-create.html#create-new-terms-rule) rule that
15-
detects the first occurrence of a specific AWS ARN accessing SecureString parameters with decryption within the last 10
16-
days.
10+
Detects the first occurrence of a user identity accessing AWS Systems Manager (SSM) SecureString parameters using the GetParameter or GetParameters API actions with credentials in the request parameters. This could indicate that the user is accessing sensitive information. This rule detects when a user accesses a SecureString parameter with the withDecryption parameter set to true. This is a New Terms rule that detects the first occurrence of an AWS identity accessing SecureString parameters with decryption.
1711
"""
1812
false_positives = [
1913
"""
20-
Users may legitimately access AWS Systems Manager (SSM) parameters using the GetParameter, GetParameters, or
21-
DescribeParameters API actions with credentials in the request parameters. Ensure that the user has a legitimate
22-
reason to access the parameters and that the credentials are secured.
14+
Users may legitimately access AWS Systems Manager (SSM) parameters using the GetParameter, GetParameters, or DescribeParameters API actions with credentials in the request parameters. Ensure that the user has a legitimate reason to access the parameters and that the credentials are secured.
2315
""",
2416
]
25-
from = "now-9m"
17+
from = "now-6m"
2618
index = ["filebeat-*", "logs-aws.cloudtrail-*"]
2719
language = "kuery"
2820
license = "Elastic License v2"
@@ -39,8 +31,8 @@ Adversaries may target SecureStrings to retrieve sensitive information such as e
3931
#### Possible Investigation Steps
4032
4133
- **Review the Access Event**: Identify the specific API call (`GetParameter` or `GetParameters`) that triggered the rule. Examine the `request_parameters` for `withDecryption` set to true and the name of the accessed parameter.
42-
- **Verify User Identity and Access Context**: Check the `user_identity` details to understand who accessed the parameter and their role within the organization. This includes checking the ARN and access key ID to determine if the access was authorized.
43-
- **User ID**: Review the `user.id` field to identify the specific user or role that initiated the API call. Note that the ARN associated may be an assumed role and may not directly correspond to a human user.
34+
- **Verify User Identity and Access Context**: Check the `aws.cloudtrail.user_identity` details to understand who accessed the parameter and their role within the organization. This includes checking the ARN and access key ID to determine if the access was authorized.
35+
- **User ID**: Review the `user.name` field to identify the specific user or role that initiated the API call. Note that the ARN associated may be an assumed role and may not directly correspond to a human user.
4436
- **Contextualize with User Behavior**: Assess whether the access pattern fits the user’s normal behavior or job responsibilities. Investigate any out-of-pattern activities around the time of the event.
4537
- **Analyze Geographic and IP Context**: Using the `source.ip` and `source.geo` information, verify if the request came from a trusted location or if there are any anomalies that suggest a compromised account.
4638
- **Inspect Related CloudTrail Events**: Look for other related events in CloudTrail to see if there was unusual activity before or after this event, such as unusual login attempts, changes to permissions, or other API calls that could indicate broader unauthorized actions.
@@ -93,6 +85,22 @@ event.dataset: aws.cloudtrail
9385
)
9486
'''
9587

88+
[rule.investigation_fields]
89+
field_names = [
90+
"@timestamp",
91+
"user.name",
92+
"user_agent.original",
93+
"source.ip",
94+
"aws.cloudtrail.user_identity.type",
95+
"aws.cloudtrail.user_identity.arn",
96+
"aws.cloudtrail.user_identity.access_key_id",
97+
"target.entity.id",
98+
"event.action",
99+
"event.outcome",
100+
"cloud.account.id",
101+
"cloud.region",
102+
"aws.cloudtrail.request_parameters"
103+
]
96104

97105
[[rule.threat]]
98106
framework = "MITRE ATT&CK"
@@ -114,7 +122,7 @@ reference = "https://attack.mitre.org/tactics/TA0006/"
114122

115123
[rule.new_terms]
116124
field = "new_terms_fields"
117-
value = ["aws.cloudtrail.user_identity.arn"]
125+
value = ["cloud.account.id", "user.name"]
118126
[[rule.new_terms.history_window_start]]
119127
field = "history_window_start"
120128
value = "now-10d"

rules/integrations/aws/defense_evasion_vpc_security_group_ingress_rule_added_for_remote_connections.toml

Lines changed: 22 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -2,26 +2,21 @@
22
creation_date = "2024/04/16"
33
integration = ["aws"]
44
maturity = "production"
5-
updated_date = "2025/01/15"
5+
updated_date = "2025/07/10"
66

77
[rule]
88
author = ["Elastic"]
99
description = """
10-
Identifies when a specified inbound (ingress) rule is added or adjusted for a VPC security group in AWS EC2. This rule
11-
detects when a security group rule is added that allows traffic from any IP address or from a specific IP address to
12-
common remote access ports, such as 22 (SSH) or 3389 (RDP). Adversaries may add these rules to allow remote access to
13-
VPC instances from any location, increasing the attack surface and potentially exposing the instances to unauthorized
14-
access.
10+
Identifies when a specified inbound (ingress) rule is added or adjusted for a VPC security group in AWS EC2. This rule detects when a security group rule is added that allows traffic from any IP address or from a specific IP address to common remote access ports, such as 22 (SSH) or 3389 (RDP). Adversaries may add these rules to allow remote access to VPC instances from any location, increasing the attack surface and potentially exposing the instances to unauthorized access.
1511
"""
1612
false_positives = [
1713
"""
18-
Administrators may legitimately add security group rules to allow traffic from any IP address or from specific IP
19-
addresses to common remote access ports.
14+
Administrators may legitimately add security group rules to allow traffic from any IP address or from specific IP addresses to common remote access ports.
2015
""",
2116
]
22-
from = "now-60m"
17+
from = "now-6m"
2318
index = ["filebeat-*", "logs-aws.cloudtrail-*"]
24-
interval = "10m"
19+
interval = "5m"
2520
language = "kuery"
2621
license = "Elastic License v2"
2722
name = "Insecure AWS EC2 VPC Security Group Ingress Rule Added"
@@ -83,11 +78,25 @@ event.dataset: "aws.cloudtrail"
8378
and event.provider: ec2.amazonaws.com
8479
and event.action: AuthorizeSecurityGroupIngress
8580
and event.outcome: success
86-
and aws.cloudtrail.flattened.request_parameters.cidrIp: ("0.0.0.0/0" or "::/0")
87-
and aws.cloudtrail.flattened.request_parameters.fromPort: (
81+
and aws.cloudtrail.flattened.request_parameters.ipPermissions.items.ipRanges.items.cidrIp: ("0.0.0.0/0" or "::/0")
82+
and aws.cloudtrail.flattened.request_parameters.ipPermissions.items.fromPort: (
8883
21 or 22 or 23 or 445 or 3389 or 5985 or 5986)
8984
'''
90-
85+
[rule.investigation_fields]
86+
field_names = [
87+
"@timestamp",
88+
"user.name",
89+
"user_agent.original",
90+
"source.ip",
91+
"aws.cloudtrail.user_identity.arn",
92+
"aws.cloudtrail.user_identity.type",
93+
"aws.cloudtrail.user_identity.access_key_id",
94+
"event.action",
95+
"event.outcome",
96+
"cloud.account.id",
97+
"cloud.region",
98+
"aws.cloudtrail.request_parameters"
99+
]
91100

92101
[[rule.threat]]
93102
framework = "MITRE ATT&CK"

rules/integrations/aws/discovery_ec2_deprecated_ami_discovery.toml

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

77
[rule]
88
author = ["Elastic"]
@@ -39,7 +39,7 @@ This rule detects when a user queries AWS for deprecated Amazon Machine Images (
3939
- Analyze the `user_agent.original` field to determine the client or tool used (e.g., AWS CLI, SDK).
4040
4141
3. **Validate the Query Context**:
42-
- Inspect the `aws.cloudtrail.flattened.request_parameters` field
42+
- Inspect the `aws.cloudtrail.request_parameters` field
4343
- Determine if the request is part of legitimate activity, such as:
4444
- Security assessments or vulnerability scans.
4545
- Maintenance or testing of legacy systems.
@@ -109,7 +109,6 @@ event.dataset: "aws.cloudtrail"
109109
and event.action: "DescribeImages"
110110
and event.outcome: "success"
111111
and aws.cloudtrail.flattened.request_parameters.includeDeprecated: "true"
112-
and aws.cloudtrail.flattened.request_parameters.ownersSet.items.owner: *
113112
'''
114113
[rule.investigation_fields]
115114
field_names = [

rules/integrations/aws/discovery_ec2_userdata_request_for_ec2_instance.toml

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

77
[rule]
88
author = ["Elastic"]
@@ -144,7 +144,7 @@ reference = "https://attack.mitre.org/tactics/TA0006/"
144144

145145
[rule.new_terms]
146146
field = "new_terms_fields"
147-
value = ["user.name", "aws.cloudtrail.flattened.request_parameters.instanceId"]
147+
value = ["cloud.account.id", "user.name", "aws.cloudtrail.flattened.request_parameters.instanceId"]
148148
[[rule.new_terms.history_window_start]]
149149
field = "history_window_start"
150150
value = "now-14d"

rules/integrations/aws/execution_ssm_sendcommand_by_rare_user.toml

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

77
[rule]
88
author = ["Elastic"]
@@ -29,8 +29,8 @@ This rule detects the execution of commands or scripts on EC2 instances using AW
2929
#### Possible Investigation Steps
3030
3131
- **Identify the Target Instance**:
32-
- **Instance ID**: Review the `aws.cloudtrail.flattened.request_parameters.instanceIds` field to identify which EC2 instances were targeted by this command. Confirm if these instances are expected to be managed through SSM.
33-
- **Document Used**: Check the `aws.cloudtrail.flattened.request_parameters.documentName` field, which specifies the document or script being executed. Commands such as `RunShellScript` or `RunPowerShellScript` can indicate interactive sessions or script-based interactions.
32+
- **Instance ID**: Review the `aws.cloudtrail.request_parameters` field to identify which EC2 instances were targeted by this command. Confirm if these instances are expected to be managed through SSM.
33+
- **Document Used**: Check the `aws.cloudtrail.request_parameters` field, which specifies the name of the document or script being executed. Commands such as `RunShellScript` or `RunPowerShellScript` can indicate interactive sessions or script-based interactions.
3434
3535
- **Review User Context**:
3636
- **User Identity**: Inspect the `aws.cloudtrail.user_identity.arn` field to determine the user or role executing the `SendCommand`. If this user is not typically involved in EC2 or SSM interactions, this could indicate unauthorized access.

0 commit comments

Comments
 (0)