Detection rules › Elastic

Office Application Startup via Template File Modification

Source
github.com/elastic/protections-artifacts

Adversaries can modify default Microsoft Office templates in order to establish persistence using malicious Macro templates.

MITRE ATT&CK coverage

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.

FieldKindExcluded valuesSearch
process.executablewildcard?:\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\*.exeexcludes:process.executable
process.thread.Ext.call_stack_summaryinntdll.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.dllexcludes: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.idinS-1-5-18, S-1-5-19, S-1-5-20excludes: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.

FieldKindValuesSearch
event.actionin
  • creation corpus 58 (elastic 58)
  • overwrite corpus 8 (elastic 8)
field:"EventType" kind:in
file.pathwildcard
  • C:\Users\*\AppData\Roaming\Microsoft\Excel\XLSTART\PERSONAL.XLSB
  • C:\Users\*\AppData\Roaming\Microsoft\Templates\Normal.dotm
field:"TargetFilename" kind:wildcard
file.sizegt
  • 0 transforms: number corpus 3 (elastic 3)
field:"file.size" kind:gt value:"0"
process.nameis_not_null
  • (no value, null check)
field:"process_name" kind:is_not_null
process.pidne
  • 4 transforms: number corpus 44 (elastic 44)
field:"process_id" kind:ne value:"4"
user.nameis_not_null
  • (no value, null check)
field:"user" kind:is_not_null