Detection rules › Elastic

Privilege Escalation via Windir or SystemRoot Environment Variable

Source
github.com/elastic/protections-artifacts

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.

Indicators

These rows show field, operator, and value matches.

FieldKindValuesSearch
registry.data.stringsis_not_null
  • (no value, null check)
field:"Details" kind:is_not_null
registry.pathwildcard
  • HKEY_USERS\*\systemroot
  • HKEY_USERS\*\windir
field:"TargetObject" kind:wildcard