Skip to content

Commit 5b386e0

Browse files
authored
[Rule Tuning] AWS EC2 Full Network Packet Capture Detected (#5244)
* [Rule Tuning] AWS EC2 Full Network Packet Capture Detected **AWS EC2 Full Network Packet Capture Detected** Alert telemetry is low in general however the alerts that do exist are unnecessarily duplicative in nature. When a traffic mirror session is created (CreateTrafficMirrorSession), it is typcially created alongside A filter and filter rules (CreateTrafficMirrorFilter, CreateTrafficMirrorFilterRule) which determines what traffic will be mirrored. There is also a traffic mirror target (CreateTrafficMirrorTarget), which is the destination for the mirrored traffic to go. The original scope of this rule included all of those APIs when really the only API needed here is `CreateTrafficMirrorSession`, which is the actual network mirroring behavior. The rest of those calls can be used as additional context during alert triage, but I've significantly reduced the scope of this rule to only capture the actual traffic mirroring behavior. - reduced the query scope to `CreateTrafficMirrorSession` only - reduced the execution window - update description and investigation guide - replaced API reference link - added highlighted fields * updating mitre technique updating mitre technique * updated Mitre mapping adding network sniffing technique * updating references to include relevant threat blog updating references to include relevant threat blog * adding EC2 tag adding EC2 tag * updating EC2 tagging
1 parent 57facdd commit 5b386e0

File tree

1 file changed

+104
-35
lines changed

1 file changed

+104
-35
lines changed

rules/integrations/aws/exfiltration_ec2_full_network_packet_capture_detected.toml

Lines changed: 104 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -2,14 +2,15 @@
22
creation_date = "2021/05/05"
33
integration = ["aws"]
44
maturity = "production"
5-
updated_date = "2025/01/15"
5+
updated_date = "2025/10/23"
66

77
[rule]
88
author = ["Elastic", "Austin Songer"]
99
description = """
10-
Identifies potential Traffic Mirroring in an Amazon Elastic Compute Cloud (EC2) instance. Traffic Mirroring is an Amazon
11-
VPC feature that you can use to copy network traffic from an Elastic network interface. This feature can potentially be
12-
abused to exfiltrate sensitive data from unencrypted internal traffic.
10+
Detects successful creation of an Amazon EC2 Traffic Mirroring session. A session copies full packets from a source
11+
Elastic Network Interface (ENI) to a mirror target (e.g., an ENI or NLB) using a mirror filter (ingress/egress rules).
12+
While used for diagnostics and NDR/IDS tooling, adversaries can abuse sessions to covertly capture and exfiltrate
13+
sensitive, potentially unencrypted, traffic from instances or subnets.
1314
"""
1415
false_positives = [
1516
"""
@@ -18,9 +19,8 @@ false_positives = [
1819
should be investigated. If known behavior is causing false positives, it can be exempted from the rule.
1920
""",
2021
]
21-
from = "now-60m"
22+
from = "now-6m"
2223
index = ["filebeat-*", "logs-aws.cloudtrail-*"]
23-
interval = "10m"
2424
language = "kuery"
2525
license = "Elastic License v2"
2626
name = "AWS EC2 Full Network Packet Capture Detected"
@@ -31,41 +31,73 @@ note = """## Triage and analysis
3131
3232
### Investigating AWS EC2 Full Network Packet Capture Detected
3333
34-
Traffic Mirroring in AWS EC2 allows copying of network traffic for monitoring and analysis, crucial for security and performance insights. However, adversaries can exploit this by capturing unencrypted data, leading to potential data exfiltration. The detection rule identifies successful creation of traffic mirroring components, signaling possible misuse for unauthorized data collection.
35-
36-
### Possible investigation steps
37-
38-
- Review the CloudTrail logs for the specific event actions: CreateTrafficMirrorFilter, CreateTrafficMirrorFilterRule, CreateTrafficMirrorSession, and CreateTrafficMirrorTarget to identify the user or role that initiated these actions.
39-
- Check the event.outcome field to confirm the success of the traffic mirroring setup and gather details about the time and source IP address of the request.
40-
- Investigate the associated Elastic Network Interface (ENI) to determine which EC2 instance is involved and assess its role and importance within the network.
41-
- Analyze the network traffic patterns and data flow from the mirrored traffic to identify any signs of data exfiltration or unusual data transfer activities.
42-
- Verify the encryption status of the network traffic being mirrored to assess the risk of sensitive data exposure.
43-
- Cross-reference the involved AWS account and IAM roles with known threat actor profiles or previous security incidents to identify potential insider threats or compromised accounts.
34+
This alert fires on a successful `CreateTrafficMirrorSession`, which enables full-packet Traffic Mirroring from a
35+
source ENI to a mirror target under a given filter. Because sessions immediately begin sending packets once active,
36+
treat unexpected creations as high priority.
37+
38+
#### Possible investigation steps
39+
40+
**Identify the actor and execution context**
41+
- **Principal**: Review `aws.cloudtrail.user_identity.arn`, `aws.cloudtrail.user_identity.type`, and
42+
`aws.cloudtrail.user_identity.access_key_id` to determine who created the session (human IAM user vs. assumed role vs. automation).
43+
- **Caller metadata**: Check `user_agent.original`, and `source.ip` for unusual tools, hosts, or locations.
44+
- **Account/Region/Time**: Validate `cloud.account.id`, `cloud.region`, and `@timestamp` against change windows or tickets.
45+
46+
**Extract the session details from the event**
47+
- **Request parameters**: Parse `aws.cloudtrail.request_parameters` for:
48+
- `NetworkInterfaceId` (mirrored source ENI) map to the EC2 instance and its business function.
49+
- `TrafficMirrorTargetId` identify where packets are being sent (ENI vs. NLB).
50+
- `TrafficMirrorFilterId` check which directions and protocols are allowed (ingress/egress, ports).
51+
- `SessionNumber`, `Description`, `TagSpecifications` look for operator tags or suspicious notes.
52+
- **Response elements**: Use `aws.cloudtrail.response_elements` to confirm the created `TrafficMirrorSessionId` and
53+
any resolved resource ARNs/IDs.
54+
55+
**Pivot for related API calls to validate scope and intent**
56+
Look before and after this event (±30–60 minutes) by the same principal / access key / source IP for:
57+
- **Target & Filter lifecycle**: `CreateTrafficMirrorTarget`, `CreateTrafficMirrorFilter`, `CreateTrafficMirrorFilterRule`,
58+
`ModifyTrafficMirrorSession|Filter|FilterRule`, and `Delete*` calls (rapid create-modify patterns can indicate staging).
59+
- **Session management**: `DeleteTrafficMirrorSession` shortly after creation (test/probe), or repeated creations to different targets.
60+
- **Discovery/positioning**: `DescribeNetworkInterfaces`, `DescribeInstances`, `DescribeVpcs/Subnets/RouteTables` around the same time.
61+
- **Cross-account indicators**: creation of targets that forward to infrastructure not owned by your account (e.g., NLB in shared services).
62+
- **Other suspicious changes**: IAM permission changes, new access keys, or S3/SNS setup that could support exfil/ops.
63+
64+
**Validate the mirror destination and potential data exposure**
65+
- If the target is an ENI: identify the owning instance/application; confirm it is an approved NDR/packet capture host.
66+
- If the target is an NLB target: determine where the NLB sends traffic (could be a collection point in another VPC or account).
67+
- Assess whether mirrored flows include plaintext protocols (internal HTTP, databases, LDAP, etc.) increasing sensitivity.
4468
4569
### False positive analysis
4670
47-
- Routine network monitoring activities may trigger the rule if legitimate traffic mirroring is set up for performance analysis. To manage this, identify and document authorized traffic mirroring configurations and exclude them from alerts.
48-
- Security audits or compliance checks might involve creating traffic mirroring sessions. Coordinate with audit teams to schedule these activities and temporarily suppress alerts during these periods.
49-
- Development and testing environments often use traffic mirroring for debugging purposes. Maintain a list of such environments and apply exceptions to avoid unnecessary alerts.
50-
- Automated infrastructure management tools might create traffic mirroring components as part of their operations. Review and whitelist these tools to prevent false positives.
51-
- Ensure that any third-party services with access to your AWS environment are vetted and their activities are monitored to distinguish between legitimate and suspicious traffic mirroring actions.
71+
- **Authorized monitoring**: Approved NDR/IDS tooling or troubleshooting playbooks may legitimately create sessions.
72+
- **Ops/diagnostics**: Short-lived sessions during incident handling or performance analysis.
73+
- **Automation**: Infrastructure pipelines that stand up temporary mirroring for validation.
5274
5375
### Response and remediation
5476
55-
- Immediately isolate the affected EC2 instance to prevent further data exfiltration. This can be done by removing the instance from any network access or security groups that allow outbound traffic.
56-
- Review and terminate any unauthorized Traffic Mirroring sessions, filters, or targets that were created. Ensure that only legitimate and necessary mirroring configurations are active.
57-
- Conduct a thorough audit of the AWS CloudTrail logs to identify any other suspicious activities or unauthorized access attempts related to Traffic Mirroring or other sensitive operations.
58-
- Rotate and update any credentials or access keys that may have been exposed or compromised during the incident to prevent further unauthorized access.
59-
- Notify the security team and relevant stakeholders about the incident for awareness and further investigation. Escalate to higher management if the data exfiltration involves sensitive or critical data.
60-
- Implement additional network monitoring and intrusion detection measures to enhance visibility and detect similar threats in the future. Consider using AWS GuardDuty or similar services for continuous threat detection.
61-
- Review and update security policies and access controls to ensure that Traffic Mirroring and other sensitive features are only accessible to authorized personnel with a legitimate need.
77+
**1. Contain**
78+
- If unauthorized, terminate the session immediately (use the `TrafficMirrorSessionId` from `aws.cloudtrail.response_elements`)
79+
and block creation permissions for the offending principal.
80+
- Quarantine or restrict egress from the target if you suspect it is forwarding captured traffic outside approved destinations.
81+
82+
**2. Investigate**
83+
- Enumerate all active sessions in the affected account/region; verify there aren’t additional rogue sessions.
84+
- Review related target and filter resources (and recent `Modify*` calls) to understand captured scope and recipients.
85+
- Trace the source ENI back to the EC2 instance and validate whether sensitive workloads were mirrored.
86+
87+
**3. Recover & harden**
88+
- Remove or lock down unapproved targets/filters; enforce least privilege on `ec2:CreateTrafficMirrorSession/Target/Filter`.
89+
- Consider SCPs or IAM conditions limiting who/where sessions can be created (e.g., only into designated monitoring VPCs).
90+
- Ensure monitoring targets are controlled, logged, and not internet-reachable.
6291
63-
## Setup
92+
**4. Improve**
93+
- Add correlation logic to automatically surface CreateTrafficMirrorSession alongside Create/Modify Target/Filter calls by the same actor.
94+
- Require tags on approved mirroring resources; alert on untagged/unticketed creations.
95+
- Update playbooks to include a standard validation checklist (principal, source ENI, target, filter rules, destination path).
6496
65-
The AWS Fleet integration, Filebeat module, or similarly structured data is required to be compatible with this rule."""
97+
"""
6698
references = [
67-
"https://docs.aws.amazon.com/AWSEC2/latest/APIReference/API_TrafficMirrorFilter.html",
68-
"https://github.com/easttimor/aws-incident-response",
99+
"https://docs.aws.amazon.com/AWSEC2/latest/APIReference/API_TrafficMirrorSession.html",
100+
"https://rhinosecuritylabs.com/aws/abusing-vpc-traffic-mirroring-in-aws/",
69101
]
70102
risk_score = 47
71103
rule_id = "c1812764-0788-470f-8e74-eb4a14d47573"
@@ -74,6 +106,7 @@ tags = [
74106
"Domain: Cloud",
75107
"Data Source: AWS",
76108
"Data Source: Amazon Web Services",
109+
"Data Source: AWS EC2",
77110
"Use Case: Network Security Monitoring",
78111
"Tactic: Exfiltration",
79112
"Tactic: Collection",
@@ -83,9 +116,10 @@ timestamp_override = "event.ingested"
83116
type = "query"
84117

85118
query = '''
86-
event.dataset:aws.cloudtrail and event.provider:ec2.amazonaws.com and
87-
event.action:(CreateTrafficMirrorFilter or CreateTrafficMirrorFilterRule or CreateTrafficMirrorSession or CreateTrafficMirrorTarget) and
88-
event.outcome:success
119+
event.dataset: "aws.cloudtrail" and
120+
event.provider: "ec2.amazonaws.com" and
121+
event.action: "CreateTrafficMirrorSession" and
122+
event.outcome: "success"
89123
'''
90124

91125

@@ -96,6 +130,11 @@ id = "T1020"
96130
name = "Automated Exfiltration"
97131
reference = "https://attack.mitre.org/techniques/T1020/"
98132

133+
[[rule.threat.technique]]
134+
id = "T1537"
135+
name = "Transfer Data to Cloud Account"
136+
reference = "https://attack.mitre.org/techniques/T1537/"
137+
99138

100139
[rule.threat.tactic]
101140
id = "TA0010"
@@ -113,4 +152,34 @@ reference = "https://attack.mitre.org/techniques/T1074/"
113152
id = "TA0009"
114153
name = "Collection"
115154
reference = "https://attack.mitre.org/tactics/TA0009/"
155+
[[rule.threat]]
156+
framework = "MITRE ATT&CK"
157+
[[rule.threat.technique]]
158+
id = "T1040"
159+
name = "Network Sniffing"
160+
reference = "https://attack.mitre.org/techniques/T1040/"
161+
162+
163+
[rule.threat.tactic]
164+
id = "TA0007"
165+
name = "Discovery"
166+
reference = "https://attack.mitre.org/tactics/TA0007/"
167+
168+
[rule.investigation_fields]
169+
field_names = [
170+
"@timestamp",
171+
"user.name",
172+
"user_agent.original",
173+
"source.ip",
174+
"aws.cloudtrail.user_identity.arn",
175+
"aws.cloudtrail.user_identity.type",
176+
"aws.cloudtrail.user_identity.access_key_id",
177+
"target.entity.id",
178+
"event.action",
179+
"event.outcome",
180+
"cloud.account.id",
181+
"cloud.region",
182+
"aws.cloudtrail.request_parameters",
183+
"aws.cloudtrail.response_elements",
184+
]
116185

0 commit comments

Comments
 (0)