Potential OpenSSH Backdoor Logging Activity

Identifies a Secure Shell (SSH) client or server process creating 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"
  5updated_date = "2026/10/08"
  6
  7[rule]
  8author = ["Elastic"]
  9description = """
 10Identifies a Secure Shell (SSH) client or server process creating a known SSH backdoor log file. Adversaries may
 11modify SSH related binaries for persistence or credential access via patching sensitive functions to enable
 12unauthorized access or to log SSH credentials for exfiltration.
 13"""
 14false_positives = ["Updates to approved and trusted SSH executables can trigger this rule."]
 15from = "now-9m"
 16index = [
 17    "logs-endpoint.events.file-*",
 18    "endgame-*",
 19    "logs-sentinel_one_cloud_funnel.*"
 20]
 21language = "eql"
 22license = "Elastic License v2"
 23name = "Potential OpenSSH Backdoor Logging Activity"
 24note = """## Triage and analysis
 25
 26> **Disclaimer**:
 27> 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.
 28
 29### Investigating Potential OpenSSH Backdoor Logging Activity
 30
 31OpenSSH 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.
 32
 33### Possible investigation steps
 34
 35- 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".
 36- 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.
 37- 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.
 38- 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.
 39- 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.
 40- 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.
 41
 42### False positive analysis
 43
 44- 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.
 45- 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.
 46- 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.
 47- Development or testing environments where SSH binaries are frequently modified for testing purposes may generate alerts. Implement exclusions for these environments to reduce noise.
 48- 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.
 49
 50### Response and remediation
 51
 52- Immediately isolate the affected system from the network to prevent further unauthorized access or data exfiltration.
 53- Terminate any suspicious SSH processes identified in the alert to halt potential backdoor activity.
 54- 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.
 55- Restore affected files and binaries from a known good backup to ensure system integrity and remove any backdoor modifications.
 56- Change all SSH credentials and keys associated with the compromised system to prevent unauthorized access using potentially logged credentials.
 57- 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.
 58- 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."""
 59references = [
 60    "https://github.com/eset/malware-ioc/tree/master/sshdoor",
 61    "https://www.welivesecurity.com/wp-content/uploads/2021/01/ESET_Kobalos.pdf",
 62]
 63risk_score = 21
 64rule_id = "f28e2be4-6eca-4349-bdd9-381573730c22"
 65setup = """## Setup
 66
 67This rule requires data coming in from one of the following integrations:
 68- Elastic Defend
 69- Elastic Endgame
 70- SentinelOne Cloud Funnel
 71
 72### Elastic Defend Integration Setup
 73Elastic 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.
 74
 75#### Prerequisite Requirements:
 76- Fleet is required for Elastic Defend.
 77- To configure Fleet Server refer to the [documentation](https://www.elastic.co/guide/en/fleet/current/fleet-server.html).
 78
 79#### The following steps should be executed in order to add the Elastic Defend integration on a Linux System:
 80- Go to the Kibana home page and click "Add integrations".
 81- In the query bar, search for "Elastic Defend" and select the integration to see more details about it.
 82- Click "Add Elastic Defend".
 83- Configure the integration name and optionally add a description.
 84- Select the type of environment you want to protect, either "Traditional Endpoints" or "Cloud Workloads".
 85- 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).
 86- We suggest selecting "Complete EDR (Endpoint Detection and Response)" as a configuration setting, that provides "All events; all preventions"
 87- 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.
 88For more details on Elastic Agent configuration settings, refer to the [helper guide](https://www.elastic.co/guide/en/fleet/8.10/agent-policy.html).
 89- Click "Save and Continue".
 90- 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.
 91For more details on Elastic Defend refer to the [helper guide](https://www.elastic.co/guide/en/security/current/install-endpoint.html).
 92"""
 93severity = "low"
 94tags = [
 95    "Domain: Endpoint",
 96    "OS: Linux",
 97    "Use Case: Threat Detection",
 98    "Tactic: Persistence",
 99    "Tactic: Credential Access",
100    "Data Source: Elastic Endgame",
101    "Data Source: Elastic Defend",
102    "Data Source: SentinelOne",
103    "Resources: Investigation Guide",
104    "Noise: Medium",
105    "Performance: Normal",
106    "Rule Type: Event Correlation (EQL)",
107    "Platform: Linux",
108]
109timestamp_override = "event.ingested"
110type = "eql"
111query = '''
112file where host.os.type == "linux" and event.type == "creation" and process.name in ("ssh", "sshd") and
113  (
114    (
115      file.name : (".*", "~*", "*~") and not file.name : (
116        ".cache", ".viminfo", ".bash_history", ".google_authenticator", ".jelenv", ".csvignore", ".rtreport", ".git*"
117      )
118    ) or
119    file.extension : ("in", "out", "ini", "h", "gz", "so", "sock", "sync", "0", "1", "2", "3", "4", "5", "6", "7", "8", "9") or
120    file.path :
121    (
122      "/tmp/*",
123      "/var/tmp/*",
124      "/dev/shm/*",
125      "/usr/share/*",
126      "/usr/include/*",
127      "/usr/local/include/*",
128      "/usr/share/man/*",
129      "/usr/local/share/*",
130      "/usr/lib/*.so.*",
131      "/usr/bin/ssd",
132      "/var/run/sshd/sshd.pid",
133      "/var/run/nscd/ns.pid",
134      "/var/run/udev/ud.pid",
135      "/var/run/udevd.pid"
136    )
137  ) and
138  not file.path like ("/tmp/krb5cc*", "/tmp/ansible_*", "/storage/*", "/tmp/clearsigned.message.*", "/tmp/fileutil.message.*")
139'''
140
141[[rule.threat]]
142framework = "MITRE ATT&CK"
143
144[[rule.threat.technique]]
145id = "T1556"
146name = "Modify Authentication Process"
147reference = "https://attack.mitre.org/techniques/T1556/"
148
149[rule.threat.tactic]
150id = "TA0006"
151name = "Credential Access"
152reference = "https://attack.mitre.org/tactics/TA0006/"
153
154[[rule.threat]]
155framework = "MITRE ATT&CK"
156
157[[rule.threat.technique]]
158id = "T1554"
159name = "Compromise Host Software Binary"
160reference = "https://attack.mitre.org/techniques/T1554/"
161
162[rule.threat.tactic]
163id = "TA0003"
164name = "Persistence"
165reference = "https://attack.mitre.org/tactics/TA0003/"
166
167[[rule.threat]]
168framework = "MITRE ATT&CK"
169
170[[rule.threat.technique]]
171id = "T1074"
172name = "Data Staged"
173reference = "https://attack.mitre.org/techniques/T1074/"
174
175[[rule.threat.technique.subtechnique]]
176id = "T1074.001"
177name = "Local Data Staging"
178reference = "https://attack.mitre.org/techniques/T1074/001/"
179
180[rule.threat.tactic]
181id = "TA0009"
182name = "Collection"
183reference = "https://attack.mitre.org/tactics/TA0009/"

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

to-top