T1221 Sumo Logic CSE · Sumo

Detect Template Injection in Sumo Logic CSE

Adversaries abuse template references embedded in Office Open XML (OOXML) documents and RTF files to conceal and deliver malicious payloads. DOCX, XLSX, and PPTX files are ZIP archives containing an XML relationship file (word/_rels/document.xml.rels) that can reference an external template URL via an attachedTemplate relationship. When the document is opened, the Office application fetches the remote template, which may deliver VBA macros, exploits, or shellcode that are absent from the original lure document — bypassing static file analysis. RTF files can be modified to include a \*\template control word pointing to a remote URL, triggering a fetch on open. Both vectors are used to deliver malicious macros (APT28 remote template macro delivery), execute exploits (Confucius, WarzoneRAT via RTF exploit embedding), or capture NTLM credentials by injecting SMB UNC paths that trigger forced authentication (Dragonfly, DarkHydrus/Phishery). Real-world campaigns frequently deliver these lures via phishing (T1566) or tainted shared content (T1080). The technique is effective because the initial document contains no traditional indicators — no embedded VBA, no OLE streams, no scripts — making gateway scanning and sandboxes that do not perform dynamic network fetching ineffective.

MITRE ATT&CK

Tactic
Defense Evasion
Technique
T1221 Template Injection
Canonical reference
https://attack.mitre.org/techniques/T1221/

Sumo Detection Query

Sumo Logic CSE (Sumo)
sql
(_sourceCategory=windows/sysmon OR _sourceCategory=os/windows/sysmon)
| where EventID in ("1", "3")
| where
    (EventID = "3" AND Image matches /(?i).*(winword|excel|powerpnt|mspub|msaccess|visio)\.exe/)
    OR
    (EventID = "1" AND ParentImage matches /(?i).*(winword|excel|powerpnt|mspub|msaccess|visio)\.exe/)
| eval IsForcedAuth = if(EventID = "3" AND DestinationPort = "445", 1, 0)
| eval IsRemoteFetch = if(EventID = "3" AND DestinationPort in ("80","443","8080","8443"), 1, 0)
| eval IsChildExec = if(
    EventID = "1"
    AND matches(Image, "(?i).*(cmd|powershell|pwsh|wscript|cscript|mshta|rundll32|regsvr32|certutil|bitsadmin|wmic|msiexec)\\.exe"),
    1, 0)
| eval IsMicrosoftInfra = if(
    IsRemoteFetch = 1
    AND matches(DestinationHostname,
      "(?i).*(microsoft\\.com|office\\.com|live\\.com|microsoftonline\\.com|windows\\.net|sharepoint\\.com|officecdn\\.microsoft\\.com|officecdna\\.microsoft\\.com|azure\\.com|azurefd\\.net|bing\\.com|msecnd\\.net|skype\\.com|trafficmanager\\.net|msftncsi\\.com)"),
    1, 0)
| where NOT (IsRemoteFetch = 1 AND IsMicrosoftInfra = 1)
| where IsForcedAuth = 1 OR IsRemoteFetch = 1 OR IsChildExec = 1
| eval AlertType = if(IsForcedAuth = 1, "ForcedAuthSMB_NTLMCapture",
    if(IsRemoteFetch = 1, "RemoteTemplateFetch",
      if(IsChildExec = 1, "OfficeChildProcess_PostTemplateExec", "Unknown")))
| eval OfficeProcess = if(EventID = "3", Image, ParentImage)
| eval TargetOrChild = if(EventID = "3", DestinationHostname, Image)
| eval RiskScore = if(IsForcedAuth = 1, 90, if(IsRemoteFetch = 1, 60, 75))
| table _messageTime, Computer, User, EventID, AlertType, OfficeProcess,
    TargetOrChild, DestinationIp, DestinationPort, DestinationHostname,
    CommandLine, ParentImage, ParentCommandLine, RiskScore
| sort by RiskScore desc, _messageTime desc
high severity high confidence

Sumo Logic detection for T1221 Template Injection querying Windows Sysmon logs (EventID 3 network connections and EventID 1 process creation events) from the windows/sysmon source category. Mirrors the three-branch SPL detection: Office applications making outbound HTTP/HTTPS connections to non-Microsoft external hosts (RemoteTemplateFetch, risk 60), Office applications initiating SMB connections to port 445 indicating forced NTLM credential capture (ForcedAuthSMB_NTLMCapture, risk 90), and Office applications spawning known LOLBin child processes following template load (OfficeChildProcess_PostTemplateExec, risk 75). Microsoft infrastructure domains are excluded from the RemoteTemplateFetch branch to suppress legitimate Office telemetry. Results are risk-scored and sorted highest-risk first.

Data Sources

Sumo Logic Installed Collector with Windows Event Log sourceSumo Logic Sysmon collectionSumo Logic Cloud SIEM with Windows normalisation schema

Required Tables

windows/sysmonos/windows/sysmon

False Positives & Tuning

  • Third-party Office add-ins (Grammarly, DocuSign, Nuance Dragon, Adobe Sign) that establish outbound HTTP/HTTPS connections from within Office process space during normal document open or editing — extend the IsMicrosoftInfra exclusion filter to include verified vendor domains used by deployed add-ins
  • Document management and workflow automation platforms (OpenText, Nintex, K2, Laserfiche) that drive Office via COM automation and spawn PowerShell or CMD for document conversion, routing, or archiving tasks — correlate ParentCommandLine to distinguish scripted pipeline invocations from interactive user macro execution
  • Macro-enabled corporate templates used by finance, legal, or HR teams that legitimately call external REST APIs for data population (e.g. pulling live rates, CRM lookups) — document approved external template source URLs and add to the allowlist; engage business stakeholders to capture the full list before tuning
Download portable Sigma rule (.yml)

Other platforms for T1221


Testing Methodology

Validate this detection against 5 adversary techniques from Atomic Red Team. Each test below lists the behaviour to exercise and the telemetry you should expect to see. Executable commands and cleanup steps are available with Pro.

  1. Test 1OOXML Remote Template Injection — DOCX with External attachedTemplate

    Expected signal: When document is opened in Word: Sysmon Event ID 3 with Image=winword.exe, DestinationIp=127.0.0.1, DestinationPort=8080. Sysmon Event ID 22 (DNS Query) if a FQDN is used instead of localhost. DeviceNetworkEvents in MDE will show InitiatingProcessFileName=winword.exe with RemoteIP=127.0.0.1 and RemotePort=8080. The connection will be refused (no listener) but the event fires before the TCP RST.

  2. Test 2RTF Template Injection — \*\template Control Word with HTTP URL

    Expected signal: When opened in Word: Sysmon Event ID 3 with Image=winword.exe, DestinationIp=127.0.0.1, DestinationPort=8080. DeviceFileEvents may show the RTF file being read from its download location. The RTF \*\template control word triggers the same network fetch mechanism as the OOXML attachedTemplate relationship.

  3. Test 3Forced Authentication via SMB UNC Template Reference

    Expected signal: Sysmon Event ID 3 with Image=winword.exe, DestinationPort=445, DestinationIp=127.0.0.1. On a real attack with an external IP: Security Event ID 4648 (explicit credential use) or 4624 (NTLM logon type 3) on the domain controller. Sysmon Event ID 22 may show DNS lookup if a hostname is used instead of IP. DeviceNetworkEvents in MDE shows InitiatingProcessFileName=winword.exe, RemotePort=445.

  4. Test 4Phishery-style Template URL Injection into Existing DOCX

    Expected signal: File creation events (Sysmon EventCode=11) for both the original and injected DOCX in %TEMP%. When the injected DOCX is opened: Sysmon EventCode=3 from winword.exe to 127.0.0.1:8080. The manipulation of the ZIP archive using System.IO.Compression is visible as PowerShell process events (Sysmon EventCode=1) before the Office network event — the chain of PowerShell→file creation→Office network connection is the full kill chain telemetry.

  5. Test 5Verify Template Injection Document Structure — Manual Inspection

    Expected signal: PowerShell process creation (Sysmon EventCode=1) with command line containing System.IO.Compression.ZipFile. No network events — this is static analysis only. The script outputs the injected URL to the console, confirming the template injection payload is present before any execution occurs.

Unlock Pro Content

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

Response PlaybookInvestigation GuideHunting QueriesAtomic Red Team TestsTuning Guidance

Related Detections