Deprecated - Netcat Listener Established Inside A Container
This rule detects an established netcat listener running inside a container. Netcat is a utility used for reading and writing data across network connections, and it can be used for malicious purposes such as establishing a backdoor for persistence or exfiltrating data.
Elastic rule (View on GitHub)
1[metadata]
2creation_date = "2023/04/26"
3integration = ["cloud_defend"]
4deprecation_date = "2025/03/14"
5maturity = "deprecated"
6updated_date = "2025/03/14"
7
8[rule]
9author = ["Elastic"]
10description = """
11This rule detects an established netcat listener running inside a container. Netcat is a utility used for reading and
12writing data across network connections, and it can be used for malicious purposes such as establishing a backdoor for
13persistence or exfiltrating data.
14"""
15false_positives = [
16 """
17 There is a potential for false positives if the container is used for legitimate tasks that require the use of
18 netcat, such as network troubleshooting, testing or system monitoring. It is important to investigate any alerts
19 generated by this rule to determine if they are indicative of malicious activity or part of legitimate container
20 activity.
21 """,
22]
23from = "now-6m"
24index = ["logs-cloud_defend*"]
25interval = "5m"
26language = "eql"
27license = "Elastic License v2"
28name = "Deprecated - Netcat Listener Established Inside A Container"
29risk_score = 73
30rule_id = "a52a9439-d52c-401c-be37-2785235c6547"
31severity = "high"
32tags = [
33 "Data Source: Elastic Defend for Containers",
34 "Domain: Container",
35 "OS: Linux",
36 "Use Case: Threat Detection",
37 "Tactic: Execution",
38 "Resources: Investigation Guide",
39]
40timestamp_override = "event.ingested"
41type = "eql"
42
43query = '''
44process where container.id: "*" and event.type== "start"
45and event.action in ("fork", "exec") and
46(
47process.name:("nc","ncat","netcat","netcat.openbsd","netcat.traditional") or
48/*account for tools that execute utilities as a subprocess, in this case the target utility name will appear as a process arg*/
49process.args: ("nc","ncat","netcat","netcat.openbsd","netcat.traditional")
50) and (
51 /* bind shell to echo for command execution */
52 (process.args:("-*l*", "--listen", "-*p*", "--source-port") and process.args:("-c", "--sh-exec", "-e", "--exec", "echo","$*"))
53 /* bind shell to specific port */
54 or process.args:("-*l*", "--listen", "-*p*", "--source-port")
55 )
56'''
57note = """## Setup
58
59This rule was deprecated in the 8.18 and 9.0 versions of the Elastic Stack due to deprecation of the 'Defend For Containers' integration. Users using 8.18+ versions should disable this rule and enable linux-based rules tagged "Domain: Container".
60
61## Triage and analysis
62
63> **Disclaimer**:
64> 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.
65
66### Investigating Deprecated - Netcat Listener Established Inside A Container
67
68Netcat is a versatile networking tool used for reading and writing data across network connections, often employed for legitimate purposes like debugging and network diagnostics. However, adversaries can exploit Netcat to establish unauthorized backdoors or exfiltrate data from containers. The detection rule identifies suspicious Netcat activity by monitoring process events within containers, focusing on specific arguments that indicate a listening state, which is a common trait of malicious use. This proactive detection helps mitigate potential threats by flagging unusual network behavior indicative of compromise.
69
70### Possible investigation steps
71
72- Review the container ID associated with the alert to identify the specific container where the Netcat listener was established. This can help in understanding the context and potential impact.
73- Examine the process name and arguments to confirm the presence of Netcat and its listening state. Look for arguments like "-l", "--listen", "-p", or "--source-port" to verify the listener setup.
74- Check the parent process of the Netcat instance to determine how it was initiated. This can provide insights into whether it was started by a legitimate application or a potentially malicious script.
75- Investigate the network connections associated with the container to identify any unusual or unauthorized connections that may indicate data exfiltration or communication with a command and control server.
76- Analyze the container's recent activity and logs to identify any other suspicious behavior or anomalies that could be related to the Netcat listener, such as unexpected file modifications or other process executions.
77- Assess the container's security posture and configuration to determine if there are any vulnerabilities or misconfigurations that could have been exploited to establish the Netcat listener.
78
79### False positive analysis
80
81- Development and testing activities within containers may trigger the rule if Netcat is used for legitimate debugging or network diagnostics. Users can create exceptions for specific container IDs or process names associated with known development environments.
82- Automated scripts or tools that utilize Netcat for routine network checks or health monitoring might be flagged. To mitigate this, users can whitelist these scripts by identifying their unique process arguments or execution patterns.
83- Containers running network services that rely on Netcat for legitimate communication purposes could be mistakenly identified. Users should document and exclude these services by specifying their container IDs and associated process arguments.
84- Security tools or monitoring solutions that incorporate Netcat for legitimate scanning or testing purposes may cause false positives. Users can manage this by excluding these tools based on their known process names and arguments.
85
86### Response and remediation
87
88- Immediately isolate the affected container to prevent further unauthorized access or data exfiltration. This can be done by stopping the container or disconnecting it from the network.
89- Conduct a thorough review of the container's logs and process history to identify any unauthorized access or data transfers that may have occurred.
90- Remove any unauthorized Netcat binaries or scripts found within the container to eliminate the backdoor.
91- Rebuild the container from a known good image to ensure no residual malicious artifacts remain.
92- Update container images and underlying host systems with the latest security patches to mitigate vulnerabilities that could be exploited by similar threats.
93- Implement network segmentation and firewall rules to restrict unauthorized outbound connections from containers, reducing the risk of data exfiltration.
94- Escalate the incident to the security operations team for further investigation and to assess the potential impact on other containers or systems within the environment."""
95
96
97[[rule.threat]]
98framework = "MITRE ATT&CK"
99[[rule.threat.technique]]
100id = "T1059"
101name = "Command and Scripting Interpreter"
102reference = "https://attack.mitre.org/techniques/T1059/"
103[[rule.threat.technique.subtechnique]]
104id = "T1059.004"
105name = "Unix Shell"
106reference = "https://attack.mitre.org/techniques/T1059/004/"
107
108
109
110[rule.threat.tactic]
111id = "TA0002"
112name = "Execution"
113reference = "https://attack.mitre.org/tactics/TA0002/"
Setup
This rule was deprecated in the 8.18 and 9.0 versions of the Elastic Stack due to deprecation of the 'Defend For Containers' integration. Users using 8.18+ versions should disable this rule and enable linux-based rules tagged "Domain: Container".
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 Deprecated - Netcat Listener Established Inside A Container
Netcat is a versatile networking tool used for reading and writing data across network connections, often employed for legitimate purposes like debugging and network diagnostics. However, adversaries can exploit Netcat to establish unauthorized backdoors or exfiltrate data from containers. The detection rule identifies suspicious Netcat activity by monitoring process events within containers, focusing on specific arguments that indicate a listening state, which is a common trait of malicious use. This proactive detection helps mitigate potential threats by flagging unusual network behavior indicative of compromise.
Possible investigation steps
- Review the container ID associated with the alert to identify the specific container where the Netcat listener was established. This can help in understanding the context and potential impact.
- Examine the process name and arguments to confirm the presence of Netcat and its listening state. Look for arguments like "-l", "--listen", "-p", or "--source-port" to verify the listener setup.
- Check the parent process of the Netcat instance to determine how it was initiated. This can provide insights into whether it was started by a legitimate application or a potentially malicious script.
- Investigate the network connections associated with the container to identify any unusual or unauthorized connections that may indicate data exfiltration or communication with a command and control server.
- Analyze the container's recent activity and logs to identify any other suspicious behavior or anomalies that could be related to the Netcat listener, such as unexpected file modifications or other process executions.
- Assess the container's security posture and configuration to determine if there are any vulnerabilities or misconfigurations that could have been exploited to establish the Netcat listener.
False positive analysis
- Development and testing activities within containers may trigger the rule if Netcat is used for legitimate debugging or network diagnostics. Users can create exceptions for specific container IDs or process names associated with known development environments.
- Automated scripts or tools that utilize Netcat for routine network checks or health monitoring might be flagged. To mitigate this, users can whitelist these scripts by identifying their unique process arguments or execution patterns.
- Containers running network services that rely on Netcat for legitimate communication purposes could be mistakenly identified. Users should document and exclude these services by specifying their container IDs and associated process arguments.
- Security tools or monitoring solutions that incorporate Netcat for legitimate scanning or testing purposes may cause false positives. Users can manage this by excluding these tools based on their known process names and arguments.
Response and remediation
- Immediately isolate the affected container to prevent further unauthorized access or data exfiltration. This can be done by stopping the container or disconnecting it from the network.
- Conduct a thorough review of the container's logs and process history to identify any unauthorized access or data transfers that may have occurred.
- Remove any unauthorized Netcat binaries or scripts found within the container to eliminate the backdoor.
- Rebuild the container from a known good image to ensure no residual malicious artifacts remain.
- Update container images and underlying host systems with the latest security patches to mitigate vulnerabilities that could be exploited by similar threats.
- Implement network segmentation and firewall rules to restrict unauthorized outbound connections from containers, reducing the risk of data exfiltration.
- Escalate the incident to the security operations team for further investigation and to assess the potential impact on other containers or systems within the environment.
Related rules
- Deprecated - Container Management Utility Run Inside A Container
- Deprecated - File Made Executable via Chmod Inside A Container
- Deprecated - Interactive Exec Command Launched Against A Running Container
- Deprecated - Suspicious Interactive Shell Spawned From Inside A Container
- Deprecated - AWS Credentials Searched For Inside A Container