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"]
  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 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 = ["winlogbeat-*", "logs-endpoint.events.process-*", "logs-windows.*", "endgame-*", "logs-system.security*"]
 17language = "eql"
 18license = "Elastic License v2"
 19name = "Remote Desktop Enabled in Windows Firewall by Netsh"
 20note = """## Triage and analysis
 21
 22### Investigating Remote Desktop Enabled in Windows Firewall by Netsh
 23
 24Microsoft Remote Desktop Protocol (RDP) is a proprietary Microsoft protocol that enables remote connections to other computers, typically over TCP port 3389.
 25
 26Attackers can use RDP to conduct their actions interactively. Ransomware operators frequently use RDP to access victim servers, often using privileged accounts.
 27
 28This rule detects the creation of a Windows Firewall inbound rule that would allow inbound RDP traffic using the `netsh.exe` utility.
 29
 30#### Possible investigation steps
 31
 32- Identify the user account that performed the action and whether it should perform this kind of action.
 33- Contact the user to check if they are aware of the operation.
 34- 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.
 35- Investigate other alerts associated with the user/host during the past 48 hours.
 36- Check whether it makes sense to enable RDP to this host, given its role in the environment.
 37- Check if the host is directly exposed to the internet.
 38- Check whether privileged accounts accessed the host shortly after the modification.
 39- Review network events within a short timespan of this alert for incoming RDP connection attempts.
 40
 41### False positive analysis
 42
 43- 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.
 44
 45### Response and remediation
 46
 47- Initiate the incident response process based on the outcome of the triage.
 48- If RDP is needed, make sure to secure it:
 49  - Allowlist RDP traffic to specific trusted hosts.
 50  - Restrict RDP logins to authorized non-administrator accounts, where possible.
 51- Isolate the involved hosts to prevent further post-compromise behavior.
 52- Review the privileges assigned to the involved users to ensure that the least privilege principle is being followed.
 53- Determine the initial vector abused by the attacker and take action to prevent reinfection through the same vector.
 54- 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).
 55"""
 56risk_score = 47
 57rule_id = "074464f9-f30d-4029-8c03-0ed237fffec7"
 58setup = """## Setup
 59
 60If enabling an EQL rule on a non-elastic-agent index (such as beats) for versions <8.2,
 61events will not define `event.ingested` and default fallback for EQL rules was not added until version 8.2.
 62Hence for this rule to work effectively, users will need to add a custom ingest pipeline to populate
 63`event.ingested` to @timestamp.
 64For more details on adding a custom ingest pipeline refer - https://www.elastic.co/guide/en/fleet/current/data-streams-pipeline-tutorial.html
 65"""
 66severity = "medium"
 67tags = [
 68    "Domain: Endpoint",
 69    "OS: Windows",
 70    "Use Case: Threat Detection",
 71    "Tactic: Defense Evasion",
 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 (process.name : "netsh.exe" or ?process.pe.original_file_name == "netsh.exe") and
 82 process.args : ("localport=3389", "RemoteDesktop", "group=\"remote desktop\"") and
 83 process.args : ("action=allow", "enable=Yes", "enable")
 84'''
 85
 86
 87[[rule.threat]]
 88framework = "MITRE ATT&CK"
 89[[rule.threat.technique]]
 90id = "T1562"
 91name = "Impair Defenses"
 92reference = "https://attack.mitre.org/techniques/T1562/"
 93[[rule.threat.technique.subtechnique]]
 94id = "T1562.004"
 95name = "Disable or Modify System Firewall"
 96reference = "https://attack.mitre.org/techniques/T1562/004/"
 97
 98
 99
100[rule.threat.tactic]
101id = "TA0005"
102name = "Defense Evasion"
103reference = "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