Detection rules › YARA-L
RDP Sensitive Settings Changed
Detects tampering of RDP Terminal Service/Server sensitive settings. Such as allowing unauthorized users access to a system via the 'fAllowUnsolicited' or enabling RDP via 'fDenyTSConnections'...etc
Known false positives
- Some of the keys mentioned here could be modified by an administrator while setting group policy
MITRE ATT&CK coverage
| Tactic | Techniques |
|---|---|
| Persistence | |
| Defense Impairment |
References
Telemetry coverage
| Provider | Record / event type |
|---|---|
| Sysmon | Event ID 13: RegistryEvent (Value Set) |
| Security-Auditing | Event ID 4657: A registry value was modified. |
Rule body
// Copyright 2025 Google LLC. Licensed under Apache-2.0.
rule rdp_sensitive_settings_changed {
meta:
author = "Samir Bousseaden, David ANDRE, Roberto Rodriguez @Cyb3rWard0g, Nasreddine Bencherchali"
description = "Detects tampering of RDP Terminal Service/Server sensitive settings. Such as allowing unauthorized users access to a system via the 'fAllowUnsolicited' or enabling RDP via 'fDenyTSConnections'...etc"
reference = "https://github.com/SigmaHQ/sigma/blob/master/rules/windows/registry/registry_set/registry_set_terminal_server_tampering.yml"
license = "https://github.com/SigmaHQ/Detection-Rule-License/blob/main/LICENSE.Detection.Rules.md"
rule_name = "RDP Sensitive Settings Changed"
rule_id = "mr_4c75375c-7ebf-4f9f-9b30-7aaab63dba8d"
sigma_uuid = "3f6b7b62-61aa-45db-96bd-9c31b36b653c"
sigma_status = "test"
tactic = "TA0005"
//tactic = "TA0003"
technique = "T1112"
type = "Detection"
data_source = "Windows Registry"
platform = "Windows"
severity = "High"
priority = "High"
false_positives = "Some of the keys mentioned here could be modified by an administrator while setting group policy"
events:
$reg.metadata.event_type = "REGISTRY_MODIFICATION"
(
(
(
strings.contains(strings.to_lower($reg.target.registry.registry_key), "\\control\\terminal server\\") or
strings.contains(strings.to_lower($reg.target.registry.registry_key), "\\windows nt\\terminal services\\")
) and
re.regex($reg.target.registry.registry_key, `\\Shadow$`) nocase and
(
$reg.target.registry.registry_value_data = "DWORD (0x00000001)" nocase or
$reg.target.registry.registry_value_data = "DWORD (0x00000002)" nocase or
$reg.target.registry.registry_value_data = "DWORD (0x00000003)" nocase or
$reg.target.registry.registry_value_data = "DWORD (0x00000004)" nocase
)
)
or
(
(
strings.contains(strings.to_lower($reg.target.registry.registry_key), "\\control\\terminal server\\") or
strings.contains(strings.to_lower($reg.target.registry.registry_key), "\\windows nt\\terminal services\\")
) and
(
re.regex($reg.target.registry.registry_key, `\\DisableRemoteDesktopAntiAlias$`) nocase or
re.regex($reg.target.registry.registry_key, `\\DisableSecuritySettings$`) nocase or
re.regex($reg.target.registry.registry_key, `\\fAllowUnsolicited$`) nocase or
re.regex($reg.target.registry.registry_key, `\\fAllowUnsolicitedFullControl$`) nocase
) and
$reg.target.registry.registry_value_data = "DWORD (0x00000001)" nocase
)
or
(
strings.contains(strings.to_lower($reg.target.registry.registry_key), "\\control\\terminal server\\initialprogram") or
strings.contains(strings.to_lower($reg.target.registry.registry_key), "\\control\\terminal server\\winstations\\rdp-tcp\\initialprogram") or
strings.contains(strings.to_lower($reg.target.registry.registry_key), "\\services\\termservice\\parameters\\servicedll") or
strings.contains(strings.to_lower($reg.target.registry.registry_key), "\\windows nt\\terminal services\\initialprogram")
)
)
$reg.principal.hostname = $hostname
match:
$hostname over 5m
outcome:
//example usage of specifying test user and hostname to adjust risk score
$risk_score = max(if($reg.principal.user.userid = "user" and $reg.principal.hostname = "hostname", 0, 15))
$principal_hostname = array_distinct($reg.principal.hostname)
$principal_process_pid = array_distinct($reg.principal.process.pid)
$principal_process_file_full_path = array_distinct($reg.principal.process.file.full_path)
$principal_process_product_specific_process_id = array_distinct($reg.principal.process.product_specific_process_id)
$principal_user_userid = array_distinct($reg.principal.user.userid)
$target_registry_key = array_distinct($reg.target.registry.registry_key)
$target_registry_value_data = array_distinct($reg.target.registry.registry_value_data)
$log_type = array_distinct(strings.concat($reg.metadata.log_type,"/",$reg.metadata.product_event_type))
condition:
$reg
}
YARA-L rule structure
Condition
Fires when at least one $reg event in the 5m window.
Events
$reg
target.registry.registry_key contains "\\control\\terminal server\\"target.registry.registry_key contains "\\windows nt\\terminal services\\"target.registry.registry_key matches "\\Shadow$"target.registry.registry_value_datais one of:DWORD (0x00000001)DWORD (0x00000002)DWORD (0x00000003)DWORD (0x00000004)
target.registry.registry_key contains "\\control\\terminal server\\"target.registry.registry_key contains "\\windows nt\\terminal services\\"target.registry.registry_key matches "\\DisableRemoteDesktopAntiAlias$"target.registry.registry_key matches "\\DisableSecuritySettings$"target.registry.registry_key matches "\\fAllowUnsolicited$"target.registry.registry_key matches "\\fAllowUnsolicitedFullControl$"target.registry.registry_value_data = "DWORD (0x00000001)"target.registry.registry_key contains "\\control\\terminal server\\initialprogram"target.registry.registry_key contains "\\control\\terminal server\\winstations\\rdp-tcp\\initialprogram"target.registry.registry_key contains "\\services\\termservice\\parameters\\servicedll"target.registry.registry_key contains "\\windows nt\\terminal services\\initialprogram"
Match and correlation
Outcome
Outcome variables add context to a detection. When the rule generates an alert, $risk_score is displayed with it.
| Field | Expression |
|---|---|
risk_score | max(if($reg.principal.user.userid = "user" and $reg.principal.hostname = "hostname", 0, 15)) |
principal_hostname | array_distinct($reg.principal.hostname) |
principal_process_pid | array_distinct($reg.principal.process.pid) |
principal_process_file_full_path | array_distinct($reg.principal.process.file.full_path) |
principal_process_product_specific_process_id | array_distinct($reg.principal.process.product_specific_process_id) |
principal_user_userid | array_distinct($reg.principal.user.userid) |
target_registry_key | array_distinct($reg.target.registry.registry_key) |
target_registry_value_data | array_distinct($reg.target.registry.registry_value_data) |
log_type | array_distinct(strings.concat($reg.metadata.log_type,"/",$reg.metadata.product_event_type)) |