Detection rules › Elastic
Windows Service Configuration Hjack
Identifies suspicious modification of a Windows service configuration using RPC. Adversaries may use this technique to maintain persistence or run with System privileges avoiding logging related to service creation.
MITRE ATT&CK coverage
| Tactic | Techniques |
|---|---|
| Persistence |
Rule body
[rule]
description = """
Identifies suspicious modification of a Windows service configuration using RPC. Adversaries may use this technique to
maintain persistence or run with System privileges avoiding logging related to service creation.
"""
id = "4a964318-31be-46de-9bc6-fde362e37c60"
license = "Elastic License v2"
name = "Windows Service Configuration Hjack"
os_list = ["windows"]
version = "1.0.4"
query = '''
sequence with maxspan=3m
[registry where event.action == "modification" and process.name : "services.exe" and
registry.path : ("HKLM\\SYSTEM\\*ControlSet*\\Services\\*\\ImagePath", "HKLM\\SYSTEM\\ControlSet*\\Services\\*\\Parameters\\ServiceDll")] as event0
[any where
(event.category : "library" and not dll.code_signature.status : "trusted" and stringcontains~(event0.registry.data.strings, dll.path)) or
(event.category : "process" and event.action == "start" and process.parent.name : "services.exe" and stringcontains~(event0.registry.data.strings, process.name))]
[registry where event.action == "modification" and process.name : "services.exe" and
registry.path : ("HKLM\\SYSTEM\\*ControlSet*\\Services\\*\\ImagePath", "HKLM\\SYSTEM\\ControlSet*\\Services\\*\\Parameters\\ServiceDll") and
event0.registry.path == registry.path and registry.data.strings : "?*" and
not stringcontains~(event0.registry.data.strings, registry.data.strings)]
'''
min_endpoint_version = "8.4.0"
[[actions]]
action = "kill_process"
field = "process.entity_id"
state = 1
[[optional_actions]]
action = "rollback"
field = "process.entity_id"
state = 0
[[threat]]
framework = "MITRE ATT&CK"
[[threat.technique]]
id = "T1543"
name = "Create or Modify System Process"
reference = "https://attack.mitre.org/techniques/T1543/"
[[threat.technique.subtechnique]]
id = "T1543.003"
name = "Windows Service"
reference = "https://attack.mitre.org/techniques/T1543/003/"
[threat.tactic]
id = "TA0003"
name = "Persistence"
reference = "https://attack.mitre.org/tactics/TA0003/"
[internal]
min_endpoint_version = "8.4.0"
Stages and Predicates
Stage 1: registry
[registry where event.action == "modification" and process.name : "services.exe" and
registry.path : ("HKLM\\SYSTEM\\*ControlSet*\\Services\\*\\ImagePath", "HKLM\\SYSTEM\\ControlSet*\\Services\\*\\Parameters\\ServiceDll")] as event0
Stage 2: any
[any where
(event.category : "library" and not dll.code_signature.status : "trusted" and stringcontains~(event0.registry.data.strings, dll.path)) or
(event.category : "process" and event.action == "start" and process.parent.name : "services.exe" and stringcontains~(event0.registry.data.strings, process.name))]
Stage 3: registry
[registry where event.action == "modification" and process.name : "services.exe" and
registry.path : ("HKLM\\SYSTEM\\*ControlSet*\\Services\\*\\ImagePath", "HKLM\\SYSTEM\\ControlSet*\\Services\\*\\Parameters\\ServiceDll") and
event0.registry.path == registry.path and registry.data.strings : "?*" and
not stringcontains~(event0.registry.data.strings, registry.data.strings)]
Exclusions
The rule actively suppresses these predicates.
| Field | Kind | Excluded values | Search |
|---|---|---|---|
event0.registry.data.strings | contains | registry.data.strings | excludes:event0.registry.data.strings field:"event0.registry.data.strings" value:"registry.data.strings" |
Indicators
These rows show field, operator, and value matches.
| Field | Kind | Values | Search |
|---|---|---|---|
event.action | eq |
| field:"EventType" kind:eq |
event.category | wildcard |
| field:"event.category" kind:wildcard |
event0.registry.data.strings | contains |
| field:"event0.registry.data.strings" kind:contains |
event0.registry.path | eq |
| field:"event0.registry.path" kind:eq value:"registry.path" |
process.name | wildcard |
| field:"process_name" kind:wildcard value:"services.exe" |
process.parent.name | wildcard |
| field:"parent_process_name" kind:wildcard value:"services.exe" |
registry.data.strings | wildcard |
| field:"Details" kind:wildcard value:"?*" |
registry.path | wildcard |
| field:"TargetObject" kind:wildcard |