T1221 CrowdStrike LogScale · LogScale

Detect Template Injection in CrowdStrike LogScale

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/

LogScale Detection Query

CrowdStrike LogScale (LogScale)
cql
// T1221 Template Injection — Office Remote Template Fetch, Forced NTLM Auth, Child Process
#event_simpleName in ["NetworkConnectIP4", "ProcessRollup2"]
| case {
    // Branch 2: Forced NTLM authentication via SMB port 445
    #event_simpleName = "NetworkConnectIP4"
    AND ImageFileName = /(?i)(winword|excel|powerpnt|mspub|msaccess|visio)\.exe/
    AND RemotePort = 445
    | AlertType := "ForcedAuthSMB_NTLMCapture"
    | RiskScore := 90;

    // Branch 1: Remote template fetch via HTTP/HTTPS to non-Microsoft host
    #event_simpleName = "NetworkConnectIP4"
    AND ImageFileName = /(?i)(winword|excel|powerpnt|mspub|msaccess|visio)\.exe/
    AND RemotePort in [80, 443, 8080, 8443]
    AND NOT DomainName = /(?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)/
    | AlertType := "RemoteTemplateFetch"
    | RiskScore := 60;

    // Branch 3: Office child process spawning — post-template payload execution
    #event_simpleName = "ProcessRollup2"
    AND ParentBaseFileName = /(?i)(winword|excel|powerpnt|mspub|msaccess|visio)\.exe/
    AND FileName = /(?i)(cmd|powershell|pwsh|wscript|cscript|mshta|rundll32|regsvr32|certutil|bitsadmin|wmic|msiexec)\.exe/
    | AlertType := "OfficeChildProcess_PostTemplateExec"
    | RiskScore := 75;

    * | drop();
  }
| table(
    [@timestamp, ComputerName, UserName,
     FileName, CommandLine,
     ParentBaseFileName, ParentCommandLine,
     RemoteAddressIP4, RemotePort, DomainName,
     AlertType, RiskScore],
    limit=1000
  )
| sort(RiskScore, order=desc)
high severity high confidence

CrowdStrike LogScale (Humio) detection for T1221 Template Injection using Falcon sensor events from the Falcon Data Replicator (FDR) or Event Stream API. Queries NetworkConnectIP4 events for Office processes (winword.exe, excel.exe, powerpnt.exe, mspub.exe, msaccess.exe, visio.exe) making outbound connections on HTTP/HTTPS ports to non-Microsoft domains (RemoteTemplateFetch, risk 60) or on port 445 (ForcedAuthSMB_NTLMCapture, risk 90). Queries ProcessRollup2 events for Office processes spawning LOLBin child processes (cmd.exe, powershell.exe, mshta.exe, rundll32.exe, regsvr32.exe, certutil.exe, bitsadmin.exe, wmic.exe, msiexec.exe), indicating macro or exploit execution following remote template load (OfficeChildProcess_PostTemplateExec, risk 75). Microsoft infrastructure domains excluded from the RemoteTemplateFetch branch via DomainName regex negation. Results risk-scored and sorted highest-risk first.

Data Sources

CrowdStrike Falcon SensorFalcon Data Replicator (FDR)CrowdStrike Event Stream APICrowdStrike Falcon LogScale SIEM

Required Tables

NetworkConnectIP4ProcessRollup2

False Positives & Tuning

  • Office templates legitimately fetched from internal corporate servers or approved non-Microsoft CDN providers not covered by the DomainName exclusion regex — extend the NOT DomainName regex to include all known internal template-hosting domains and approved partner CDN hostnames
  • Software deployment tooling or patch management systems (SCCM, PDQ, Ansible) that use Office COM automation and spawn PowerShell or CMD as part of document generation, conversion, or reporting workflows — cross-reference CommandLine and ParentCommandLine against known deployment job signatures to distinguish scripted automation from interactive user activity
  • Browser-integrated Office experiences (Office Online editing plugins, Outlook add-ins, SharePoint co-authoring) that route network connections through the Office process to external services — validate flagged DomainName values against the deployed add-in and integration inventory before escalating to an incident
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