Detection rules › Elastic

Windows Service Configuration Hjack

Time window
3m
Source
github.com/elastic/protections-artifacts

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

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.

FieldKindExcluded valuesSearch
event0.registry.data.stringscontainsregistry.data.stringsexcludes:event0.registry.data.strings field:"event0.registry.data.strings" value:"registry.data.strings"

Indicators

These rows show field, operator, and value matches.

FieldKindValuesSearch
event.actioneq
  • modification corpus 72 (elastic 72)
  • start corpus 391 (elastic 391)
field:"EventType" kind:eq
event.categorywildcard
  • library corpus 22 (elastic 22)
  • process corpus 142 (elastic 142)
field:"event.category" kind:wildcard
event0.registry.data.stringscontains
  • dll.path (field reference)
  • process.name (field reference)
field:"event0.registry.data.strings" kind:contains
event0.registry.patheq
  • registry.path (field reference)
field:"event0.registry.path" kind:eq value:"registry.path"
process.namewildcard
  • services.exe corpus 7 (elastic 7)
field:"process_name" kind:wildcard value:"services.exe"
process.parent.namewildcard
  • services.exe corpus 12 (elastic 8, splunk 3, kusto 1)
field:"parent_process_name" kind:wildcard value:"services.exe"
registry.data.stringswildcard
  • ?* corpus 4 (elastic 4)
field:"Details" kind:wildcard value:"?*"
registry.pathwildcard
  • HKLM\SYSTEM\*ControlSet*\Services\*\ImagePath corpus 5 (elastic 5)
  • HKLM\SYSTEM\ControlSet*\Services\*\Parameters\ServiceDll
field:"TargetObject" kind:wildcard