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", "sentinel_one_cloud_funnel", "m365_defender", "system", "crowdstrike"]
  4maturity = "production"
  5min_stack_comments = "Breaking change at 8.14.0 for the Windows Integration."
  6min_stack_version = "8.14.0"
  7updated_date = "2024/10/31"
  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*", "logs-sentinel_one_cloud_funnel.*", "logs-m365_defender.event-*", "logs-crowdstrike.fdr*"]
 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"
 57severity = "high"
 58tags = [
 59    "Domain: Endpoint",
 60    "OS: Windows",
 61    "Use Case: Threat Detection",
 62    "Tactic: Command and Control",
 63    "Tactic: Lateral Movement",
 64    "Resources: Investigation Guide",
 65    "Data Source: Elastic Endgame",
 66    "Data Source: Elastic Defend",
 67    "Data Source: SentinelOne",
 68    "Data Source: Microsoft Defender for Endpoint",
 69    "Data Source: System",
 70    "Data Source: Crowdstrike",
 71]
 72timestamp_override = "event.ingested"
 73type = "eql"
 74
 75query = '''
 76process where host.os.type == "windows" and event.type == "start" and
 77  /* RDP port and usual SSH tunneling related switches in command line */
 78  process.args : "*:3389" and
 79  process.args : ("-L", "-P", "-R", "-pw", "-ssh")
 80'''
 81
 82
 83[[rule.threat]]
 84framework = "MITRE ATT&CK"
 85[[rule.threat.technique]]
 86id = "T1572"
 87name = "Protocol Tunneling"
 88reference = "https://attack.mitre.org/techniques/T1572/"
 89
 90
 91[rule.threat.tactic]
 92id = "TA0011"
 93name = "Command and Control"
 94reference = "https://attack.mitre.org/tactics/TA0011/"
 95
 96[[rule.threat]]
 97framework = "MITRE ATT&CK"
 98[[rule.threat.technique]]
 99id = "T1021"
100name = "Remote Services"
101reference = "https://attack.mitre.org/techniques/T1021/"
102[[rule.threat.technique.subtechnique]]
103id = "T1021.004"
104name = "SSH"
105reference = "https://attack.mitre.org/techniques/T1021/004/"
106
107
108
109[rule.threat.tactic]
110id = "TA0008"
111name = "Lateral Movement"
112reference = "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