High Number of Egress Network Connections from Unusual Executable
This rule detects a high number of egress network connections from an unusual executable on a Linux system. This could indicate a command and control (C2) communication attempt, a brute force attack via a malware infection, or other malicious activity. ESQL rules have limited fields available in its alert documents. Make sure to review the original documents to aid in the investigation of this alert.
Elastic rule (View on GitHub)
1[metadata]
2creation_date = "2025/02/20"
3integration = ["endpoint"]
4maturity = "production"
5updated_date = "2026/09/18"
6
7[rule]
8author = ["Elastic"]
9description = """
10This rule detects a high number of egress network connections from an unusual executable on a Linux system. This could
11indicate a command and control (C2) communication attempt, a brute force attack via a malware infection, or other
12malicious activity. ESQL rules have limited fields available in its alert documents. Make sure to review the original
13documents to aid in the investigation of this alert.
14"""
15from = "now-61m"
16interval = "1h"
17language = "esql"
18license = "Elastic License v2"
19name = "High Number of Egress Network Connections from Unusual Executable"
20note = """## Triage and analysis
21
22> **Disclaimer**:
23> This investigation guide was created using generative AI technology and has been reviewed to improve its accuracy and relevance. While every effort has been made to ensure its quality, we recommend validating the content and adapting it to suit your specific environment and operational needs.
24
25### Investigating High Number of Egress Network Connections from Unusual Executable
26
27In Linux environments, executables can initiate network connections for legitimate purposes. However, adversaries exploit this by deploying malware in temporary directories to establish command and control (C2) channels. The detection rule identifies unusual executables making numerous outbound connections, excluding trusted IP ranges and known benign paths, to flag potential threats.
28
29### Possible investigation steps
30
31- Review the process.executable field to identify the specific executable making the connections and determine if it is known or expected in the environment.
32- Examine the destination.ip field to identify the external IP addresses the executable is attempting to connect to and check if they are known malicious or suspicious.
33- Check the host.os.type and agent.id fields to identify the specific host and agent involved, and gather additional context about the system's role and recent activity.
34- Analyze the @timestamp field to correlate the timing of the connections with other events or activities on the network or host.
35- Cross-reference the identified executable and IP addresses with threat intelligence sources to determine if they are associated with known threats or campaigns.
36- If the executable is determined to be malicious or suspicious, isolate the affected host and perform a deeper forensic analysis to identify any additional indicators of compromise or lateral movement.
37
38### False positive analysis
39
40- Executables in temporary directories used by legitimate applications or scripts can trigger alerts. Review the process name and executable path to determine if they are associated with known applications or scripts.
41- Automated scripts or cron jobs that perform network operations might be flagged. Identify these scripts and consider excluding their paths from the rule if they are verified as non-malicious.
42- Development or testing environments often use temporary directories for network operations. If these environments are known and trusted, add their specific paths to the exclusion list.
43- Backup or synchronization tools that use temporary directories for data transfer can generate numerous connections. Verify these tools and exclude their paths if they are confirmed to be safe.
44- Security tools or monitoring agents that operate in temporary directories might be mistakenly flagged. Confirm their legitimacy and exclude their paths to prevent false positives.
45
46### Response and remediation
47
48- Isolate the affected host immediately from the network to prevent further potential malicious communication and lateral movement.
49- Terminate the suspicious process identified by the alert to stop any ongoing malicious activity.
50- Conduct a forensic analysis of the affected system to identify any additional indicators of compromise (IOCs) and assess the extent of the infection.
51- Remove any malicious executables or files found in temporary directories such as /tmp, /var/tmp, or /dev/shm to eliminate the threat.
52- Patch and update the affected system to the latest security standards to close any vulnerabilities that may have been exploited.
53- Monitor network traffic for any unusual outbound connections from other systems to detect potential spread or similar threats.
54- Escalate the incident to the security operations center (SOC) or incident response team for further investigation and to ensure comprehensive remediation.
55"""
56risk_score = 47
57rule_id = "1fa350e0-0aa2-4055-bf8f-ab8b59233e59"
58setup = """## Setup
59
60This rule requires data coming in from Elastic Defend.
61
62### Elastic Defend Integration Setup
63Elastic Defend is integrated into the Elastic Agent using Fleet. Upon configuration, the integration allows the Elastic Agent to monitor events on your host and send data to the Elastic Security app.
64
65#### Prerequisite Requirements:
66- Fleet is required for Elastic Defend.
67- To configure Fleet Server refer to the [documentation](https://www.elastic.co/guide/en/fleet/current/fleet-server.html).
68
69#### The following steps should be executed in order to add the Elastic Defend integration on a Linux System:
70- Go to the Kibana home page and click "Add integrations".
71- In the query bar, search for "Elastic Defend" and select the integration to see more details about it.
72- Click "Add Elastic Defend".
73- Configure the integration name and optionally add a description.
74- Select the type of environment you want to protect, either "Traditional Endpoints" or "Cloud Workloads".
75- Select a configuration preset. Each preset comes with different default settings for Elastic Agent, you can further customize these later by configuring the Elastic Defend integration policy. [Helper guide](https://www.elastic.co/guide/en/security/current/configure-endpoint-integration-policy.html).
76- We suggest selecting "Complete EDR (Endpoint Detection and Response)" as a configuration setting, that provides "All events; all preventions"
77- Enter a name for the agent policy in "New agent policy name". If other agent policies already exist, you can click the "Existing hosts" tab and select an existing policy instead.
78For more details on Elastic Agent configuration settings, refer to the [helper guide](https://www.elastic.co/guide/en/fleet/8.10/agent-policy.html).
79- Click "Save and Continue".
80- To complete the integration, select "Add Elastic Agent to your hosts" and continue to the next section to install the Elastic Agent on your hosts.
81For more details on Elastic Defend refer to the [helper guide](https://www.elastic.co/guide/en/security/current/install-endpoint.html).
82"""
83severity = "medium"
84tags = [
85 "Domain: Endpoint",
86 "OS: Linux",
87 "Use Case: Threat Detection",
88 "Tactic: Command and Control",
89 "Data Source: Elastic Defend",
90 "Resources: Investigation Guide",
91 "Noise: Medium",
92 "Performance: Normal",
93 "Rule Type: ES|QL",
94 "Platform: Linux",
95]
96timestamp_override = "event.ingested"
97type = "esql"
98query = '''
99from logs-endpoint.events.network-* metadata _id, _index, _version
100| mv_expand event.action
101| where
102 host.os.type == "linux" and
103 event.type == "start" and
104 event.action == "connection_attempted" and
105 (
106 process.executable like "/tmp/*" or
107 process.executable like "/var/tmp/*" or
108 process.executable like "/dev/shm/*" or
109 process.executable like "/var/log/*" or
110 process.executable like "/sys/*" or
111 process.executable like "/media/*" or
112 process.executable like "/proc/*" or
113 process.executable like "/var/backups/*" or
114 process.executable like "/var/mail/*" or
115 process.executable like "/var/spool/*" or
116 process.executable like "./*" or
117 process.name like ".*"
118 ) and
119 not (
120 cidr_match(destination.ip,
121 "10.0.0.0/8", "127.0.0.0/8", "169.254.0.0/16", "172.16.0.0/12",
122 "192.0.0.0/24", "192.0.0.29/32", "192.0.0.8/32", "192.0.0.9/32",
123 "192.0.0.10/32", "192.0.0.170/32", "192.0.0.171/32", "192.0.2.0/24",
124 "192.31.196.0/24", "192.52.193.0/24", "192.168.0.0/16", "192.88.99.0/24",
125 "224.0.0.0/4", "100.64.0.0/10", "192.175.48.0/24", "198.18.0.0/15",
126 "198.51.100.0/24", "203.0.113.0/24", "240.0.0.0/4", "::1", "FE80::/10", "FF00::/8"
127 ) or
128 process.executable like "/tmp/newroot/*" or
129 process.executable like "/tmp/.mount*" or
130 process.executable like "/tmp/go-build*"
131 )
132| keep
133 @timestamp,
134 _id,
135 _index,
136 _version,
137 host.os.type,
138 event.type,
139 event.action,
140 process.name,
141 process.executable,
142 destination.ip,
143 agent.id,
144 host.name,
145 data_stream.dataset,
146 data_stream.namespace
147
148| stats
149 Esql.event_count = count(),
150 Esql.agent_id_count_distinct = count_distinct(agent.id),
151 Esql.host_name_values = values(host.name),
152 Esql.agent_id_values = values(agent.id),
153 Esql.data_stream_dataset_values = values(data_stream.dataset),
154 Esql.data_stream_namespace_values = values(data_stream.namespace)
155 by process.executable
156| where
157 Esql.agent_id_count_distinct == 1 and
158 Esql.event_count > 15
159
160// Extract unique values to ECS fields for alerts exclusion
161| eval agent.id = mv_min(Esql.agent_id_values),
162 host.name = mv_min(Esql.host_name_values)
163
164| sort Esql.event_count asc
165
166| keep agent.id, host.name, process.executable, Esql.*
167'''
168
169[[rule.threat]]
170framework = "MITRE ATT&CK"
171
172[[rule.threat.technique]]
173id = "T1071"
174name = "Application Layer Protocol"
175reference = "https://attack.mitre.org/techniques/T1071/"
176
177[rule.threat.tactic]
178id = "TA0011"
179name = "Command and Control"
180reference = "https://attack.mitre.org/tactics/TA0011/"
181
182[[rule.threat]]
183framework = "MITRE ATT&CK"
184
185[[rule.threat.technique]]
186id = "T1564"
187name = "Hide Artifacts"
188reference = "https://attack.mitre.org/techniques/T1564/"
189
190[[rule.threat.technique.subtechnique]]
191id = "T1564.001"
192name = "Hidden Files and Directories"
193reference = "https://attack.mitre.org/techniques/T1564/001/"
194
195[rule.threat.tactic]
196id = "TA0005"
197name = "Defense Evasion"
198reference = "https://attack.mitre.org/tactics/TA0005/"
Triage and analysis
Disclaimer: This investigation guide was created using generative AI technology and has been reviewed to improve its accuracy and relevance. While every effort has been made to ensure its quality, we recommend validating the content and adapting it to suit your specific environment and operational needs.
Investigating High Number of Egress Network Connections from Unusual Executable
In Linux environments, executables can initiate network connections for legitimate purposes. However, adversaries exploit this by deploying malware in temporary directories to establish command and control (C2) channels. The detection rule identifies unusual executables making numerous outbound connections, excluding trusted IP ranges and known benign paths, to flag potential threats.
Possible investigation steps
- Review the process.executable field to identify the specific executable making the connections and determine if it is known or expected in the environment.
- Examine the destination.ip field to identify the external IP addresses the executable is attempting to connect to and check if they are known malicious or suspicious.
- Check the host.os.type and agent.id fields to identify the specific host and agent involved, and gather additional context about the system's role and recent activity.
- Analyze the @timestamp field to correlate the timing of the connections with other events or activities on the network or host.
- Cross-reference the identified executable and IP addresses with threat intelligence sources to determine if they are associated with known threats or campaigns.
- If the executable is determined to be malicious or suspicious, isolate the affected host and perform a deeper forensic analysis to identify any additional indicators of compromise or lateral movement.
False positive analysis
- Executables in temporary directories used by legitimate applications or scripts can trigger alerts. Review the process name and executable path to determine if they are associated with known applications or scripts.
- Automated scripts or cron jobs that perform network operations might be flagged. Identify these scripts and consider excluding their paths from the rule if they are verified as non-malicious.
- Development or testing environments often use temporary directories for network operations. If these environments are known and trusted, add their specific paths to the exclusion list.
- Backup or synchronization tools that use temporary directories for data transfer can generate numerous connections. Verify these tools and exclude their paths if they are confirmed to be safe.
- Security tools or monitoring agents that operate in temporary directories might be mistakenly flagged. Confirm their legitimacy and exclude their paths to prevent false positives.
Response and remediation
- Isolate the affected host immediately from the network to prevent further potential malicious communication and lateral movement.
- Terminate the suspicious process identified by the alert to stop any ongoing malicious activity.
- Conduct a forensic analysis of the affected system to identify any additional indicators of compromise (IOCs) and assess the extent of the infection.
- Remove any malicious executables or files found in temporary directories such as /tmp, /var/tmp, or /dev/shm to eliminate the threat.
- Patch and update the affected system to the latest security standards to close any vulnerabilities that may have been exploited.
- Monitor network traffic for any unusual outbound connections from other systems to detect potential spread or similar threats.
- Escalate the incident to the security operations center (SOC) or incident response team for further investigation and to ensure comprehensive remediation.
Related rules
- Potential Malware-Driven SSH Brute Force Attempt
- AWS EC2 LOLBin Execution via SSM SendCommand
- Curl or Wget Egress Network Connection via LoLBin
- Curl or Wget Spawned via Node.js
- File Transfer Utility Launched from Unusual Parent