T1137.001

Office Template Macros

Adversaries abuse Microsoft Office templates (Normal.dotm for Word, PERSONAL.XLSB for Excel) to obtain persistence. Malicious VBA macros inserted into base templates execute every time the Office application starts. Adversaries may also hijack the GlobalDotName registry key to point Word to an arbitrary template location, enabling stealth persistence that fires on every Word launch.

Microsoft Sentinel / Defender
kusto
// T1137.001 — Office Template Macros persistence detection
// Detect writes to Office template files and GlobalDotName registry modification
let OfficeMacroTemplates = dynamic([
  "Normal.dotm", "PERSONAL.XLSB", "NormalEmail.dotm"
]);
let TemplateStartupPaths = dynamic([
  "\\AppData\\Roaming\\Microsoft\\Templates\\",
  "\\AppData\\Roaming\\Microsoft\\Excel\\XLSTART\\",
  "\\AppData\\Roaming\\Microsoft\\Word\\STARTUP\\",
  "\\Program Files (x86)\\Microsoft Office\\root\\"
]);
// Part 1: Detect writes to Office template files
let TemplateFileWrites = DeviceFileEvents
| where Timestamp > ago(24h)
| where ActionType in ("FileCreated", "FileModified")
| where FileName has_any (OfficeMacroTemplates) or FolderPath has_any (TemplateStartupPaths)
| where InitiatingProcessFileName !in~ ("winword.exe", "excel.exe", "powerpnt.exe", "outlook.exe", "MicrosoftEdgeUpdate.exe", "OfficeClickToRun.exe")
| project Timestamp, DeviceName, AccountName, FileName, FolderPath,
         InitiatingProcessFileName, InitiatingProcessCommandLine, ActionType;
// Part 2: Detect GlobalDotName registry key modification
let GlobalDotNameReg = DeviceRegistryEvents
| where Timestamp > ago(24h)
| where RegistryKey has_all ("Microsoft", "Word")
| where RegistryValueName =~ "GlobalDotName" or RegistryKey has "GlobalDotName"
| project Timestamp, DeviceName, AccountName, RegistryKey, RegistryValueName, RegistryValueData,
         InitiatingProcessFileName, InitiatingProcessCommandLine, ActionType;
// Part 3: Detect Office apps spawning unexpected child processes (macro execution)
let OfficeMacroExec = DeviceProcessEvents
| where Timestamp > ago(24h)
| where InitiatingProcessFileName in~ ("winword.exe", "excel.exe", "powerpnt.exe")
| where FileName !in~ ("winword.exe", "excel.exe", "powerpnt.exe", "MSOSYNC.exe", "splwow64.exe", "WerFault.exe", "csc.exe", "vbc.exe")
| where FileName in~ ("cmd.exe", "powershell.exe", "wscript.exe", "cscript.exe", "mshta.exe", "rundll32.exe", "regsvr32.exe", "certutil.exe", "bitsadmin.exe", "msiexec.exe")
| project Timestamp, DeviceName, AccountName, FileName, ProcessCommandLine,
         InitiatingProcessFileName, InitiatingProcessCommandLine;
union TemplateFileWrites, GlobalDotNameReg, OfficeMacroExec
| sort by Timestamp desc
high severity high confidence

Data Sources

File: File Creation File: File Modification Windows Registry: Registry Value Modification Process: Process Creation Microsoft Defender for Endpoint

Required Tables

DeviceFileEvents DeviceRegistryEvents DeviceProcessEvents

False Positives

  • Legitimate IT automation tools (PDQ Deploy, SCCM) distributing updated Office templates to endpoints
  • User-created macros in Personal.xlsb for legitimate automation of repetitive Excel tasks
  • Office add-in installations that create or modify startup folder files as part of normal installation
  • Helpdesk/support personnel modifying Normal.dotm to deploy standardized corporate templates

Unlock Pro Content

Get the full detection package for T1137.001 including response playbook, investigation guide, and atomic red team tests.

Response PlaybookInvestigation GuideHunting QueriesAtomic Red Team TestsTuning Guidance

Related Detections