Privilege Escalation via Windir Environment Variable

Identifies a privilege escalation attempt via a rogue Windows directory (Windir) environment variable. This is a known primitive that is often combined with other vulnerabilities to elevate privileges.

Elastic rule (View on GitHub)

 1[metadata]
 2creation_date = "2020/11/26"
 3integration = ["endpoint"]
 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 a privilege escalation attempt via a rogue Windows directory (Windir) environment variable. This is a known
13primitive that is often combined with other vulnerabilities to elevate privileges.
14"""
15from = "now-9m"
16index = ["logs-endpoint.events.registry-*", "endgame-*", "logs-windows.sysmon_operational-*"]
17language = "eql"
18license = "Elastic License v2"
19name = "Privilege Escalation via Windir Environment Variable"
20references = ["https://www.tiraniddo.dev/2017/05/exploiting-environment-variables-in.html"]
21risk_score = 73
22rule_id = "d563aaba-2e72-462b-8658-3e5ea22db3a6"
23severity = "high"
24tags = ["Domain: Endpoint", "OS: Windows", "Use Case: Threat Detection", "Tactic: Privilege Escalation", "Data Source: Elastic Endgame", "Data Source: Elastic Defend", "Data Source: Sysmon"]
25timestamp_override = "event.ingested"
26type = "eql"
27
28query = '''
29registry where host.os.type == "windows" and registry.path : (
30    "HKEY_USERS\\*\\Environment\\windir",
31    "HKEY_USERS\\*\\Environment\\systemroot",
32    "HKU\\*\\Environment\\windir",
33    "HKU\\*\\Environment\\systemroot",
34    "\\REGISTRY\\USER\\*\\Environment\\windir",
35    "\\REGISTRY\\USER\\*\\Environment\\systemroot"
36    ) and
37 not registry.data.strings : ("C:\\windows", "%SystemRoot%")
38'''
39
40
41[[rule.threat]]
42framework = "MITRE ATT&CK"
43[[rule.threat.technique]]
44id = "T1574"
45name = "Hijack Execution Flow"
46reference = "https://attack.mitre.org/techniques/T1574/"
47[[rule.threat.technique.subtechnique]]
48id = "T1574.007"
49name = "Path Interception by PATH Environment Variable"
50reference = "https://attack.mitre.org/techniques/T1574/007/"
51
52
53
54[rule.threat.tactic]
55id = "TA0004"
56name = "Privilege Escalation"
57reference = "https://attack.mitre.org/tactics/TA0004/"

References

Related rules

to-top