Detection rules › YARA-L
Session Manager Autorun Keys Modification
Detects modification of autostart extensibility point (ASEP) in registry
Known false positives
- Legitimate software automatically sets up autorun keys for legitimate reason
MITRE ATT&CK coverage
| Tactic | Techniques |
|---|---|
| Persistence |
References
Telemetry coverage
| Provider | Record / event type |
|---|---|
| Sysmon | Event ID 13: RegistryEvent (Value Set) |
| Security-Auditing | Event ID 4657: A registry value was modified. |
Rule body
// Copyright 2025 Google LLC. Licensed under Apache-2.0.
rule session_manager_autorun_keys_modification {
meta:
author = "Victor Sergeev, Daniil Yugoslavskiy, Gleb Sukhodolskiy, Timur Zinniatullin, oscd.community, Tim Shelton, frack113 (split)"
description = "Detects modification of autostart extensibility point (ASEP) in registry"
reference = "https://github.com/SigmaHQ/sigma/blob/master/rules/windows/registry/registry_set/registry_set_asep_reg_keys_modification_session_manager.yml"
license = "https://github.com/SigmaHQ/Detection-Rule-License/blob/main/LICENSE.Detection.Rules.md"
rule_name = "Session Manager Autorun Keys Modification"
rule_id = "mr_4ec3053f-3617-4262-93ae-838dc542610c"
sigma_uuid = "046218bd-e0d8-4113-a3c3-895a12b2b298"
sigma_status = "test"
tactic = "TA0003"
//tactic = "TA0004"
technique = "T1547.001"
//technique = "T1546.009"
type = "Detection"
data_source = "Sysmon"
platform = "Windows"
severity = "Medium"
priority = "Medium"
false_positives = "Legitimate software automatically sets up autorun keys for legitimate reason"
events:
$reg.metadata.event_type = "REGISTRY_MODIFICATION"
strings.contains(strings.to_lower($reg.target.registry.registry_key), "system\\currentcontrolset\\control\\session manager")
(
strings.contains(strings.to_lower($reg.target.registry.registry_key), "\\setupexecute") or
strings.contains(strings.to_lower($reg.target.registry.registry_key), "\\s0initialcommand") or
strings.contains(strings.to_lower($reg.target.registry.registry_key), "\\knowndlls") or
strings.contains(strings.to_lower($reg.target.registry.registry_key), "\\execute") or
strings.contains(strings.to_lower($reg.target.registry.registry_key), "\\bootexecute") or
strings.contains(strings.to_lower($reg.target.registry.registry_key), "\\appcertdlls")
)
NOT $reg.target.registry.registry_value_data = "(Empty)" nocase
$reg.principal.hostname = $hostname
match:
$hostname over 5m
outcome:
//example usage of specifying test user and hostname to adjust risk score
$risk_score = max(if($reg.principal.user.userid = "user" and $reg.principal.hostname = "hostname", 0, 15))
$principal_hostname = array_distinct($reg.principal.hostname)
$principal_process_pid = array_distinct($reg.principal.process.pid)
$principal_process_file_full_path = array_distinct($reg.principal.process.file.full_path)
$principal_process_product_specific_process_id = array_distinct($reg.principal.process.product_specific_process_id)
$principal_user_userid = array_distinct($reg.principal.user.userid)
$target_registry_key = array_distinct($reg.target.registry.registry_key)
$target_registry_value_data = array_distinct($reg.target.registry.registry_value_data)
$log_type = array_distinct(strings.concat($reg.metadata.log_type,"/",$reg.metadata.product_event_type))
condition:
$reg
}
YARA-L rule structure
Condition
Fires when at least one $reg event in the 5m window.
Events
$reg
target.registry.registry_key contains "system\\currentcontrolset\\control\\session manager"target.registry.registry_key contains "\\setupexecute"target.registry.registry_key contains "\\s0initialcommand"target.registry.registry_key contains "\\knowndlls"target.registry.registry_key contains "\\execute"target.registry.registry_key contains "\\bootexecute"target.registry.registry_key contains "\\appcertdlls"target.registry.registry_value_data = "(Empty)"
Match and correlation
Outcome
Outcome variables add context to a detection. When the rule generates an alert, $risk_score is displayed with it.
| Field | Expression |
|---|---|
risk_score | max(if($reg.principal.user.userid = "user" and $reg.principal.hostname = "hostname", 0, 15)) |
principal_hostname | array_distinct($reg.principal.hostname) |
principal_process_pid | array_distinct($reg.principal.process.pid) |
principal_process_file_full_path | array_distinct($reg.principal.process.file.full_path) |
principal_process_product_specific_process_id | array_distinct($reg.principal.process.product_specific_process_id) |
principal_user_userid | array_distinct($reg.principal.user.userid) |
target_registry_key | array_distinct($reg.target.registry.registry_key) |
target_registry_value_data | array_distinct($reg.target.registry.registry_value_data) |
log_type | array_distinct(strings.concat($reg.metadata.log_type,"/",$reg.metadata.product_event_type)) |