Detection rules › Elastic
Potential Privilege Escalation via SetWindowsHook DLL Injection
Identifies a potentially untrusted DLL loaded by a privileged account from a suspicious location where the call stack indicates a user-mode callback path consistent with SetWindowsHookEx-style window hook execution. Adversaries can abuse window hooks to force a privileged process to load attacker-controlled DLLs and elevate privileges.
MITRE ATT&CK coverage
| Tactic | Techniques |
|---|---|
| Privilege Escalation |
Rule body
[rule]
description = """
Identifies a potentially untrusted DLL loaded by a privileged account from a suspicious location where the call stack
indicates a user-mode callback path consistent with SetWindowsHookEx-style window hook execution. Adversaries can abuse
window hooks to force a privileged process to load attacker-controlled DLLs and elevate privileges.
"""
id = "6eec7771-953c-46a0-9765-93000de1c237"
license = "Elastic License v2"
name = "Potential Privilege Escalation via SetWindowsHook DLL Injection"
os_list = ["windows"]
reference = [
"https://attack.mitre.org/techniques/T1055/001/",
"https://learn.microsoft.com/en-us/windows/win32/api/winuser/nf-winuser-setwindowshookexa",
]
version = "1.0.1"
query = '''
library where
user.id in ("S-1-5-18", "S-1-5-19", "S-1-5-20") and
not dll.code_signature.status like ("trusted", "errorCode_endpoint*") and
process.thread.Ext.call_stack_summary == "ntdll.dll|kernelbase.dll|user32.dll|ntdll.dll" and
(dll.Ext.relative_file_creation_time <= 900 or dll.Ext.relative_file_name_modify_time <= 900) and
_arraysearch(process.thread.Ext.call_stack, $entry, $entry.symbol_info like "?:\\Windows\\System32\\ntdll.dll!KiUserCallbackDispatcher*") and
not dll.path : ("?:\\Program Files\\*", "?:\\Program Files (x86)\\*", "?:\\Windows\\System32\\*")
'''
min_endpoint_version = "8.12.0"
optional_actions = []
[[actions]]
action = "kill_process"
field = "process.entity_id"
state = 0
tree = true
[[threat]]
framework = "MITRE ATT&CK"
[[threat.technique]]
id = "T1055"
name = "Process Injection"
reference = "https://attack.mitre.org/techniques/T1055/"
[[threat.technique.subtechnique]]
id = "T1055.001"
name = "Dynamic-link Library Injection"
reference = "https://attack.mitre.org/techniques/T1055/001/"
[threat.tactic]
id = "TA0004"
name = "Privilege Escalation"
reference = "https://attack.mitre.org/tactics/TA0004/"
[internal]
min_endpoint_version = "8.12.0"
Stages and Predicates
Stage 1: library
library where
user.id in ("S-1-5-18", "S-1-5-19", "S-1-5-20") and
not dll.code_signature.status like ("trusted", "errorCode_endpoint*") and
process.thread.Ext.call_stack_summary == "ntdll.dll|kernelbase.dll|user32.dll|ntdll.dll" and
(dll.Ext.relative_file_creation_time <= 900 or dll.Ext.relative_file_name_modify_time <= 900) and
_arraysearch(process.thread.Ext.call_stack, $entry, $entry.symbol_info like "?:\\Windows\\System32\\ntdll.dll!KiUserCallbackDispatcher*") and
not dll.path : ("?:\\Program Files\\*", "?:\\Program Files (x86)\\*", "?:\\Windows\\System32\\*")
Exclusions
The rule actively suppresses these predicates.
| Field | Kind | Excluded values | Search |
|---|---|---|---|
dll.code_signature.status | wildcard | trusted, errorCode_endpoint* | excludes:dll.code_signature.status field:"dll.code_signature.status" value:"trusted" field:"dll.code_signature.status" value:"errorCode_endpoint*" |
dll.path | starts_with | ?:\Program Files\, ?:\Program Files (x86)\, ?:\Windows\System32\ | excludes:dll.path field:"dll.path" value:"?:\Program Files\" field:"dll.path" value:"?:\Program Files (x86)\" field:"dll.path" value:"?:\Windows\System32\" |
Indicators
These rows show field, operator, and value matches.
| Field | Kind | Values | Search |
|---|---|---|---|
dll.Ext.relative_file_creation_time | le |
| field:"dll.Ext.relative_file_creation_time" kind:le value:"900" |
dll.Ext.relative_file_name_modify_time | le |
| field:"dll.Ext.relative_file_name_modify_time" kind:le value:"900" |
process.thread.Ext.call_stack_summary | eq |
| field:"process.thread.Ext.call_stack_summary" kind:eq value:"ntdll.dll|kernelbase.dll|user32.dll|ntdll.dll" |
user.id | in |
| field:"user.id" kind:in |