Template Injection
- ID
- T1221
- Tactics
- TA0005 Stealth
- Platforms
- Windows
- Data sources
- Process Creation, Network Connection Creation
- Source
- attack.mitre.org
- MITRE last modified
- 12 May 2026
Adversaries may create or modify references in user document templates to conceal malicious code or force authentication attempts. For example, Microsoft’s Office Open XML (OOXML) specification defines an XML-based format for Office documents (.docx, xlsx, .pptx) to replace older binary formats (.doc, .xls, .ppt). OOXML files are packed together ZIP archives compromised of various XML files, referred to as parts, containing properties that collectively define how a document is rendered.[3]
Properties within parts may reference shared public resources accessed via online URLs. For example, template properties may reference a file, serving as a pre-formatted document blueprint, that is fetched when the document is loaded.
Adversaries may abuse these templates to initially conceal malicious code to be executed via user documents. Template references injected into a document may enable malicious payloads to be fetched and executed when the document is loaded.[4] These documents can be delivered via other techniques such as Phishing and/or Taint Shared Content and may evade static detections since no typical indicators (VBA macro, script, etc.) are present until after the malicious payload is fetched.[5] Examples have been seen in the wild where template injection was used to load malicious code containing an exploit.[6]
Adversaries may also modify the *\template control word within an .rtf file to similarly conceal then download malicious code. This legitimate control word value is intended to be a file destination of a template file resource that is retrieved and loaded when an .rtf file is opened. However, adversaries may alter the bytes of an existing .rtf file to insert a template control word field to include a URL resource of a malicious payload.[7][8]
This technique may also enable Forced Authentication by injecting a SMB/HTTPS (or other credential prompting) URL and triggering an authentication attempt.[1][9][10]
Detection
- DET0566 Template Injection Detection - Windows
Data components: Process Creation, Network Connection Creation
Mitigations (4)
- M1017 User Training
Train users to identify social engineering techniques and spearphishing emails that could be used to deliver malicious documents.
- M1031 Network Intrusion Prevention
Network/Host intrusion prevention systems, antivirus, and detonation chambers can be employed to prevent documents from fetching and/or executing malicious payloads.[1]
- M1042 Disable or Remove Feature or Program
Consider disabling Microsoft Office macros/active content to prevent the execution of malicious payloads in documents [2], though this setting may not mitigate the Forced Authentication use for this technique.
- M1049 Antivirus/Antimalware
Network/Host intrusion prevention systems, antivirus, and detonation chambers can be employed to prevent documents from fetching and/or executing malicious payloads.[1]
Groups (8)
- G0007 APT28
- G0035 Dragonfly
- G0047 Gamaredon Group
- G0079 DarkHydrus
- G0081 Tropic Trooper
- G0100 Inception
- G0142 Confucius
- G1054 MirrorFace
Software (2)
References
- Anomali Template Injection MAR 2018
- Microsoft Disable Macros
- Microsoft Open XML July 2017
- SANS Brian Wiltse Template Injection
- Redxorblue Remote Template Injection
- MalwareBytes Template Injection OCT 2017
- Proofpoint RTF Injection
- Ciberseguridad Decoding malicious RTF files
- Talos Template Injection July 2017
- ryhanson phishery SEPT 2016
