Detection rules › Elastic
Office Application Startup via Template File Modification
Adversaries can modify default Microsoft Office templates in order to establish persistence using malicious Macro templates.
MITRE ATT&CK coverage
| Tactic | Techniques |
|---|---|
| Persistence |
Rule body
[rule]
description = """
Adversaries can modify default Microsoft Office templates in order to establish persistence using malicious Macro
templates.
"""
id = "608eae71-6797-4ded-bfaa-41bcb17a8498"
license = "Elastic License v2"
name = "Office Application Startup via Template File Modification"
os_list = ["windows"]
reference = ["https://attack.mitre.org/techniques/T1137/001/"]
version = "1.0.30"
query = '''
file where event.action in ("creation", "overwrite") and process.pid != 4 and
process.name != null and user.name != null and
file.path :
("C:\\Users\\*\\AppData\\Roaming\\Microsoft\\Templates\\Normal.dotm",
"C:\\Users\\*\\AppData\\Roaming\\Microsoft\\Excel\\XLSTART\\PERSONAL.XLSB") and file.size > 0 and
not process.thread.Ext.call_stack_summary in
("sysfer.dll|apphelp.dll|kernelbase.dll|migcore.dll|loadstate.exe|kernel32.dll|ntdll.dll",
"ntdll.dll|apphelp.dll|kernelbase.dll|migcore.dll|loadstate.exe|kernel32.dll|ntdll.dll") and
not process.executable : ("?:\\Windows\\System32\\svchost.exe",
"?:\\Windows\\explorer.exe",
"?:\\Program Files\\Citrix\\User Profile Manager\\UserProfileManager.exe",
"?:\\Program Files (x86)\\Citrix\\User Profile Manager\\UserProfileManager.exe",
"?:\\Program Files (x86)\\Ivanti\\Workspace Control\\pfwsmgr.exe",
"?:\\ProgramData\\ForensiT\\Transwiz\\Deployment Files\\Transwiz.exe",
"C:\\Program Files (x86)\\Windows Kits\\10\\Assessment and Deployment Kit\\User State Migration Tool\\amd64\\loadstate.exe",
"?:\\Windows\\Sys*\\xcopy.exe",
"?:\\Windows\\Sys*\\Robocopy.exe",
"?:\\Program Files\\Veeam\\Endpoint Backup\\*.exe",
"?:\\Program Files (x86)\\Laplink PCmover\\PCmoverHost.exe",
"?:\\Windows\\System32\\dllhost.exe",
"C:\\Windows\\System32\\cmd.exe",
"D:\\SuperGrate*.exe",
"\\Device\\Mup\\*.exe") and
not user.id in ("S-1-5-18", "S-1-5-19", "S-1-5-20")
'''
min_endpoint_version = "8.10.0"
[[actions]]
action = "kill_process"
field = "process.entity_id"
state = 0
[[optional_actions]]
action = "rollback"
field = "process.entity_id"
state = 0
[[threat]]
framework = "MITRE ATT&CK"
[[threat.technique]]
id = "T1137"
name = "Office Application Startup"
reference = "https://attack.mitre.org/techniques/T1137/"
[[threat.technique.subtechnique]]
id = "T1137.001"
name = "Office Template Macros"
reference = "https://attack.mitre.org/techniques/T1137/001/"
[threat.tactic]
id = "TA0003"
name = "Persistence"
reference = "https://attack.mitre.org/tactics/TA0003/"
[internal]
min_endpoint_version = "8.10.0"
Stages and Predicates
Stage 1: file
file where event.action in ("creation", "overwrite") and process.pid != 4 and
process.name != null and user.name != null and
file.path :
("C:\\Users\\*\\AppData\\Roaming\\Microsoft\\Templates\\Normal.dotm",
"C:\\Users\\*\\AppData\\Roaming\\Microsoft\\Excel\\XLSTART\\PERSONAL.XLSB") and file.size > 0 and
not process.thread.Ext.call_stack_summary in
("sysfer.dll|apphelp.dll|kernelbase.dll|migcore.dll|loadstate.exe|kernel32.dll|ntdll.dll",
"ntdll.dll|apphelp.dll|kernelbase.dll|migcore.dll|loadstate.exe|kernel32.dll|ntdll.dll") and
not process.executable : ("?:\\Windows\\System32\\svchost.exe",
"?:\\Windows\\explorer.exe",
"?:\\Program Files\\Citrix\\User Profile Manager\\UserProfileManager.exe",
"?:\\Program Files (x86)\\Citrix\\User Profile Manager\\UserProfileManager.exe",
"?:\\Program Files (x86)\\Ivanti\\Workspace Control\\pfwsmgr.exe",
"?:\\ProgramData\\ForensiT\\Transwiz\\Deployment Files\\Transwiz.exe",
"C:\\Program Files (x86)\\Windows Kits\\10\\Assessment and Deployment Kit\\User State Migration Tool\\amd64\\loadstate.exe",
"?:\\Windows\\Sys*\\xcopy.exe",
"?:\\Windows\\Sys*\\Robocopy.exe",
"?:\\Program Files\\Veeam\\Endpoint Backup\\*.exe",
"?:\\Program Files (x86)\\Laplink PCmover\\PCmoverHost.exe",
"?:\\Windows\\System32\\dllhost.exe",
"C:\\Windows\\System32\\cmd.exe",
"D:\\SuperGrate*.exe",
"\\Device\\Mup\\*.exe") and
not user.id in ("S-1-5-18", "S-1-5-19", "S-1-5-20")
Exclusions
The rule actively suppresses these predicates.
| Field | Kind | Excluded values | Search |
|---|---|---|---|
process.executable | wildcard | ?:\Windows\System32\svchost.exe, ?:\Windows\explorer.exe, ?:\Program Files\Citrix\User Profile Manager\UserProfileManager.exe, ?:\Program Files (x86)\Citrix\User Profile Manager\UserProfileManager.exe, ?:\Program Files (x86)\Ivanti\Workspace Control\pfwsmgr.exe, ?:\ProgramData\ForensiT\Transwiz\Deployment Files\Transwiz.exe, C:\Program Files (x86)\Windows Kits\10\Assessment and Deployment Kit\User State Migration Tool\amd64\loadstate.exe, ?:\Windows\Sys*\xcopy.exe, ?:\Windows\Sys*\Robocopy.exe, ?:\Program Files\Veeam\Endpoint Backup\*.exe, ?:\Program Files (x86)\Laplink PCmover\PCmoverHost.exe, ?:\Windows\System32\dllhost.exe, C:\Windows\System32\cmd.exe, D:\SuperGrate*.exe, \Device\Mup\*.exe | excludes:process.executable |
process.thread.Ext.call_stack_summary | in | ntdll.dll|apphelp.dll|kernelbase.dll|migcore.dll|loadstate.exe|kernel32.dll|ntdll.dll, sysfer.dll|apphelp.dll|kernelbase.dll|migcore.dll|loadstate.exe|kernel32.dll|ntdll.dll | excludes:process.thread.Ext.call_stack_summary field:"process.thread.Ext.call_stack_summary" value:"ntdll.dll|apphelp.dll|kernelbase.dll|migcore.dll|loadstate.exe|kernel32.dll|ntdll.dll" field:"process.thread.Ext.call_stack_summary" value:"sysfer.dll|apphelp.dll|kernelbase.dll|migcore.dll|loadstate.exe|kernel32.dll|ntdll.dll" |
user.id | in | S-1-5-18, S-1-5-19, S-1-5-20 | excludes:user.id field:"user.id" value:"S-1-5-18" field:"user.id" value:"S-1-5-19" field:"user.id" value:"S-1-5-20" |
Indicators
These rows show field, operator, and value matches.
| Field | Kind | Values | Search |
|---|---|---|---|
event.action | in |
| field:"EventType" kind:in |
file.path | wildcard |
| field:"TargetFilename" kind:wildcard |
file.size | gt |
| field:"file.size" kind:gt value:"0" |
process.name | is_not_null | field:"process_name" kind:is_not_null | |
process.pid | ne |
| field:"process_id" kind:ne value:"4" |
user.name | is_not_null | field:"user" kind:is_not_null |