Potential OpenSSH Backdoor Logging Activity
Identifies a Secure Shell (SSH) client or server process creating or writing to a known SSH backdoor log file. Adversaries may modify SSH related binaries for persistence or credential access via patching sensitive functions to enable unauthorized access or to log SSH credentials for exfiltration.
Elastic rule (View on GitHub)
1[metadata]
2creation_date = "2020/12/21"
3integration = ["endpoint", "sentinel_one_cloud_funnel"]
4maturity = "production"
5min_stack_comments = "Breaking change at 8.13.0 for SentinelOne Integration."
6min_stack_version = "8.13.0"
7updated_date = "2025/01/15"
8
9[rule]
10author = ["Elastic"]
11description = """
12Identifies a Secure Shell (SSH) client or server process creating or writing to a known SSH backdoor log file.
13Adversaries may modify SSH related binaries for persistence or credential access via patching sensitive functions to
14enable unauthorized access or to log SSH credentials for exfiltration.
15"""
16false_positives = ["Updates to approved and trusted SSH executables can trigger this rule."]
17from = "now-9m"
18index = ["auditbeat-*", "logs-endpoint.events.*", "endgame-*", "logs-sentinel_one_cloud_funnel.*"]
19language = "eql"
20license = "Elastic License v2"
21name = "Potential OpenSSH Backdoor Logging Activity"
22references = [
23 "https://github.com/eset/malware-ioc/tree/master/sshdoor",
24 "https://www.welivesecurity.com/wp-content/uploads/2021/01/ESET_Kobalos.pdf",
25]
26risk_score = 73
27rule_id = "f28e2be4-6eca-4349-bdd9-381573730c22"
28setup = """## Setup
29
30This rule requires data coming in from one of the following integrations:
31- Elastic Defend
32- Auditbeat
33
34### Elastic Defend Integration Setup
35Elastic 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.
36
37#### Prerequisite Requirements:
38- Fleet is required for Elastic Defend.
39- To configure Fleet Server refer to the [documentation](https://www.elastic.co/guide/en/fleet/current/fleet-server.html).
40
41#### The following steps should be executed in order to add the Elastic Defend integration on a Linux System:
42- Go to the Kibana home page and click "Add integrations".
43- In the query bar, search for "Elastic Defend" and select the integration to see more details about it.
44- Click "Add Elastic Defend".
45- Configure the integration name and optionally add a description.
46- Select the type of environment you want to protect, either "Traditional Endpoints" or "Cloud Workloads".
47- 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).
48- We suggest selecting "Complete EDR (Endpoint Detection and Response)" as a configuration setting, that provides "All events; all preventions"
49- 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.
50For more details on Elastic Agent configuration settings, refer to the [helper guide](https://www.elastic.co/guide/en/fleet/8.10/agent-policy.html).
51- Click "Save and Continue".
52- 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.
53For more details on Elastic Defend refer to the [helper guide](https://www.elastic.co/guide/en/security/current/install-endpoint.html).
54
55### Auditbeat Setup
56Auditbeat is a lightweight shipper that you can install on your servers to audit the activities of users and processes on your systems. For example, you can use Auditbeat to collect and centralize audit events from the Linux Audit Framework. You can also use Auditbeat to detect changes to critical files, like binaries and configuration files, and identify potential security policy violations.
57
58#### The following steps should be executed in order to add the Auditbeat on a Linux System:
59- Elastic provides repositories available for APT and YUM-based distributions. Note that we provide binary packages, but no source packages.
60- To install the APT and YUM repositories follow the setup instructions in this [helper guide](https://www.elastic.co/guide/en/beats/auditbeat/current/setup-repositories.html).
61- To run Auditbeat on Docker follow the setup instructions in the [helper guide](https://www.elastic.co/guide/en/beats/auditbeat/current/running-on-docker.html).
62- To run Auditbeat on Kubernetes follow the setup instructions in the [helper guide](https://www.elastic.co/guide/en/beats/auditbeat/current/running-on-kubernetes.html).
63- For complete “Setup and Run Auditbeat” information refer to the [helper guide](https://www.elastic.co/guide/en/beats/auditbeat/current/setting-up-and-running.html).
64
65#### Custom Ingest Pipeline
66For versions <8.2, you need to add a custom ingest pipeline to populate `event.ingested` with @timestamp for non-elastic-agent indexes, like auditbeats/filebeat/winlogbeat etc. For more details to add a custom ingest pipeline refer to the [guide](https://www.elastic.co/guide/en/fleet/current/data-streams-pipeline-tutorial.html).
67"""
68severity = "high"
69tags = [
70 "Domain: Endpoint",
71 "OS: Linux",
72 "Use Case: Threat Detection",
73 "Tactic: Persistence",
74 "Tactic: Credential Access",
75 "Data Source: Elastic Endgame",
76 "Data Source: Elastic Defend",
77 "Data Source: SentinelOne",
78 "Resources: Investigation Guide",
79]
80timestamp_override = "event.ingested"
81type = "eql"
82
83query = '''
84file where host.os.type == "linux" and event.type == "change" and process.executable : ("/usr/sbin/sshd", "/usr/bin/ssh") and
85 (
86 (file.name : (".*", "~*", "*~") and not file.name : (".cache", ".viminfo", ".bash_history", ".google_authenticator",
87 ".jelenv", ".csvignore", ".rtreport")) or
88 file.extension : ("in", "out", "ini", "h", "gz", "so", "sock", "sync", "0", "1", "2", "3", "4", "5", "6", "7", "8", "9") or
89 file.path :
90 (
91 "/private/etc/*--",
92 "/usr/share/*",
93 "/usr/include/*",
94 "/usr/local/include/*",
95 "/private/tmp/*",
96 "/private/var/tmp/*",
97 "/usr/tmp/*",
98 "/usr/share/man/*",
99 "/usr/local/share/*",
100 "/usr/lib/*.so.*",
101 "/private/etc/ssh/.sshd_auth",
102 "/usr/bin/ssd",
103 "/private/var/opt/power",
104 "/private/etc/ssh/ssh_known_hosts",
105 "/private/var/html/lol",
106 "/private/var/log/utmp",
107 "/private/var/lib",
108 "/var/run/sshd/sshd.pid",
109 "/var/run/nscd/ns.pid",
110 "/var/run/udev/ud.pid",
111 "/var/run/udevd.pid"
112 )
113 )
114'''
115note = """## Triage and analysis
116
117> **Disclaimer**:
118> 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.
119
120### Investigating Potential OpenSSH Backdoor Logging Activity
121
122OpenSSH is a widely used protocol for secure remote administration and file transfers. Adversaries may exploit OpenSSH by modifying its binaries to log credentials or maintain unauthorized access. The detection rule identifies suspicious file changes linked to SSH processes, focusing on unusual file names, extensions, and paths indicative of backdoor activity, thus helping to uncover potential security breaches.
123
124### Possible investigation steps
125
126- Review the file change event details to identify the specific file name, extension, and path involved in the alert. Pay particular attention to unusual file names or extensions and paths listed in the query, such as "/usr/lib/*.so.*" or "/private/etc/ssh/.sshd_auth".
127- Examine the process executable that triggered the alert, either "/usr/sbin/sshd" or "/usr/bin/ssh", to determine if it has been modified or replaced. Check the integrity of these binaries using hash comparisons against known good versions.
128- Investigate the user account associated with the process that made the file change. Determine if the account has a history of suspicious activity or if it has been compromised.
129- Check for any recent or unusual login attempts or sessions related to the SSH service on the host. Look for patterns that might indicate unauthorized access or credential harvesting.
130- Analyze system logs, such as auth.log or secure.log, for any anomalies or entries that coincide with the time of the file change event. This can provide additional context or evidence of malicious activity.
131- If a backdoor is suspected, consider isolating the affected system from the network to prevent further unauthorized access and begin remediation efforts, such as restoring from a clean backup or reinstalling the affected services.
132
133### False positive analysis
134
135- Routine system updates or package installations may trigger file changes in SSH-related directories. Users can create exceptions for known update processes to prevent false alerts.
136- Custom scripts or administrative tasks that modify SSH configuration files for legitimate purposes might be flagged. Users should whitelist these scripts or processes if they are verified as non-malicious.
137- Backup or synchronization tools that create temporary files with unusual extensions or names in SSH directories can cause false positives. Exclude these tools from monitoring if they are part of regular operations.
138- Development or testing environments where SSH binaries are frequently modified for testing purposes may generate alerts. Implement exclusions for these environments to reduce noise.
139- Automated configuration management tools like Ansible or Puppet that modify SSH settings as part of their operations can be excluded if they are part of authorized workflows.
140
141### Response and remediation
142
143- Immediately isolate the affected system from the network to prevent further unauthorized access or data exfiltration.
144- Terminate any suspicious SSH processes identified in the alert to halt potential backdoor activity.
145- Conduct a thorough review of the modified files and binaries, particularly those listed in the query, to assess the extent of the compromise and identify any malicious code or unauthorized changes.
146- Restore affected files and binaries from a known good backup to ensure system integrity and remove any backdoor modifications.
147- Change all SSH credentials and keys associated with the compromised system to prevent unauthorized access using potentially logged credentials.
148- Implement additional monitoring on the affected system and network for any signs of persistence or further malicious activity, focusing on the paths and file types highlighted in the detection query.
149- Escalate the incident to the security operations team for further investigation and to determine if additional systems may be affected, ensuring a coordinated response to the threat."""
150
151
152[[rule.threat]]
153framework = "MITRE ATT&CK"
154[[rule.threat.technique]]
155id = "T1556"
156name = "Modify Authentication Process"
157reference = "https://attack.mitre.org/techniques/T1556/"
158
159
160[rule.threat.tactic]
161id = "TA0006"
162name = "Credential Access"
163reference = "https://attack.mitre.org/tactics/TA0006/"
164[[rule.threat]]
165framework = "MITRE ATT&CK"
166[[rule.threat.technique]]
167id = "T1554"
168name = "Compromise Host Software Binary"
169reference = "https://attack.mitre.org/techniques/T1554/"
170
171
172[rule.threat.tactic]
173id = "TA0003"
174name = "Persistence"
175reference = "https://attack.mitre.org/tactics/TA0003/"
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 Potential OpenSSH Backdoor Logging Activity
OpenSSH is a widely used protocol for secure remote administration and file transfers. Adversaries may exploit OpenSSH by modifying its binaries to log credentials or maintain unauthorized access. The detection rule identifies suspicious file changes linked to SSH processes, focusing on unusual file names, extensions, and paths indicative of backdoor activity, thus helping to uncover potential security breaches.
Possible investigation steps
- Review the file change event details to identify the specific file name, extension, and path involved in the alert. Pay particular attention to unusual file names or extensions and paths listed in the query, such as "/usr/lib/.so." or "/private/etc/ssh/.sshd_auth".
- Examine the process executable that triggered the alert, either "/usr/sbin/sshd" or "/usr/bin/ssh", to determine if it has been modified or replaced. Check the integrity of these binaries using hash comparisons against known good versions.
- Investigate the user account associated with the process that made the file change. Determine if the account has a history of suspicious activity or if it has been compromised.
- Check for any recent or unusual login attempts or sessions related to the SSH service on the host. Look for patterns that might indicate unauthorized access or credential harvesting.
- Analyze system logs, such as auth.log or secure.log, for any anomalies or entries that coincide with the time of the file change event. This can provide additional context or evidence of malicious activity.
- If a backdoor is suspected, consider isolating the affected system from the network to prevent further unauthorized access and begin remediation efforts, such as restoring from a clean backup or reinstalling the affected services.
False positive analysis
- Routine system updates or package installations may trigger file changes in SSH-related directories. Users can create exceptions for known update processes to prevent false alerts.
- Custom scripts or administrative tasks that modify SSH configuration files for legitimate purposes might be flagged. Users should whitelist these scripts or processes if they are verified as non-malicious.
- Backup or synchronization tools that create temporary files with unusual extensions or names in SSH directories can cause false positives. Exclude these tools from monitoring if they are part of regular operations.
- Development or testing environments where SSH binaries are frequently modified for testing purposes may generate alerts. Implement exclusions for these environments to reduce noise.
- Automated configuration management tools like Ansible or Puppet that modify SSH settings as part of their operations can be excluded if they are part of authorized workflows.
Response and remediation
- Immediately isolate the affected system from the network to prevent further unauthorized access or data exfiltration.
- Terminate any suspicious SSH processes identified in the alert to halt potential backdoor activity.
- Conduct a thorough review of the modified files and binaries, particularly those listed in the query, to assess the extent of the compromise and identify any malicious code or unauthorized changes.
- Restore affected files and binaries from a known good backup to ensure system integrity and remove any backdoor modifications.
- Change all SSH credentials and keys associated with the compromised system to prevent unauthorized access using potentially logged credentials.
- Implement additional monitoring on the affected system and network for any signs of persistence or further malicious activity, focusing on the paths and file types highlighted in the detection query.
- Escalate the incident to the security operations team for further investigation and to determine if additional systems may be affected, ensuring a coordinated response to the threat.
References
Related rules
- Pluggable Authentication Module (PAM) Creation in Unusual Directory
- Pluggable Authentication Module (PAM) Version Discovery
- Chkconfig Service Add
- DNF Package Manager Plugin File Creation
- Directory Creation in /bin directory