Skip to content

Commit 0fc8d43

Browse files
Merge branch 'main' into investigation_guide_bedrock
2 parents 0e6c9fd + c602042 commit 0fc8d43

9 files changed

+801
-111
lines changed

rules/integrations/aws/discovery_ec2_multi_region_describe_instances.toml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,8 @@
11
[metadata]
22
creation_date = "2024/08/26"
3+
integration = ["aws"]
34
maturity = "production"
4-
updated_date = "2024/10/09"
5+
updated_date = "2024/11/04"
56

67
[rule]
78
author = ["Elastic"]
Lines changed: 149 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,149 @@
1+
[metadata]
2+
creation_date = "2024/11/04"
3+
integration = ["aws"]
4+
maturity = "production"
5+
min_stack_comments = "ES|QL rule type is still in technical preview as of 8.13, however this rule was tested successfully"
6+
min_stack_version = "8.13.0"
7+
updated_date = "2024/11/04"
8+
9+
[rule]
10+
author = ["Elastic"]
11+
description = """
12+
Detects when a single AWS resource is running multiple `Describe` and `List` API calls in a 10-second window. This
13+
behavior could indicate an actor attempting to discover the AWS infrastructure using compromised credentials or a
14+
compromised instance. Adversaries may use this information to identify potential targets for further exploitation or to
15+
gain a better understanding of the target's infrastructure.
16+
"""
17+
false_positives = [
18+
"""
19+
Administrators or automated systems may legitimately perform multiple `Describe` and `List` API calls in a short
20+
time frame. Verify the user identity and the purpose of the API calls to determine if the behavior is expected.
21+
""",
22+
]
23+
from = "now-9m"
24+
language = "esql"
25+
license = "Elastic License v2"
26+
name = "AWS Discovery API Calls via CLI from a Single Resource"
27+
note = """## Triage and Analysis
28+
29+
### Investigating AWS Discovery API Calls via CLI from a Single Resource
30+
31+
This rule detects multiple discovery-related API calls (`Describe`, `List`, or `Get` actions) within a short time window (30 seconds) from a single AWS resource. High volumes of such calls may indicate attempts to enumerate AWS infrastructure for reconnaissance purposes, which is often a tactic used by adversaries with compromised credentials or unauthorized access.
32+
33+
#### Possible Investigation Steps
34+
35+
- **Identify the Actor and Resource**:
36+
- **User Identity and Resource**: Examine `aws.cloudtrail.user_identity.arn` to identify the actor making the discovery requests. Verify the user or resource associated with these actions to ensure they are recognized and expected.
37+
- **User Agent and Tooling**: Check `user_agent.name` to confirm whether the `aws-cli` tool was used for these requests. Use of the CLI in an atypical context might indicate unauthorized or automated access.
38+
39+
- **Evaluate the Context and Scope of API Calls**:
40+
- **API Action Types**: Look into the specific actions under `event.action` for API calls like `Describe*`, `List*`, or `Get*`. Note if these calls are targeting sensitive services, such as `EC2`, `IAM`, or `S3`, which may suggest an attempt to identify high-value assets.
41+
- **Time Pattern Analysis**: Review the `time_window` and `unique_api_count` to assess whether the frequency of these calls is consistent with normal patterns for this resource or user.
42+
43+
- **Analyze Potential Compromise Indicators**:
44+
- **Identity Type**: Review `aws.cloudtrail.user_identity.type` to determine if the calls originated from an assumed role, a root user, or a service role. Unusual identity types for discovery operations may suggest misuse or compromise.
45+
- **Source IP and Geographic Location**: Examine the `source.ip` and `source.geo` fields to identify any unusual IP addresses or locations associated with the activity, which may help confirm or rule out external access.
46+
47+
- **Examine Related CloudTrail Events**:
48+
- **Pivot for Related Events**: Identify any additional IAM or CloudTrail events tied to the same actor ARN. Activities such as `AssumeRole`, `GetSessionToken`, or `CreateAccessKey` in proximity to these discovery calls may signal an attempt to escalate privileges.
49+
- **Look for Anomalous Patterns**: Determine if this actor or resource has performed similar discovery actions previously, or if these actions coincide with other alerts related to credential use or privilege escalation.
50+
51+
### False Positive Analysis
52+
53+
- **Expected Discovery Activity**: Regular discovery or enumeration API calls may be conducted by security, automation, or monitoring scripts to maintain an inventory of resources. Validate if this activity aligns with known automation or inventory tasks.
54+
- **Routine Admin or Automated Access**: If specific roles or resources, such as automation tools or monitoring services, regularly trigger this rule, consider adding exceptions for these known, benign users to reduce false positives.
55+
56+
### Response and Remediation
57+
58+
- **Confirm Authorized Access**: If the discovery activity appears unauthorized, consider immediate steps to restrict the user or resource’s permissions.
59+
- **Review and Remove Unauthorized API Calls**: If the actor is not authorized to perform discovery actions, investigate and potentially disable their permissions or access keys to prevent further misuse.
60+
- **Enhance Monitoring for Discovery Patterns**: Consider additional logging or alerting for high-frequency discovery API calls, especially if triggered from new or unrecognized resources.
61+
- **Policy Review and Updates**: Review IAM policies associated with the actor, ensuring restrictive permissions and MFA enforcement where possible to prevent unauthorized discovery.
62+
63+
### Additional Information
64+
65+
For further guidance on AWS infrastructure discovery and best practices, refer to [AWS CloudTrail documentation](https://docs.aws.amazon.com/awscloudtrail/latest/userguide/cloudtrail-event-reference.html) and MITRE ATT&CK’s [Cloud Infrastructure Discovery](https://attack.mitre.org/techniques/T1580/).
66+
"""
67+
references = ["https://stratus-red-team.cloud/attack-techniques/AWS/aws.discovery.ec2-enumerate-from-instance/"]
68+
risk_score = 21
69+
rule_id = "74f45152-9aee-11ef-b0a5-f661ea17fbcd"
70+
severity = "low"
71+
tags = [
72+
"Domain: Cloud",
73+
"Data Source: AWS",
74+
"Data Source: AWS EC2",
75+
"Data Source: AWS IAM",
76+
"Data Source: AWS S3",
77+
"Use Case: Threat Detection",
78+
"Tactic: Discovery",
79+
]
80+
timestamp_override = "event.ingested"
81+
type = "esql"
82+
83+
query = '''
84+
from logs-aws.cloudtrail*
85+
86+
// create time window buckets of 10 seconds
87+
| eval time_window = date_trunc(10 seconds, @timestamp)
88+
| where
89+
event.dataset == "aws.cloudtrail"
90+
91+
// filter on CloudTrail audit logs for IAM, EC2, and S3 events only
92+
and event.provider in (
93+
"iam.amazonaws.com",
94+
"ec2.amazonaws.com",
95+
"s3.amazonaws.com",
96+
"rds.amazonaws.com",
97+
"lambda.amazonaws.com",
98+
"dynamodb.amazonaws.com",
99+
"kms.amazonaws.com",
100+
"cloudfront.amazonaws.com",
101+
"elasticloadbalancing.amazonaws.com",
102+
"cloudfront.amazonaws.com"
103+
)
104+
105+
// ignore AWS service actions
106+
and aws.cloudtrail.user_identity.type != "AWSService"
107+
108+
// filter for aws-cli specifically
109+
and user_agent.name == "aws-cli"
110+
111+
// exclude DescribeCapacityReservations events related to AWS Config
112+
and not event.action in ("DescribeCapacityReservations")
113+
114+
// filter for Describe, Get, List, and Generate API calls
115+
| where true in (
116+
starts_with(event.action, "Describe"),
117+
starts_with(event.action, "Get"),
118+
starts_with(event.action, "List"),
119+
starts_with(event.action, "Generate")
120+
)
121+
// extract owner, identity type, and actor from the ARN
122+
| dissect aws.cloudtrail.user_identity.arn "%{}::%{owner}:%{identity_type}/%{actor}"
123+
| where starts_with(actor, "AWSServiceRoleForConfig") != true
124+
| keep @timestamp, time_window, event.action, aws.cloudtrail.user_identity.arn
125+
| stats
126+
// count the number of unique API calls per time window and actor
127+
unique_api_count = count_distinct(event.action) by time_window, aws.cloudtrail.user_identity.arn
128+
129+
// filter for more than 5 unique API calls per time window
130+
| where unique_api_count > 5
131+
132+
// sort the results by the number of unique API calls in descending order
133+
| sort unique_api_count desc
134+
'''
135+
136+
137+
[[rule.threat]]
138+
framework = "MITRE ATT&CK"
139+
[[rule.threat.technique]]
140+
id = "T1580"
141+
name = "Cloud Infrastructure Discovery"
142+
reference = "https://attack.mitre.org/techniques/T1580/"
143+
144+
145+
[rule.threat.tactic]
146+
id = "TA0007"
147+
name = "Discovery"
148+
reference = "https://attack.mitre.org/tactics/TA0007/"
149+
Lines changed: 97 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,97 @@
1+
[metadata]
2+
creation_date = "2024/11/01"
3+
integration = ["aws"]
4+
maturity = "production"
5+
updated_date = "2024/11/01"
6+
7+
[rule]
8+
author = ["Elastic"]
9+
description = """
10+
Identifies when an AWS Systems Manager (SSM) command document is created by a user who does not typically perform this action. Adversaries may create SSM command documents to execute commands on managed instances, potentially leading to unauthorized access, command and control, data exfiltration and more.
11+
"""
12+
false_positives = [
13+
"""
14+
Legitimate users may create SSM command documents for legitimate purposes. Ensure that the document is authorized and the user is known before taking action.
15+
""",
16+
]
17+
from = "now-9m"
18+
index = ["filebeat-*", "logs-aws.cloudtrail-*"]
19+
language = "kuery"
20+
license = "Elastic License v2"
21+
name = "AWS SSM Command Document Created by Rare User"
22+
note = """
23+
## Triage and Analysis
24+
25+
### Investigating AWS SSM Command Document Created by Rare User
26+
27+
This rule identifies when an AWS Systems Manager (SSM) command document is created by a user who does not typically perform this action. Creating SSM command documents can be a legitimate action but may also indicate malicious intent if done by an unusual or compromised user. Adversaries may leverage SSM documents to execute commands on managed instances, potentially leading to unauthorized access, command and control, or data exfiltration.
28+
29+
#### Possible Investigation Steps
30+
31+
- **Identify the Actor**: Review the `aws.cloudtrail.user_identity.arn` field to identify who created the SSM document. Verify if this user typically creates such documents and has the appropriate permissions. It may be unexpected for certain types of users, like assumed roles or federated users, to perform this action.
32+
- **Analyze the Document Details**:
33+
- **Document Name**: Check the `aws.cloudtrail.request_parameters.name` field for the document name to understand its intended purpose.
34+
- **Document Content**: If possible, review `aws.cloudtrail.request_parameters.content` for any sensitive or unexpected instructions (e.g., actions for data exfiltration or privilege escalation). If not available via logs, consider reviewing the document in the AWS Management Console.
35+
- **Contextualize the Activity with Related Events**: Look for other CloudTrail events involving the same user ARN or IP address (`source.address`). Examine actions performed in other AWS services, such as IAM, EC2, or S3, to identify if additional suspicious behavior exists. The `SendCommand` API call may indicate attempts to execute the SSM document on managed instances.
36+
- **Check Document Status and Metadata**:
37+
- **Document Status**: Confirm the document creation status in `aws.cloudtrail.response_elements.documentDescription.status`. A status of `Creating` may indicate that the document is in progress.
38+
- **Execution Permissions**: Review if the document specifies `platformTypes` and `documentVersion` in `aws.cloudtrail.response_elements.documentDescription` to understand which environments may be impacted and if multiple versions exist.
39+
40+
### False Positive Analysis
41+
42+
- **Authorized Administrative Actions**: Determine if this document creation aligns with scheduled administrative tasks or actions by authorized personnel.
43+
- **Historical User Actions**: Compare this action against historical activities for the user to determine if they have a history of creating similar documents, which may indicate legitimate usage.
44+
45+
### Response and Remediation
46+
47+
- **Immediate Document Review and Deletion**: If the document creation is deemed unauthorized, delete the document immediately and check for other similar documents created recently.
48+
- **Enhance Monitoring and Alerts**: Configure additional monitoring for SSM document creation events, especially when associated with untrusted or rare users.
49+
- **Policy Update**: Consider restricting SSM document creation permissions to specific, trusted roles or users to prevent unauthorized document creation.
50+
- **Incident Response**: If the document is confirmed as part of malicious activity, treat this as a security incident. Follow incident response protocols, including containment, investigation, and remediation.
51+
52+
### Additional Information
53+
54+
For further guidance on managing and securing AWS Systems Manager in your environment, refer to the [AWS SSM documentation](https://docs.aws.amazon.com/systems-manager/latest/userguide/what-is-systems-manager.html) and AWS security best practices.
55+
"""
56+
references = [
57+
"https://docs.aws.amazon.com/systems-manager/latest/APIReference/API_CreateDocument.html",
58+
"https://docs.aws.amazon.com/systems-manager/latest/userguide/documents.html"
59+
]
60+
risk_score = 21
61+
rule_id = "50a2bdea-9876-11ef-89db-f661ea17fbcd"
62+
severity = "low"
63+
tags = [
64+
"Domain: Cloud",
65+
"Data Source: AWS",
66+
"Data Source: Amazon Web Services",
67+
"Data Source: AWS SNS",
68+
"Data Source: AWS Systems Manager",
69+
"Resources: Investigation Guide",
70+
"Use Case: Threat Detection",
71+
"Tactic: Execution"
72+
]
73+
timestamp_override = "event.ingested"
74+
type = "new_terms"
75+
76+
query = '''
77+
event.dataset: "aws.cloudtrail"
78+
and event.provider: "ssm.amazonaws.com"
79+
and event.action: "CreateDocument"
80+
and event.outcome: "success"
81+
and aws.cloudtrail.response_elements: *documentType=Command*
82+
'''
83+
84+
[[rule.threat]]
85+
framework = "MITRE ATT&CK"
86+
87+
[rule.threat.tactic]
88+
id = "TA0002"
89+
name = "Execution"
90+
reference = "https://attack.mitre.org/tactics/TA0002/"
91+
92+
[rule.new_terms]
93+
field = "new_terms_fields"
94+
value = ["aws.cloudtrail.user_identity.arn"]
95+
[[rule.new_terms.history_window_start]]
96+
field = "history_window_start"
97+
value = "now-14d"
Lines changed: 103 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,103 @@
1+
[metadata]
2+
creation_date = "2024/11/01"
3+
integration = ["aws"]
4+
maturity = "production"
5+
updated_date = "2024/11/01"
6+
7+
[rule]
8+
author = ["Elastic"]
9+
description = """
10+
Identifies when an SNS topic is subscribed to by an email address of a user who does not typically perform this action.
11+
Adversaries may subscribe to an SNS topic to collect sensitive information or exfiltrate data via an external email
12+
address.
13+
"""
14+
false_positives = [
15+
"""
16+
Legitimate users may subscribe to SNS topics for legitimate purposes. Ensure that the subscription is authorized and
17+
the subscription email address is known before taking action.
18+
""",
19+
]
20+
from = "now-9m"
21+
index = ["filebeat-*", "logs-aws.cloudtrail-*"]
22+
language = "kuery"
23+
license = "Elastic License v2"
24+
name = "AWS SNS Email Subscription by Rare User"
25+
note = """## Triage and Analysis
26+
27+
### Investigating AWS SNS Email Subscription by Rare User
28+
29+
This rule identifies when an SNS topic is subscribed to by an email address of a user who does not typically perform this action. While subscribing to SNS topics is a common practice, adversaries may exploit this feature to collect sensitive information or exfiltrate data via an external email address.
30+
31+
#### Possible Investigation Steps
32+
33+
- **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.
34+
- **Review the SNS Subscription Event**: Analyze the specifics of the `Subscribe` action in CloudTrail logs:
35+
- **Topic**: Look at the `aws.cloudtrail.request_parameters.topicArn` field to identify the SNS topic involved in the subscription.
36+
- **Protocol and Endpoint**: Review the `aws.cloudtrail.request_parameters.protocol` and `aws.cloudtrail.request_parameters.endpoint` fields to confirm the subscription's protocol and email address. Confirm if this endpoint is associated with a known or trusted entity.
37+
- **Subscription Status**: Check the `aws.cloudtrail.response_elements.subscriptionArn` field for the subscription's current status, noting if it requires confirmation.
38+
- **Verify Authorization**: Evaluate whether the user typically engages in SNS subscription actions and if they are authorized to do so for the specified topic.
39+
- **Contextualize with Related Events**: Review related CloudTrail logs around the event time for other actions by the same user or IP address. Look for activities involving other AWS services, such as S3 or IAM, that may indicate further suspicious behavior.
40+
- **Evaluate the Subscription Endpoint**: Determine whether the email endpoint is legitimate or associated with any known entity. This may require checking internal documentation or reaching out to relevant AWS account administrators.
41+
- **Check for Publish Actions**: Investigate for any subsequent `Publish` actions on the same SNS topic that may indicate exfiltration attempts or data leakage. If Publish actions are detected, further investigate the contents of the messages.
42+
- **Review IAM Policies**: Examine the user or role's IAM policies to ensure that the subscription action is within the scope of their permissions or should be.
43+
44+
### False Positive Analysis
45+
46+
- **Historical User Actions**: Verify if the user has a history of performing similar actions on SNS topics. Consistent, repetitive actions may suggest legitimate usage.
47+
- **Scheduled or Automated Tasks**: Confirm if the subscription action aligns with scheduled tasks or automated notifications authorized by your organization.
48+
49+
### Response and Remediation
50+
51+
- **Immediate Review and Reversal**: If the subscription was unauthorized, take appropriate action to cancel it and adjust SNS permissions as necessary.
52+
- **Strengthen Monitoring and Alerts**: Configure monitoring systems to flag similar actions involving sensitive topics or unapproved endpoints.
53+
- **Policy Review**: Review and update policies related to SNS subscriptions and access, tightening control as needed to prevent unauthorized subscriptions.
54+
- **Incident Response**: If there is evidence of malicious intent, treat the event as a potential data exfiltration incident and follow incident response protocols, including further investigation, containment, and recovery.
55+
56+
### Additional Information
57+
58+
For further guidance on managing and securing SNS topics in AWS environments, refer to the [AWS SNS documentation](https://docs.aws.amazon.com/sns/latest/dg/welcome.html) and AWS best practices for security.
59+
60+
"""
61+
references = ["https://docs.aws.amazon.com/sns/latest/api/API_Subscribe.html"]
62+
risk_score = 21
63+
rule_id = "3df49ff6-985d-11ef-88a1-f661ea17fbcd"
64+
severity = "low"
65+
tags = [
66+
"Domain: Cloud",
67+
"Data Source: AWS",
68+
"Data Source: Amazon Web Services",
69+
"Data Source: AWS SNS",
70+
"Resources: Investigation Guide",
71+
"Use Case: Threat Detection",
72+
"Tactic: Exfiltration",
73+
]
74+
timestamp_override = "event.ingested"
75+
type = "new_terms"
76+
77+
query = '''
78+
event.dataset: "aws.cloudtrail"
79+
and event.provider: "sns.amazonaws.com"
80+
and event.action: "Subscribe"
81+
and aws.cloudtrail.request_parameters: *protocol=email*
82+
'''
83+
84+
85+
[[rule.threat]]
86+
framework = "MITRE ATT&CK"
87+
[[rule.threat.technique]]
88+
id = "T1567"
89+
name = "Exfiltration Over Web Service"
90+
reference = "https://attack.mitre.org/techniques/T1567/"
91+
92+
93+
[rule.threat.tactic]
94+
id = "TA0010"
95+
name = "Exfiltration"
96+
reference = "https://attack.mitre.org/tactics/TA0010/"
97+
98+
[rule.new_terms]
99+
field = "new_terms_fields"
100+
value = ["aws.cloudtrail.user_identity.arn"]
101+
[[rule.new_terms.history_window_start]]
102+
field = "history_window_start"
103+
value = "now-14d"

0 commit comments

Comments
 (0)