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"]
  4maturity = "production"
  5updated_date = "2024/05/31"
  6
  7[rule]
  8author = ["Elastic"]
  9description = """
 10Identifies a Secure Shell (SSH) client or server process creating or writing to a known SSH backdoor log file.
 11Adversaries may modify SSH related binaries for persistence or credential access via patching sensitive functions to
 12enable unauthorized 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 = ["auditbeat-*", "logs-endpoint.events.*", "endgame-*"]
 17language = "eql"
 18license = "Elastic License v2"
 19name = "Potential OpenSSH Backdoor Logging Activity"
 20references = [
 21    "https://github.com/eset/malware-ioc/tree/master/sshdoor",
 22    "https://www.welivesecurity.com/wp-content/uploads/2021/01/ESET_Kobalos.pdf",
 23]
 24risk_score = 73
 25rule_id = "f28e2be4-6eca-4349-bdd9-381573730c22"
 26setup = """## Setup
 27
 28This rule requires data coming in from one of the following integrations:
 29- Elastic Defend
 30- Auditbeat
 31
 32### Elastic Defend Integration Setup
 33Elastic 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.
 34
 35#### Prerequisite Requirements:
 36- Fleet is required for Elastic Defend.
 37- To configure Fleet Server refer to the [documentation](https://www.elastic.co/guide/en/fleet/current/fleet-server.html).
 38
 39#### The following steps should be executed in order to add the Elastic Defend integration on a Linux System:
 40- Go to the Kibana home page and click "Add integrations".
 41- In the query bar, search for "Elastic Defend" and select the integration to see more details about it.
 42- Click "Add Elastic Defend".
 43- Configure the integration name and optionally add a description.
 44- Select the type of environment you want to protect, either "Traditional Endpoints" or "Cloud Workloads".
 45- 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).
 46- We suggest selecting "Complete EDR (Endpoint Detection and Response)" as a configuration setting, that provides "All events; all preventions"
 47- 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.
 48For more details on Elastic Agent configuration settings, refer to the [helper guide](https://www.elastic.co/guide/en/fleet/8.10/agent-policy.html).
 49- Click "Save and Continue".
 50- 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.
 51For more details on Elastic Defend refer to the [helper guide](https://www.elastic.co/guide/en/security/current/install-endpoint.html).
 52
 53### Auditbeat Setup
 54Auditbeat 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.
 55
 56#### The following steps should be executed in order to add the Auditbeat on a Linux System:
 57- Elastic provides repositories available for APT and YUM-based distributions. Note that we provide binary packages, but no source packages.
 58- 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).
 59- 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).
 60- 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).
 61- 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).
 62
 63#### Custom Ingest Pipeline
 64For 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).
 65"""
 66severity = "high"
 67tags = [
 68    "Domain: Endpoint",
 69    "OS: Linux",
 70    "Use Case: Threat Detection",
 71    "Tactic: Persistence",
 72    "Tactic: Credential Access",
 73    "Data Source: Elastic Endgame",
 74    "Data Source: Elastic Defend",
 75]
 76timestamp_override = "event.ingested"
 77type = "eql"
 78
 79query = '''
 80file where host.os.type == "linux" and event.type == "change" and process.executable : ("/usr/sbin/sshd", "/usr/bin/ssh") and
 81  (
 82    (file.name : (".*", "~*", "*~") and not file.name : (".cache", ".viminfo", ".bash_history", ".google_authenticator",
 83      ".jelenv", ".csvignore", ".rtreport")) or
 84    file.extension : ("in", "out", "ini", "h", "gz", "so", "sock", "sync", "0", "1", "2", "3", "4", "5", "6", "7", "8", "9") or
 85    file.path :
 86    (
 87      "/private/etc/*--",
 88      "/usr/share/*",
 89      "/usr/include/*",
 90      "/usr/local/include/*",
 91      "/private/tmp/*",
 92      "/private/var/tmp/*",
 93      "/usr/tmp/*",
 94      "/usr/share/man/*",
 95      "/usr/local/share/*",
 96      "/usr/lib/*.so.*",
 97      "/private/etc/ssh/.sshd_auth",
 98      "/usr/bin/ssd",
 99      "/private/var/opt/power",
100      "/private/etc/ssh/ssh_known_hosts",
101      "/private/var/html/lol",
102      "/private/var/log/utmp",
103      "/private/var/lib",
104      "/var/run/sshd/sshd.pid",
105      "/var/run/nscd/ns.pid",
106      "/var/run/udev/ud.pid",
107      "/var/run/udevd.pid"
108    )
109  )
110'''
111
112
113[[rule.threat]]
114framework = "MITRE ATT&CK"
115[[rule.threat.technique]]
116id = "T1556"
117name = "Modify Authentication Process"
118reference = "https://attack.mitre.org/techniques/T1556/"
119
120
121[rule.threat.tactic]
122id = "TA0006"
123name = "Credential Access"
124reference = "https://attack.mitre.org/tactics/TA0006/"
125[[rule.threat]]
126framework = "MITRE ATT&CK"
127[[rule.threat.technique]]
128id = "T1554"
129name = "Compromise Host Software Binary"
130reference = "https://attack.mitre.org/techniques/T1554/"
131
132
133[rule.threat.tactic]
134id = "TA0003"
135name = "Persistence"
136reference = "https://attack.mitre.org/tactics/TA0003/"

References

Related rules

to-top