Potential Remote Desktop Tunneling Detected

Identifies potential use of an SSH utility to establish RDP over a reverse SSH Tunnel. This can be used by attackers to enable routing of network packets that would otherwise not reach their intended destination.

Elastic rule (View on GitHub)

  1[metadata]
  2creation_date = "2020/10/14"
  3integration = ["endpoint", "windows"]
  4maturity = "production"
  5min_stack_comments = "New fields added: required_fields, related_integrations, setup"
  6min_stack_version = "8.3.0"
  7updated_date = "2024/03/28"
  8
  9[rule]
 10author = ["Elastic"]
 11description = """
 12Identifies potential use of an SSH utility to establish RDP over a reverse SSH Tunnel. This can be used by attackers to
 13enable routing of network packets that would otherwise not reach their intended destination.
 14"""
 15from = "now-9m"
 16index = ["logs-endpoint.events.process-*", "winlogbeat-*", "logs-windows.*", "endgame-*", "logs-system.security*"]
 17language = "eql"
 18license = "Elastic License v2"
 19name = "Potential Remote Desktop Tunneling Detected"
 20note = """## Triage and analysis
 21
 22### Investigating Potential Remote Desktop Tunneling Detected
 23
 24Protocol Tunneling is a mechanism that involves explicitly encapsulating a protocol within another for various use cases, ranging from providing an outer layer of encryption (similar to a VPN) to enabling traffic that network appliances would filter to reach their destination.
 25
 26Attackers may tunnel Remote Desktop Protocol (RDP) traffic through other protocols like Secure Shell (SSH) to bypass network restrictions that block incoming RDP connections but may be more permissive to other protocols.
 27
 28This rule looks for command lines involving the `3389` port, which RDP uses by default and options commonly associated with tools that perform tunneling.
 29
 30#### Possible investigation steps
 31
 32- Investigate the process execution chain (parent process tree) for unknown processes. Examine their executable files for prevalence, whether they are located in expected locations, and if they are signed with valid digital signatures.
 33- Identify the user account that performed the action and whether it should perform this kind of action.
 34- Contact the account and system owners and confirm whether they are aware of this activity.
 35- Investigate other alerts associated with the user/host during the past 48 hours.
 36- Assess whether this behavior is prevalent in the environment by looking for similar occurrences across hosts.
 37- Examine network data to determine if the host communicated with external servers using the tunnel.
 38
 39### False positive analysis
 40
 41- This activity is unlikely to happen legitimately. Benign true positives (B-TPs) can be added as exceptions if necessary.
 42- Investigate the command line for the execution of programs that are unrelated to tunneling, like Remote Desktop clients.
 43
 44### Response and remediation
 45
 46- Initiate the incident response process based on the outcome of the triage.
 47- Isolate the involved host to prevent further post-compromise behavior.
 48- Take the necessary actions to disable the tunneling, which can be a process kill, service deletion, registry key modification, etc. Inspect the host to learn which method was used and to determine a response for the case.
 49- Investigate credential exposure on systems compromised or used by the attacker to ensure all compromised accounts are identified. Reset passwords for these accounts and other potentially compromised credentials, such as email, business systems, and web services.
 50- Run a full antimalware scan. This may reveal additional artifacts left in the system, persistence mechanisms, and malware components.
 51- Determine the initial vector abused by the attacker and take action to prevent reinfection through the same vector.
 52- Using the incident response data, update logging and audit policies to improve the mean time to detect (MTTD) and the mean time to respond (MTTR).
 53"""
 54references = ["https://blog.netspi.com/how-to-access-rdp-over-a-reverse-ssh-tunnel/"]
 55risk_score = 73
 56rule_id = "76fd43b7-3480-4dd9-8ad7-8bd36bfad92f"
 57setup = """## Setup
 58
 59If enabling an EQL rule on a non-elastic-agent index (such as beats) for versions <8.2,
 60events will not define `event.ingested` and default fallback for EQL rules was not added until version 8.2.
 61Hence for this rule to work effectively, users will need to add a custom ingest pipeline to populate
 62`event.ingested` to @timestamp.
 63For more details on adding a custom ingest pipeline refer - https://www.elastic.co/guide/en/fleet/current/data-streams-pipeline-tutorial.html
 64"""
 65severity = "high"
 66tags = [
 67    "Domain: Endpoint",
 68    "OS: Windows",
 69    "Use Case: Threat Detection",
 70    "Tactic: Command and Control",
 71    "Tactic: Lateral Movement",
 72    "Resources: Investigation Guide",
 73    "Data Source: Elastic Endgame",
 74    "Data Source: Elastic Defend"
 75]
 76timestamp_override = "event.ingested"
 77type = "eql"
 78
 79query = '''
 80process where host.os.type == "windows" and event.type == "start" and
 81  /* RDP port and usual SSH tunneling related switches in command line */
 82  process.args : "*:3389" and
 83  process.args : ("-L", "-P", "-R", "-pw", "-ssh")
 84'''
 85
 86
 87[[rule.threat]]
 88framework = "MITRE ATT&CK"
 89[[rule.threat.technique]]
 90id = "T1572"
 91name = "Protocol Tunneling"
 92reference = "https://attack.mitre.org/techniques/T1572/"
 93
 94
 95[rule.threat.tactic]
 96id = "TA0011"
 97name = "Command and Control"
 98reference = "https://attack.mitre.org/tactics/TA0011/"
 99
100[[rule.threat]]
101framework = "MITRE ATT&CK"
102[[rule.threat.technique]]
103id = "T1021"
104name = "Remote Services"
105reference = "https://attack.mitre.org/techniques/T1021/"
106[[rule.threat.technique.subtechnique]]
107id = "T1021.004"
108name = "SSH"
109reference = "https://attack.mitre.org/techniques/T1021/004/"
110
111
112
113[rule.threat.tactic]
114id = "TA0008"
115name = "Lateral Movement"
116reference = "https://attack.mitre.org/tactics/TA0008/"

Triage and analysis

Investigating Potential Remote Desktop Tunneling Detected

Protocol Tunneling is a mechanism that involves explicitly encapsulating a protocol within another for various use cases, ranging from providing an outer layer of encryption (similar to a VPN) to enabling traffic that network appliances would filter to reach their destination.

Attackers may tunnel Remote Desktop Protocol (RDP) traffic through other protocols like Secure Shell (SSH) to bypass network restrictions that block incoming RDP connections but may be more permissive to other protocols.

This rule looks for command lines involving the 3389 port, which RDP uses by default and options commonly associated with tools that perform tunneling.

Possible investigation steps

  • Investigate the process execution chain (parent process tree) for unknown processes. Examine their executable files for prevalence, whether they are located in expected locations, and if they are signed with valid digital signatures.
  • Identify the user account that performed the action and whether it should perform this kind of action.
  • Contact the account and system owners and confirm whether they are aware of this activity.
  • Investigate other alerts associated with the user/host during the past 48 hours.
  • Assess whether this behavior is prevalent in the environment by looking for similar occurrences across hosts.
  • Examine network data to determine if the host communicated with external servers using the tunnel.

False positive analysis

  • This activity is unlikely to happen legitimately. Benign true positives (B-TPs) can be added as exceptions if necessary.
  • Investigate the command line for the execution of programs that are unrelated to tunneling, like Remote Desktop clients.

Response and remediation

  • Initiate the incident response process based on the outcome of the triage.
  • Isolate the involved host to prevent further post-compromise behavior.
  • Take the necessary actions to disable the tunneling, which can be a process kill, service deletion, registry key modification, etc. Inspect the host to learn which method was used and to determine a response for the case.
  • Investigate credential exposure on systems compromised or used by the attacker to ensure all compromised accounts are identified. Reset passwords for these accounts and other potentially compromised credentials, such as email, business systems, and web services.
  • Run a full antimalware scan. This may reveal additional artifacts left in the system, persistence mechanisms, and malware components.
  • Determine the initial vector abused by the attacker and take action to prevent reinfection through the same vector.
  • Using the incident response data, update logging and audit policies to improve the mean time to detect (MTTD) and the mean time to respond (MTTR).

References

Related rules

to-top