Remote Desktop Enabled in Windows Firewall by Netsh

Identifies use of the network shell utility (netsh.exe) to enable inbound Remote Desktop Protocol (RDP) connections in the Windows Firewall.

Elastic rule (View on GitHub)

  1[metadata]
  2creation_date = "2020/10/13"
  3integration = ["endpoint", "windows", "system", "m365_defender", "sentinel_one_cloud_funnel"]
  4maturity = "production"
  5updated_date = "2024/10/15"
  6min_stack_version = "8.14.0"
  7min_stack_comments = "Breaking change at 8.14.0 for the Windows Integration."
  8
  9[rule]
 10author = ["Elastic"]
 11description = """
 12Identifies use of the network shell utility (netsh.exe) to enable inbound Remote Desktop Protocol (RDP) connections in
 13the Windows Firewall.
 14"""
 15from = "now-9m"
 16index = [
 17    "winlogbeat-*",
 18    "logs-endpoint.events.process-*",
 19    "logs-windows.forwarded*",
 20    "logs-windows.sysmon_operational-*",
 21    "endgame-*",
 22    "logs-system.security*",
 23    "logs-m365_defender.event-*",
 24    "logs-sentinel_one_cloud_funnel.*",
 25]
 26language = "eql"
 27license = "Elastic License v2"
 28name = "Remote Desktop Enabled in Windows Firewall by Netsh"
 29note = """## Triage and analysis
 30
 31### Investigating Remote Desktop Enabled in Windows Firewall by Netsh
 32
 33Microsoft Remote Desktop Protocol (RDP) is a proprietary Microsoft protocol that enables remote connections to other computers, typically over TCP port 3389.
 34
 35Attackers can use RDP to conduct their actions interactively. Ransomware operators frequently use RDP to access victim servers, often using privileged accounts.
 36
 37This rule detects the creation of a Windows Firewall inbound rule that would allow inbound RDP traffic using the `netsh.exe` utility.
 38
 39#### Possible investigation steps
 40
 41- Identify the user account that performed the action and whether it should perform this kind of action.
 42- Contact the user to check if they are aware of the operation.
 43- 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.
 44- Investigate other alerts associated with the user/host during the past 48 hours.
 45- Check whether it makes sense to enable RDP to this host, given its role in the environment.
 46- Check if the host is directly exposed to the internet.
 47- Check whether privileged accounts accessed the host shortly after the modification.
 48- Review network events within a short timespan of this alert for incoming RDP connection attempts.
 49
 50### False positive analysis
 51
 52- The `netsh.exe` utility can be used legitimately. Check whether the user should be performing this kind of activity, whether the user is aware of it, whether RDP should be open, and whether the action exposes the environment to unnecessary risks.
 53
 54### Response and remediation
 55
 56- Initiate the incident response process based on the outcome of the triage.
 57- If RDP is needed, make sure to secure it:
 58  - Allowlist RDP traffic to specific trusted hosts.
 59  - Restrict RDP logins to authorized non-administrator accounts, where possible.
 60- Isolate the involved hosts to prevent further post-compromise behavior.
 61- Review the privileges assigned to the involved users to ensure that the least privilege principle is being followed.
 62- Determine the initial vector abused by the attacker and take action to prevent reinfection through the same vector.
 63- 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).
 64"""
 65risk_score = 47
 66rule_id = "074464f9-f30d-4029-8c03-0ed237fffec7"
 67severity = "medium"
 68tags = [
 69    "Domain: Endpoint",
 70    "OS: Windows",
 71    "Use Case: Threat Detection",
 72    "Tactic: Defense Evasion",
 73    "Resources: Investigation Guide",
 74    "Data Source: Elastic Endgame",
 75    "Data Source: Elastic Defend",
 76    "Data Source: System",
 77    "Data Source: Microsoft Defender for Endpoint",
 78    "Data Source: Sysmon",
 79    "Data Source: SentinelOne",
 80]
 81timestamp_override = "event.ingested"
 82type = "eql"
 83
 84query = '''
 85process where host.os.type == "windows" and event.type == "start" and
 86 (process.name : "netsh.exe" or ?process.pe.original_file_name == "netsh.exe") and
 87 process.args : ("localport=3389", "RemoteDesktop", "group=\"remote desktop\"") and
 88 process.args : ("action=allow", "enable=Yes", "enable")
 89'''
 90
 91
 92[[rule.threat]]
 93framework = "MITRE ATT&CK"
 94[[rule.threat.technique]]
 95id = "T1562"
 96name = "Impair Defenses"
 97reference = "https://attack.mitre.org/techniques/T1562/"
 98[[rule.threat.technique.subtechnique]]
 99id = "T1562.004"
100name = "Disable or Modify System Firewall"
101reference = "https://attack.mitre.org/techniques/T1562/004/"
102
103
104
105[rule.threat.tactic]
106id = "TA0005"
107name = "Defense Evasion"
108reference = "https://attack.mitre.org/tactics/TA0005/"

Triage and analysis

Investigating Remote Desktop Enabled in Windows Firewall by Netsh

Microsoft Remote Desktop Protocol (RDP) is a proprietary Microsoft protocol that enables remote connections to other computers, typically over TCP port 3389.

Attackers can use RDP to conduct their actions interactively. Ransomware operators frequently use RDP to access victim servers, often using privileged accounts.

This rule detects the creation of a Windows Firewall inbound rule that would allow inbound RDP traffic using the netsh.exe utility.

Possible investigation steps

  • Identify the user account that performed the action and whether it should perform this kind of action.
  • Contact the user to check if they are aware of the operation.
  • 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.
  • Investigate other alerts associated with the user/host during the past 48 hours.
  • Check whether it makes sense to enable RDP to this host, given its role in the environment.
  • Check if the host is directly exposed to the internet.
  • Check whether privileged accounts accessed the host shortly after the modification.
  • Review network events within a short timespan of this alert for incoming RDP connection attempts.

False positive analysis

  • The netsh.exe utility can be used legitimately. Check whether the user should be performing this kind of activity, whether the user is aware of it, whether RDP should be open, and whether the action exposes the environment to unnecessary risks.

Response and remediation

  • Initiate the incident response process based on the outcome of the triage.
  • If RDP is needed, make sure to secure it:
    • Allowlist RDP traffic to specific trusted hosts.
    • Restrict RDP logins to authorized non-administrator accounts, where possible.
  • Isolate the involved hosts to prevent further post-compromise behavior.
  • Review the privileges assigned to the involved users to ensure that the least privilege principle is being followed.
  • 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).

Related rules

to-top