Network Connection Initiated by SSHD Child Process

This rule identifies an egress internet connection initiated by an SSH Daemon child process. This behavior is indicative of the alteration of a shell configuration file or other mechanism that launches a process when a new SSH login occurs. Attackers can also backdoor the SSH daemon to allow for persistence, call out to a C2 or to steal credentials.

Elastic rule (View on GitHub)

  1[metadata]
  2creation_date = "2024/06/06"
  3integration = ["endpoint"]
  4maturity = "production"
  5updated_date = "2024/10/17"
  6
  7[rule]
  8author = ["Elastic"]
  9description = """
 10This rule identifies an egress internet connection initiated by an SSH Daemon child process. This behavior is
 11indicative of the alteration of a shell configuration file or other mechanism that launches a process when a
 12new SSH login occurs. Attackers can also backdoor the SSH daemon to allow for persistence, call out to a C2
 13or to steal credentials.
 14"""
 15from = "now-9m"
 16index = ["logs-endpoint.events.*"]
 17language = "eql"
 18license = "Elastic License v2"
 19name = "Network Connection Initiated by SSHD Child Process"
 20references = ["https://hadess.io/the-art-of-linux-persistence/"]
 21risk_score = 47
 22rule_id = "63431796-f813-43af-820b-492ee2efec8e"
 23severity = "medium"
 24tags = [
 25    "Domain: Endpoint",
 26    "OS: Linux",
 27    "Use Case: Threat Detection",
 28    "Tactic: Persistence",
 29    "Data Source: Elastic Defend"
 30]
 31type = "eql"
 32query = '''
 33sequence by host.id with maxspan=1s
 34  [process where host.os.type == "linux" and event.type == "start" and event.action == "exec" and
 35   process.parent.executable == "/usr/sbin/sshd"] by process.entity_id
 36  [network where host.os.type == "linux" and event.type == "start" and event.action == "connection_attempted" and not (
 37     destination.ip == null or destination.ip == "0.0.0.0" or cidrmatch(
 38     destination.ip, "10.0.0.0/8", "127.0.0.0/8", "169.254.0.0/16", "172.16.0.0/12", "192.0.0.0/24", "192.0.0.0/29",
 39     "192.0.0.8/32", "192.0.0.9/32", "192.0.0.10/32", "192.0.0.170/32", "192.0.0.171/32", "192.0.2.0/24",
 40     "192.31.196.0/24", "192.52.193.0/24", "192.168.0.0/16", "192.88.99.0/24", "224.0.0.0/4", "100.64.0.0/10",
 41     "192.175.48.0/24","198.18.0.0/15", "198.51.100.0/24", "203.0.113.0/24", "240.0.0.0/4", "::1", "FE80::/10",
 42     "FF00::/8", "172.31.0.0/16"
 43     )
 44    ) and not (
 45      process.executable in ("/bin/yum", "/usr/bin/yum") or
 46      process.name in ("login_duo", "ssh", "sshd", "sshd-session")
 47    )
 48  ] by process.parent.entity_id
 49'''
 50
 51[[rule.threat]]
 52framework = "MITRE ATT&CK"
 53
 54[[rule.threat.technique]]
 55id = "T1546"
 56name = "Event Triggered Execution"
 57reference = "https://attack.mitre.org/techniques/T1546/"
 58
 59[[rule.threat.technique.subtechnique]]
 60id = "T1546.004"
 61name = "Unix Shell Configuration Modification"
 62reference = "https://attack.mitre.org/techniques/T1546/004/"
 63
 64[rule.threat.tactic]
 65id = "TA0003"
 66name = "Persistence"
 67reference = "https://attack.mitre.org/tactics/TA0003/"
 68
 69[[rule.threat]]
 70framework = "MITRE ATT&CK"
 71
 72[[rule.threat.technique]]
 73id = "T1021"
 74name = "Remote Services"
 75reference = "https://attack.mitre.org/techniques/T1021/"
 76
 77[[rule.threat.technique.subtechnique]]
 78id = "T1021.004"
 79name = "SSH"
 80reference = "https://attack.mitre.org/techniques/T1021/004/"
 81
 82[[rule.threat.technique]]
 83id = "T1563"
 84name = "Remote Service Session Hijacking"
 85reference = "https://attack.mitre.org/techniques/T1563/"
 86
 87[[rule.threat.technique.subtechnique]]
 88id = "T1563.001"
 89name = "SSH Hijacking"
 90reference = "https://attack.mitre.org/techniques/T1563/001/"
 91
 92[rule.threat.tactic]
 93id = "TA0008"
 94name = "Lateral Movement"
 95reference = "https://attack.mitre.org/tactics/TA0008/"
 96
 97[[rule.threat]]
 98framework = "MITRE ATT&CK"
 99
100[rule.threat.tactic]
101id = "TA0011"
102name = "Command and Control"
103reference = "https://attack.mitre.org/tactics/TA0011/"

References

Related rules

to-top