Detection rules › Elastic
Privilege Escalation via Windir or SystemRoot Environment Variable
Identifies a privilege escalation attempt via a rogue Windows directory (Windir) or System Root environment variable. This is a known primitive that is often combined with other vulnerabilities to elevate privileges.
MITRE ATT&CK coverage
Rule body
[rule]
description = """
Identifies a privilege escalation attempt via a rogue Windows directory (Windir) or System Root environment variable.
This is a known primitive that is often combined with other vulnerabilities to elevate privileges.
"""
id = "18ffee0c-5f40-4dd8-aa9a-28251a308dbc"
license = "Elastic License v2"
name = "Privilege Escalation via Windir or SystemRoot Environment Variable"
os_list = ["windows"]
reference = ["https://www.tiraniddo.dev/2017/05/exploiting-environment-variables-in.html"]
version = "1.0.33"
query = '''
registry where registry.data.strings != null and
not user.id : "S-1-5-18" and
registry.path : ("HKEY_USERS\\*\\windir", "HKEY_USERS\\*\\systemroot") and
not registry.data.strings : ("?:\\windows", "?SystemRoot?") and
not registry.path : "HKEY_USERS\\*\\SOFTWARE\\*"
'''
min_endpoint_version = "7.15.0"
[[actions]]
action = "kill_process"
field = "process.entity_id"
state = 0
[[optional_actions]]
action = "rollback"
field = "process.entity_id"
state = 0
[[threat]]
framework = "MITRE ATT&CK"
[[threat.technique]]
id = "T1574"
name = "Hijack Execution Flow"
reference = "https://attack.mitre.org/techniques/T1574/"
[[threat.technique.subtechnique]]
id = "T1574.007"
name = "Path Interception by PATH Environment Variable"
reference = "https://attack.mitre.org/techniques/T1574/007/"
[threat.tactic]
id = "TA0004"
name = "Privilege Escalation"
reference = "https://attack.mitre.org/tactics/TA0004/"
[internal]
min_endpoint_version = "7.15.0"
Stages and Predicates
Stage 1: registry
registry where registry.data.strings != null and
not user.id : "S-1-5-18" and
registry.path : ("HKEY_USERS\\*\\windir", "HKEY_USERS\\*\\systemroot") and
not registry.data.strings : ("?:\\windows", "?SystemRoot?") and
not registry.path : "HKEY_USERS\\*\\SOFTWARE\\*"
Exclusions
The rule actively suppresses these predicates.
| Field | Kind | Excluded values | Search |
|---|---|---|---|
registry.data.strings | eq | ?:\windows, ?SystemRoot? | excludes:registry.data.strings field:"registry.data.strings" value:"?:\windows" field:"registry.data.strings" value:"?SystemRoot?" |
registry.path | wildcard | HKEY_USERS\*\SOFTWARE\* | excludes:registry.path field:"registry.path" value:"HKEY_USERS\*\SOFTWARE\*" |
user.id | eq | S-1-5-18 | excludes:user.id field:"user.id" value:"S-1-5-18" |
Indicators
These rows show field, operator, and value matches.
| Field | Kind | Values | Search |
|---|---|---|---|
registry.data.strings | is_not_null | field:"Details" kind:is_not_null | |
registry.path | wildcard |
| field:"TargetObject" kind:wildcard |