Skip to content

Commit a8f0130

Browse files
Merge branch 'main' into Samirbous-patch-1
2 parents 4b0de8b + dd4576d commit a8f0130

19 files changed

+1022
-230
lines changed

detection_rules/etc/non-ecs-schema.json

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@
1313
"AccessList": "keyword",
1414
"AccessMask": "keyword",
1515
"AccessMaskDescription": "keyword",
16+
"AdditionalInfo": "keyword",
1617
"AllowedToDelegateTo": "keyword",
1718
"AttributeLDAPDisplayName": "keyword",
1819
"AttributeValue": "keyword",
@@ -168,7 +169,11 @@
168169
"aws.cloudtrail.flattened.request_parameters.dryRun": "boolean",
169170
"aws.cloudtrail.flattened.request_parameters.clientToken": "keyword",
170171
"aws.cloudtrail.flattened.response_elements.s3BucketName": "keyword",
171-
"aws.cloudtrail.flattened.response_elements.tableArn": "keyword"
172+
"aws.cloudtrail.flattened.response_elements.tableArn": "keyword",
173+
"aws.cloudtrail.flattened.request_parameters.attribute": "keyword",
174+
"aws.cloudtrail.flattened.request_parameters.reason": "keyword",
175+
"aws.cloudtrail.flattened.request_parameters.omitted": "keyword",
176+
"aws.cloudtrail.flattened.request_parameters.ownersSet.items.owner": "keyword"
172177
},
173178
"logs-azure.signinlogs-*": {
174179
"azure.signinlogs.properties.conditional_access_audiences.application_id": "keyword",

pyproject.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[project]
22
name = "detection_rules"
3-
version = "1.2.15"
3+
version = "1.2.19"
44
description = "Detection Rules is the home for rules used by Elastic Security. This repository is used for the development, maintenance, testing, validation, and release of rules for Elastic Security’s Detection Engine."
55
readme = "README.md"
66
requires-python = ">=3.12"
Lines changed: 126 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,126 @@
1+
[metadata]
2+
creation_date = "2025/06/10"
3+
integration = ["aws"]
4+
maturity = "production"
5+
updated_date = "2025/06/10"
6+
7+
[rule]
8+
author = ["Elastic"]
9+
description = """
10+
Identifies the evasion of cloudtrail logging for IAM actions involving policy creation, modification or attachment. When making certain policy-related API calls, an adversary may pad the associated policy document with whitespaces to trigger CloudTrail’s logging size constraints, resulting in incomplete logging where critical details about the policy are omitted. By exploiting this gap, threat actors can bypass monitoring performed through CloudTrail and can effectively obscure unauthorized changes. This rule looks for IAM API calls with the requestParameters property containing reason:”requestParameters too large” and omitted:true.
11+
"""
12+
false_positives = [
13+
"""
14+
There is no known legitimate reason for padding policies with white spaces to the extent it would take to trigger Cloudtrail's logging constraints. Any instance of this should be investigated.
15+
""",
16+
]
17+
from = "now-6m"
18+
interval = "5m"
19+
index = ["filebeat-*", "logs-aws.cloudtrail-*"]
20+
language = "kuery"
21+
license = "Elastic License v2"
22+
name = "AWS CloudTrail Log Evasion"
23+
note = """## Triage and analysis
24+
25+
### Investigating AWS CloudTrail Log Evasion
26+
27+
Amazon CloudTrail is a service that enables governance, compliance, operational auditing, and risk auditing of your Amazon Web Services account. With CloudTrail, you can log, continuously monitor, and retain account activity related to actions across your Amazon Web Services infrastructure. In the `requestParameters` field of CloudTrail logs, a policy that was created/updated is typically displayed, including details such as the policy name and the full policy document content. However, when policies padded with large amounts of insignificant whitespace (such as spaces, tabs, or line breaks), reach a size range of 102,401 to 131,072 characters they begin to be omitted from CloudTrail logs and are instead rendered as "requestParameters too large". Attackers can do this to cover their tracks and impact security monitoring that relies on this source. This rule looks for IAM API calls with the requestParameters property containing reason:”requestParameters too large” and omitted:true.
28+
29+
#### Possible investigation steps
30+
31+
- Identify the user account that performed the action and whether it should perform this kind of action.
32+
- Investigate other alerts associated with the user account during the past 48 hours.
33+
- Contact the account and resource owners and confirm whether they are aware of this activity.
34+
- Check if this operation was approved and performed according to the organization's change management policy.
35+
- Considering the source IP address and geolocation of the user who issued the command:
36+
- Do they look normal for the user?
37+
- 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?
38+
- 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?
39+
- Examine the newly created or modified policy highlighted in `target.entity.id`.
40+
- If no policy name is included for event.actions like `PutRolePolicy`, analyze the inline policies attached to the `actor.entity.id` for unexpected permission changes or additions.
41+
- 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.
42+
43+
### False positive analysis
44+
45+
- If this rule is noisy in your environment due to expected activity, consider adding exceptions — preferably with a combination of user and IP address conditions. However, this behavior is rarely seen in legitimate operations and should be thoroughly investigated.
46+
47+
### Response and remediation
48+
49+
- Initiate the incident response process based on the outcome of the triage.
50+
- Disable or limit the account during the investigation and response.
51+
- Identify the possible impact of the incident and prioritize accordingly; the following actions can help you gain context:
52+
- Identify the account role in the cloud environment.
53+
- Assess the criticality of affected services and servers.
54+
- Work with your IT team to identify and minimize the impact on users.
55+
- Identify if the attacker is moving laterally and compromising other accounts, servers, or services.
56+
- Identify any regulatory or legal ramifications related to this activity.
57+
- Investigate credential exposure on systems compromised or used by the attacker to ensure all compromised accounts are identified. Reset passwords 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.
58+
- Check if unauthorized new users were created, remove unauthorized new accounts, and request password resets for other IAM users.
59+
- Consider enabling multi-factor authentication for users.
60+
- Review the permissions assigned to the implicated user to ensure that the least privilege principle is being followed.
61+
- Implement security best practices [outlined](https://aws.amazon.com/premiumsupport/knowledge-center/security-best-practices/) by AWS.
62+
- Take the actions needed to return affected systems, data, or services to their normal operational levels.
63+
- Identify the initial vector abused by the attacker and take action to prevent reinfection via the same vector.
64+
- 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).
65+
66+
## Setup
67+
68+
The AWS Fleet integration, Filebeat module, or similarly structured data is required to be compatible with this rule."""
69+
references = [
70+
"https://permiso.io/blog/cloudtrail-logging-evasion-where-policy-size-matters",
71+
]
72+
risk_score = 47
73+
rule_id = "9ebd48ac-a0e2-430a-a219-fe072a50146b"
74+
severity = "medium"
75+
tags = [
76+
"Domain: Cloud",
77+
"Data Source: AWS",
78+
"Data Source: Amazon Web Services",
79+
"Data Source: AWS IAM",
80+
"Use Case: Log Auditing",
81+
"Resources: Investigation Guide",
82+
"Tactic: Defense Evasion",
83+
]
84+
timestamp_override = "event.ingested"
85+
type = "query"
86+
87+
query = '''
88+
event.dataset: aws.cloudtrail and event.provider: iam.amazonaws.com and aws.cloudtrail.flattened.request_parameters.reason: "requestParameters too large" and aws.cloudtrail.flattened.request_parameters.omitted : true and event.outcome: success
89+
'''
90+
91+
[rule.investigation_fields]
92+
field_names = [
93+
"@timestamp",
94+
"user.name",
95+
"user_agent.original",
96+
"source.ip",
97+
"aws.cloudtrail.user_identity.arn",
98+
"aws.cloudtrail.user_identity.type",
99+
"aws.cloudtrail.user_identity.access_key_id",
100+
"event.action",
101+
"event.outcome",
102+
"target.entity.id",
103+
"cloud.account.id",
104+
"cloud.region",
105+
"aws.cloudtrail.request_parameters",
106+
"aws.cloudtrail.response_elements"
107+
]
108+
109+
[[rule.threat]]
110+
framework = "MITRE ATT&CK"
111+
[[rule.threat.technique]]
112+
id = "T1562"
113+
name = "Impair Defenses"
114+
reference = "https://attack.mitre.org/techniques/T1562/"
115+
[[rule.threat.technique.subtechnique]]
116+
id = "T1562.008"
117+
name = "Disable or Modify Cloud Logs"
118+
reference = "https://attack.mitre.org/techniques/T1562/008/"
119+
120+
121+
122+
[rule.threat.tactic]
123+
id = "TA0005"
124+
name = "Defense Evasion"
125+
reference = "https://attack.mitre.org/tactics/TA0005/"
126+

rules/integrations/aws/discovery_ec2_deprecated_ami_discovery.toml

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

77
[rule]
88
author = ["Elastic"]
99
description = """
10-
Identifies when a user has queried for deprecated Amazon Machine Images (AMIs) in AWS. This may indicate an adversary
11-
whom is looking for outdated AMIs that may be vulnerable to exploitation. While deprecated AMIs are not inherently
12-
malicious or indicate breach, they may be more susceptible to vulnerabilities and should be investigated for potential
13-
security risks.
10+
Identifies when a user has queried for deprecated Amazon Machine Images (AMIs) in AWS. This may indicate an adversary looking for outdated AMIs that may be vulnerable to exploitation. While deprecated AMIs are not inherently malicious or indicative of a breach, they may be more susceptible to vulnerabilities and should be investigated for potential security risks.
1411
"""
1512
false_positives = [
1613
"Legitimate use of deprecated AMIs for testing or development purposes.",
1714
"Automated tools or scripts that query for deprecated AMIs as part of a security assessment.",
1815
"Misconfigured applications or services that rely on deprecated AMIs for compatibility reasons.",
1916
"Administrators or developers who are unaware of the deprecation status of AMIs they are using.",
2017
]
21-
from = "now-9m"
18+
from = "now-6m"
19+
interval = "5m"
2220
index = ["filebeat-*", "logs-aws.cloudtrail-*"]
2321
language = "kuery"
2422
license = "Elastic License v2"
@@ -34,29 +32,24 @@ This rule detects when a user queries AWS for deprecated Amazon Machine Images (
3432
1. **Identify the User Performing the Query**:
3533
- Review the `aws.cloudtrail.user_identity.arn` field to determine the AWS user or role making the request.
3634
- Check `aws.cloudtrail.user_identity.type` and `aws.cloudtrail.user_identity.access_key_id` to verify the type of access (e.g., IAM user, role, or federated identity).
37-
- Investigate the `related.user` field for additional user context.
3835
3936
2. **Analyze the Source of the Request**:
4037
- Review the `source.ip` field to determine the IP address of the source making the request.
4138
- Check `source.geo` for the geographic location of the IP address.
4239
- Analyze the `user_agent.original` field to determine the client or tool used (e.g., AWS CLI, SDK).
4340
44-
3. **Review the Request Details**:
45-
- Inspect the `aws.cloudtrail.flattened.request_parameters` field for query parameters, such as `includeDeprecated=true`.
46-
- Confirm that the request explicitly includes deprecated AMIs (`includeDeprecated=true`) and is tied to specific owners via the `ownersSet` field.
47-
- Verify the `event.action` is `DescribeImages` and the `event.outcome` is `success`.
48-
49-
4. **Validate the Query Context**:
41+
3. **Validate the Query Context**:
42+
- Inspect the `aws.cloudtrail.flattened.request_parameters` field
5043
- Determine if the request is part of legitimate activity, such as:
5144
- Security assessments or vulnerability scans.
5245
- Maintenance or testing of legacy systems.
5346
- Check if the query aligns with recent changes in the AWS environment, such as new configurations or services.
5447
55-
5. **Correlate with Other Events**:
48+
4. **Correlate with Other Events**:
5649
- Investigate additional AWS API calls from the same user or IP address for signs of reconnaissance or exploitation.
5750
- Review logs for related actions, such as launching instances from deprecated AMIs (`RunInstances` API call).
5851
59-
6. **Assess Security Risks**:
52+
5. **Assess Security Risks**:
6053
- Evaluate the use of deprecated AMIs within your environment and their associated vulnerabilities.
6154
- Ensure that deprecated AMIs are not being used in production environments or systems exposed to external threats.
6255
@@ -116,9 +109,23 @@ event.dataset: "aws.cloudtrail"
116109
and event.action: "DescribeImages"
117110
and event.outcome: "success"
118111
and aws.cloudtrail.flattened.request_parameters.includeDeprecated: "true"
119-
and aws.cloudtrail.request_parameters: *owner=*
112+
and aws.cloudtrail.flattened.request_parameters.ownersSet.items.owner: *
120113
'''
121-
114+
[rule.investigation_fields]
115+
field_names = [
116+
"@timestamp",
117+
"user.name",
118+
"user_agent.original",
119+
"source.ip",
120+
"aws.cloudtrail.user_identity.arn",
121+
"aws.cloudtrail.user_identity.type",
122+
"aws.cloudtrail.user_identity.access_key_id",
123+
"event.action",
124+
"event.outcome",
125+
"cloud.account.id",
126+
"cloud.region",
127+
"aws.cloudtrail.request_parameters"
128+
]
122129

123130
[[rule.threat]]
124131
framework = "MITRE ATT&CK"
@@ -133,15 +140,3 @@ id = "TA0007"
133140
name = "Discovery"
134141
reference = "https://attack.mitre.org/tactics/TA0007/"
135142

136-
[rule.investigation_fields]
137-
field_names = [
138-
"aws.cloudtrail.user_identity.arn",
139-
"aws.cloudtrail.user_identity.type",
140-
"aws.cloudtrail.user_identity.access_key_id",
141-
"source.ip",
142-
"cloud.account.id",
143-
"cloud.region",
144-
"user_agent.original",
145-
"event.action",
146-
]
147-

rules/integrations/aws/discovery_ec2_userdata_request_for_ec2_instance.toml

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

77
[rule]
88
author = ["Elastic"]
99
description = """
10-
Identifies discovery request `DescribeInstanceAttribute` with the attribute userData and instanceId in AWS CloudTrail
10+
Identifies discovery request DescribeInstanceAttribute with the attribute userData and instanceId in AWS CloudTrail
1111
logs. This may indicate an attempt to retrieve user data from an EC2 instance. Adversaries may use this information to
1212
gather sensitive data from the instance such as hardcoded credentials or to identify potential vulnerabilities. This is
13-
a [New Terms](https://www.elastic.co/guide/en/security/current/rules-ui-create.html#create-new-terms-rule) rule that
14-
identifies when `aws.cloudtrail.user_identity.arn` requests the user data for a specific
15-
`aws.cloudtrail.flattened.request_parameters.instanceId` from an EC2 instance in the last 14 days.
13+
a New Terms rule that identifies the first time an IAM user or role requests the user data for a specific EC2 instance.
1614
"""
17-
from = "now-9m"
15+
from = "now-6m"
16+
interval = "5m"
1817
index = ["filebeat-*", "logs-aws.cloudtrail-*"]
1918
language = "kuery"
2019
license = "Elastic License v2"
@@ -36,12 +35,7 @@ This rule detects requests to retrieve the `userData` attribute of an EC2 instan
3635
- **User Identity**: Inspect the `aws.cloudtrail.user_identity.arn` field to identify the user or role that executed the `DescribeInstanceAttribute` action. Investigate whether this user typically performs such actions.
3736
- **Access Patterns**: Validate whether the user or role has the necessary permissions and whether the frequency of this action aligns with expected behavior.
3837
- **Access Key ID**: Check the `aws.cloudtrail.user_identity.access_key_id` field to determine the key used to make the request as it may be compromised.
39-
40-
- **Analyze Request Details**:
41-
- **Parameters**: Verify that the `attribute=userData` parameter was explicitly requested. This indicates intentional access to user data.
4238
- **Source IP and Geolocation**: Check the `source.address` and `source.geo` fields to validate whether the request originated from a trusted location or network. Unexpected geolocations can indicate adversarial activity.
43-
44-
- **Review Source Tool**:
4539
- **User Agent**: Inspect the `user_agent.original` field to determine the tool or client used (e.g., Terraform, AWS CLI). Legitimate automation tools may trigger this activity, but custom or unknown user agents may indicate malicious intent.
4640
4741
- **Check for Related Activity**:
@@ -94,13 +88,29 @@ event.dataset: "aws.cloudtrail"
9488
and event.provider: "ec2.amazonaws.com"
9589
and event.action: "DescribeInstanceAttribute"
9690
and event.outcome: "success"
97-
and aws.cloudtrail.request_parameters: (*attribute=userData* and *instanceId*)
91+
and aws.cloudtrail.flattened.request_parameters.attribute: "userData"
9892
and not aws.cloudtrail.user_identity.invoked_by: (
9993
"AWS Internal" or
10094
"cloudformation.amazonaws.com"
10195
)
10296
'''
10397

98+
[rule.investigation_fields]
99+
field_names = [
100+
"@timestamp",
101+
"user.name",
102+
"user_agent.original",
103+
"source.ip",
104+
"aws.cloudtrail.user_identity.arn",
105+
"aws.cloudtrail.user_identity.type",
106+
"aws.cloudtrail.user_identity.access_key_id",
107+
"event.action",
108+
"event.outcome",
109+
"cloud.account.id",
110+
"cloud.region",
111+
"aws.cloudtrail.request_parameters",
112+
"aws.cloudtrail.response_elements"
113+
]
104114

105115
[[rule.threat]]
106116
framework = "MITRE ATT&CK"
@@ -134,7 +144,7 @@ reference = "https://attack.mitre.org/tactics/TA0006/"
134144

135145
[rule.new_terms]
136146
field = "new_terms_fields"
137-
value = ["aws.cloudtrail.user_identity.arn", "aws.cloudtrail.flattened.request_parameters.instanceId"]
147+
value = ["user.name", "aws.cloudtrail.flattened.request_parameters.instanceId"]
138148
[[rule.new_terms.history_window_start]]
139149
field = "history_window_start"
140150
value = "now-14d"

0 commit comments

Comments
 (0)