Skip to content

Commit 7de8d1d

Browse files
Update latest docs (#6892)
1 parent c91ec84 commit 7de8d1d

File tree

80 files changed

+7633
-131
lines changed

Some content is hidden

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

80 files changed

+7633
-131
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,129 @@
1+
[[prebuilt-rule-8-16-16-aws-cloudtrail-log-evasion]]
2+
=== AWS CloudTrail Log Evasion
3+
4+
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.
5+
6+
*Rule type*: query
7+
8+
*Rule indices*:
9+
10+
* filebeat-*
11+
* logs-aws.cloudtrail-*
12+
13+
*Severity*: medium
14+
15+
*Risk score*: 47
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://permiso.io/blog/cloudtrail-logging-evasion-where-policy-size-matters
26+
27+
*Tags*:
28+
29+
* Domain: Cloud
30+
* Data Source: AWS
31+
* Data Source: Amazon Web Services
32+
* Data Source: AWS IAM
33+
* Use Case: Log Auditing
34+
* Resources: Investigation Guide
35+
* Tactic: Defense Evasion
36+
37+
*Version*: 1
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 CloudTrail Log Evasion*
55+
56+
57+
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.
58+
59+
60+
*Possible investigation steps*
61+
62+
63+
- Identify the user account that performed the action and whether it should perform this kind of action.
64+
- Investigate other alerts associated with the user account during the past 48 hours.
65+
- Contact the account and resource owners and confirm whether they are aware of this activity.
66+
- Check if this operation was approved and performed according to the organization's change management policy.
67+
- Considering the source IP address and geolocation of the user who issued the command:
68+
- Do they look normal for the user?
69+
- 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?
70+
- 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?
71+
- Examine the newly created or modified policy highlighted in `target.entity.id`.
72+
- 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.
73+
- 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.
74+
75+
76+
*False positive analysis*
77+
78+
79+
- 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.
80+
81+
82+
*Response and remediation*
83+
84+
85+
- Initiate the incident response process based on the outcome of the triage.
86+
- Disable or limit the account during the investigation and response.
87+
- Identify the possible impact of the incident and prioritize accordingly; the following actions can help you gain context:
88+
- Identify the account role in the cloud environment.
89+
- Assess the criticality of affected services and servers.
90+
- Work with your IT team to identify and minimize the impact on users.
91+
- Identify if the attacker is moving laterally and compromising other accounts, servers, or services.
92+
- Identify any regulatory or legal ramifications related to this activity.
93+
- 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.
94+
- Check if unauthorized new users were created, remove unauthorized new accounts, and request password resets for other IAM users.
95+
- Consider enabling multi-factor authentication for users.
96+
- Review the permissions assigned to the implicated user to ensure that the least privilege principle is being followed.
97+
- Implement security best practices https://aws.amazon.com/premiumsupport/knowledge-center/security-best-practices/[outlined] by AWS.
98+
- Take the actions needed to return affected systems, data, or services to their normal operational levels.
99+
- Identify the initial vector abused by the attacker and take action to prevent reinfection via the same vector.
100+
- 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).
101+
102+
==== Setup
103+
104+
105+
The AWS Fleet integration, Filebeat module, or similarly structured data is required to be compatible with this rule.
106+
107+
==== Rule query
108+
109+
110+
[source, js]
111+
----------------------------------
112+
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
113+
114+
----------------------------------
115+
116+
*Framework*: MITRE ATT&CK^TM^
117+
118+
* Tactic:
119+
** Name: Defense Evasion
120+
** ID: TA0005
121+
** Reference URL: https://attack.mitre.org/tactics/TA0005/
122+
* Technique:
123+
** Name: Impair Defenses
124+
** ID: T1562
125+
** Reference URL: https://attack.mitre.org/techniques/T1562/
126+
* Sub-technique:
127+
** Name: Disable or Modify Cloud Logs
128+
** ID: T1562.008
129+
** Reference URL: https://attack.mitre.org/techniques/T1562/008/
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,149 @@
1+
[[prebuilt-rule-8-16-16-aws-ec2-deprecated-ami-discovery]]
2+
=== AWS EC2 Deprecated AMI Discovery
3+
4+
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.
5+
6+
*Rule type*: query
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://hackingthe.cloud/aws/exploitation/Misconfigured_Resource-Based_Policies/exploting_public_resources_attack_playbook/
26+
27+
*Tags*:
28+
29+
* Domain: Cloud
30+
* Data Source: AWS
31+
* Data Source: AWS EC2
32+
* Resources: Investigation Guide
33+
* Use Case: Threat Detection
34+
* Tactic: Discovery
35+
36+
*Version*: 5
37+
38+
*Rule authors*:
39+
40+
* Elastic
41+
42+
*Rule license*: Elastic License v2
43+
44+
45+
==== Investigation guide
46+
47+
48+
49+
*Triage and analysis*
50+
51+
52+
53+
*Investigating AWS EC2 Deprecated AMI Discovery*
54+
55+
56+
This rule detects when a user queries AWS for deprecated Amazon Machine Images (AMIs). While deprecated AMIs are not inherently malicious, their use can introduce vulnerabilities or misconfigurations. Adversaries may exploit deprecated AMIs in search of outdated or unpatched systems. Investigating these queries can help identify potential risks or misconfigurations.
57+
58+
59+
*Possible Investigation Steps*
60+
61+
62+
1. **Identify the User Performing the Query**:
63+
- Review the `aws.cloudtrail.user_identity.arn` field to determine the AWS user or role making the request.
64+
- 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).
65+
66+
2. **Analyze the Source of the Request**:
67+
- Review the `source.ip` field to determine the IP address of the source making the request.
68+
- Check `source.geo` for the geographic location of the IP address.
69+
- Analyze the `user_agent.original` field to determine the client or tool used (e.g., AWS CLI, SDK).
70+
71+
3. **Validate the Query Context**:
72+
- Inspect the `aws.cloudtrail.flattened.request_parameters` field
73+
- Determine if the request is part of legitimate activity, such as:
74+
- Security assessments or vulnerability scans.
75+
- Maintenance or testing of legacy systems.
76+
- Check if the query aligns with recent changes in the AWS environment, such as new configurations or services.
77+
78+
4. **Correlate with Other Events**:
79+
- Investigate additional AWS API calls from the same user or IP address for signs of reconnaissance or exploitation.
80+
- Review logs for related actions, such as launching instances from deprecated AMIs (`RunInstances` API call).
81+
82+
5. **Assess Security Risks**:
83+
- Evaluate the use of deprecated AMIs within your environment and their associated vulnerabilities.
84+
- Ensure that deprecated AMIs are not being used in production environments or systems exposed to external threats.
85+
86+
87+
*False Positive Analysis*
88+
89+
90+
- **Legitimate Use**: Users may query for deprecated AMIs for testing or compatibility purposes.
91+
- **Automated Tools**: Security or compliance tools might query deprecated AMIs as part of regular assessments.
92+
- **Misconfigured Services**: Legacy systems may rely on deprecated AMIs for compatibility, leading to legitimate queries.
93+
94+
95+
*Response and Remediation*
96+
97+
98+
1. **Immediate Actions**:
99+
- Verify the intent of the user querying for deprecated AMIs.
100+
- Restrict IAM permissions to prevent unauthorized access to deprecated AMIs.
101+
102+
2. **Mitigation Steps**:
103+
- Identify and replace deprecated AMIs in use with supported and updated AMIs.
104+
- Update AWS IAM policies to minimize permissions for querying or using deprecated AMIs.
105+
106+
3. **Enhance Monitoring**:
107+
- Enable alerts for future queries involving deprecated AMIs or other unusual API activity.
108+
- Monitor CloudTrail logs for additional reconnaissance or suspicious behavior.
109+
110+
4. **Security Audits**:
111+
- Conduct a review of all AMIs in use across your environment to identify outdated or deprecated images.
112+
- Remove any deprecated AMIs from production environments and restrict their usage to isolated testing.
113+
114+
5. **Add Rule Exceptions**:
115+
- Create exceptions for legitimate use cases or automated tools that query for deprecated AMIs.
116+
- Document and communicate the exceptions to relevant teams to avoid future alerts.
117+
118+
119+
*Additional Resources*
120+
121+
122+
- https://docs.aws.amazon.com/AWSEC2/latest/UserGuide/AMIs.html[AWS Documentation: AMI Lifecycle Management]
123+
- https://docs.aws.amazon.com/AWSEC2/latest/UserGuide/ami-deprecate.html[AWS Documentation: Deprecated AMIs]
124+
125+
126+
==== Rule query
127+
128+
129+
[source, js]
130+
----------------------------------
131+
event.dataset: "aws.cloudtrail"
132+
and event.provider: "ec2.amazonaws.com"
133+
and event.action: "DescribeImages"
134+
and event.outcome: "success"
135+
and aws.cloudtrail.flattened.request_parameters.includeDeprecated: "true"
136+
and aws.cloudtrail.flattened.request_parameters.ownersSet.items.owner: *
137+
138+
----------------------------------
139+
140+
*Framework*: MITRE ATT&CK^TM^
141+
142+
* Tactic:
143+
** Name: Discovery
144+
** ID: TA0007
145+
** Reference URL: https://attack.mitre.org/tactics/TA0007/
146+
* Technique:
147+
** Name: Cloud Infrastructure Discovery
148+
** ID: T1580
149+
** Reference URL: https://attack.mitre.org/techniques/T1580/

0 commit comments

Comments
 (0)