Deleting every risky element from a file is safe but often breaks the file, while leaving the element in place is usable but unsafe; content substitution is the middle path of swapping the element for something harmless. MITRE D3FEND names this countermeasure Content Substitution (D3-CNS) and defines it as "Modifies specific digital content information by replacing it with something else." It sits under the Isolate tactic as a child of Content Modification (D3-CM), alongside Content Excision, Content Format Conversion and Content Rebuild. This card explains what gets substituted in practice, which ATT&CK techniques D3FEND relates to it, where the technique is implemented, how to test that substitutes are safe and the file still works, and where substitution stops helping. It is for email, web and application security engineers who run or are designing a content disarm and reconstruction (CDR) pipeline; the rebuild step itself is covered in D3-CNR Content Rebuild.
Key takeaways
- Replace, do not just remove. D3FEND's description is that when malicious or unnecessary elements are found, or an embedded portion does not comply with policy, "it may be replaced with alternatives to ensure safety."
- It is a policy action inside CDR. D3FEND's only reference for D3-CNS is the same OPSWAT content disarm and reconstruction patent used for the whole Content Modification family; in products, substitution is usually one of several actions a CDR policy can take per element.
- The substitute must be inert and honest. A placeholder that tells the user what was replaced keeps trust and cuts release requests; a silent swap leaves users confused about what changed.
- The ATT&CK links are broad and inferred. D3FEND relates D3-CNS to techniques through the File artefact; the practical value is against malicious attachments, macros, embedded objects and links in delivered files.
- Test the substitute, not only the removal. A rewritten link that resolves to an unchecked page, or a re-encoded image produced by a vulnerable library, moves the risk rather than removing it.
D3-CNS at a glance
| Attribute | Value |
|---|---|
| D3FEND ID | D3-CNS (d3f:ContentSubstitution) |
| Tactic | Isolate |
| Parent technique | Content Modification (D3-CM), under Content Filtering (D3-CF) |
| Sibling techniques | Content Excision (D3-CNE), Content Format Conversion (D3-CFC), Content Rebuild (D3-CNR) |
| Digital artefacts | Modifies File; filters Digital Media, File Content Block and File Metadata; enforces Content Policy |
| D3FEND reference | Patent US20190268352A1, Method For Content Disarm and Reconstruction (OPSWAT, Inc.) |
| Typical substitutions | Active content to a notice, hyperlinks to inspected links, images to re-encoded copies, metadata values to neutral values |
| Main limitation | The substitute inherits trust; if it is not itself safe or checked, the attack moves to the substitute |
D3FEND version 1.6.0, checked November 2026. In the D3FEND ontology the artefact relations are declared on the parent D3-CM and inherited by D3-CNS; the D3FEND site lists the same relations for D3-CNS.
How it works
Content substitution acts on one element at a time. The CDR engine parses the file, identifies each element, compares it with the content policy, and for elements that fail the policy chooses a replacement rather than deleting them or rejecting the whole file. The OPSWAT patent that D3FEND cites frames the element-level decision around three questions: whether the element's behaviour is acceptable, whether it is visible to the user, and whether it is necessary. Substitution suits elements that are visible or necessary but whose behaviour is not acceptable.
| Element | Example substitute | Why substitute rather than remove |
|---|---|---|
| Macro project or script in a document | A short visible notice that active content was removed, and where to request the original | Users see why a button or automation no longer works and do not open a support ticket |
| Embedded object (for example an embedded executable or OLE package) | A static image or icon of the object, or a text note | Page layout survives, so the document still reads correctly |
| Hyperlink in a document or message | A rewritten link that routes through a checking service, or the plain text of the original URL | The reader keeps the reference without a direct click to an unchecked destination |
| Image | A re-encoded copy in a permitted format with metadata stripped | The picture stays; hidden data in the original encoding does not |
| Metadata values (author, path, comments, location) | Neutral or empty values | Removes information leakage while keeping a valid file structure that requires the field |
| Form actions in PDF | Inert form fields | The form can still be read and printed |
The OWASP File Upload Cheat Sheet recommends converting uploaded images into a permitted format and stripping unneeded metadata, and cautions that "Rewriting does not guarantee that all malicious content is removed." It also notes that the image library is processing untrusted input and should run with restricted formats, resource limits and sandboxing. The same caution applies to every substitution engine.
ATT&CK techniques D3FEND relates to D3-CNS
Relationship type: inferred only. D3FEND lists no direct ATT&CK mapping for D3-CNS. Its site derives related techniques through shared digital artefacts and labels them "inferred, experimental" (D3FEND 1.6.0, checked November 2026). Because D3-CNS modifies the File artefact, the list spans most ATT&CK tactics. The table is a selection, made by NHI Mgmt Group, of techniques where substituting content in delivered files genuinely changes the outcome; each ID was checked against ATT&CK v20. D3FEND's list also carries Impair Defenses entries that ATT&CK v20 has revoked; the v20 successors include T1685 Disable or Modify Tools, which substitution does not affect.
| ATT&CK ID | Technique | What substitution changes (NHI Mgmt Group view) |
|---|---|---|
| T1566.001 | Spearphishing Attachment | Active parts of the attachment are replaced before delivery |
| T1566.002 | Spearphishing Link | Links inside delivered documents can be replaced by checked or non-clickable versions |
| T1204.002 | Malicious File | The element the user was meant to trigger is no longer there to run |
| T1137, T1137.001 | Office Application Startup, Office Template Macros | Macro code is replaced by a notice when policy forbids macros |
| T1564.007 | VBA Stomping | The VBA project, including any mismatched streams, is replaced as a whole |
| T1027 | Obfuscated Files or Information | Obfuscated content in a substituted element is not carried forward |
| T1036.005, T1036.006 | Match Legitimate Resource Name or Location, Space after Filename | Limited: substitution changes content, not file names; pair with file type checks |
| T1005, T1070.004, T1072, T1074.001, T1083, T1119 | Data from Local System, File Deletion, Software Deployment Tools, Local Data Staging, File and Directory Discovery, Automated Collection | Little practical effect; related by D3FEND only because these techniques act on files |
For the defensive detail on the initial access path, see MITRE ATT&CK T1566 Phishing and T1204 User Execution. On-host techniques such as MITRE ATT&CK T1072 Software Deployment Tools need host and identity controls, not content substitution.
Where it is implemented
- CDR engines and services: per-element policy actions (keep, remove, replace) for macros, embedded objects, links and metadata, applied by email gateways, web gateways, file transfer connectors and APIs. The Content Disarm and Reconstruction buyer's guide covers how to evaluate these.
- Email security link rewriting: many email security services replace URLs in messages with links that route through a checking service at click time. This is substitution applied to message content rather than to attachments; see the Email Security Guide.
- Application upload pipelines: image re-encoding and metadata replacement in the application, using an image or document library, as covered in the File Upload Security Guide.
- Cross domain solutions: in an import gateway, a complex element may be substituted with a simpler, verifiable form before the protocol break, following the transformation and verification steps of the NCSC safe import pattern.
Deployment steps
- Choose the action per element type. For each file type and channel, record whether each element class is kept, removed (excision) or replaced (substitution). Substitution is usually right for visible elements users notice when missing.
- Design the substitutes. Write the notice text, choose the placeholder image, decide whether rewritten links are clickable, and confirm the substitute itself contains no active content.
- Keep a change record per file. Log which elements were substituted, so analysts and users can see what changed. The NCSC cross domain principles note that the end user must still be able to judge whether a transformation has changed the data.
- Run in report-only mode. Log the substitutions that would happen for two to four weeks and review them with the owners of affected workflows.
- Pilot and widen. Enable substitution for one channel and group, track release requests and complaints, then extend.
- Verify after substitution. Check that the output is well formed and that no forbidden element remains; raise an alert on every verification failure, as the NCSC import pattern advises.
- Roll back safely. Keep originals in a protected store for a defined period and allow reviewed release, so a bad substitution can be reversed without disabling the control.
How to verify it works
- Known-structure corpus: send harmless test files through every channel, each containing one element that policy should replace: a document with a harmless macro, a document with an embedded object, a PDF with a form action, an image with location metadata, a document with a hyperlink. Confirm the substitute appears and the original element does not.
- Substitute inspection: open the output and confirm the notice text is present, the placeholder renders, and rewritten links resolve through the checking service rather than directly.
- Nested content: repeat with the same samples inside archives and embedded documents. The NCSC content-based attack protection principle asks for nested content to be expanded, transformed and verified like the outer file.
- Fidelity: confirm layout and remaining content are unchanged apart from the substituted elements.
| Metric | Example target (NHI Mgmt Group suggestion, not a standard) | Why it matters |
|---|---|---|
| Corpus elements replaced as policy requires, per channel | 100% on every monthly run | Proves substitution still runs after updates |
| Substitutes containing any active content | Zero | The substitute must be inert |
| Release requests per 1,000 processed files | Falling after the pilot | Shows the substitutes keep files usable |
| Files with a complete change record | 100% | Lets users and analysts see what changed |
| Verification failures raised as alerts | Every failure investigated | A failure points to a faulty or compromised transformation step |
Limits, bypasses and failure patterns
- Substitutes that point somewhere unchecked: a rewritten link only helps if the checking service evaluates the destination at click time; a link replaced by another direct link changes nothing.
- Silent substitution: users who find a broken document with no explanation forward the original through personal channels, which bypasses the control.
- Vulnerable substitution libraries: image and document libraries parse hostile input. Patch them, restrict formats and run them sandboxed with resource limits, as OWASP advises for image rewriting.
- Encrypted and unsupported content: elements inside password-protected archives or unsupported formats cannot be substituted; set an explicit outcome instead of silent delivery.
- Substitution of the wrong layer: replacing the visible text of a link but not its target, or the thumbnail of an embedded object but not the object, leaves the risky element in place. Test the structure, not the appearance.
- Treating substitution as detection: substitution removes risk silently and produces few alerts. Keep D3-FCOA File Content Analysis and sandboxing so you still learn who is being targeted.
Framework mapping
| Framework | Reference | Relevance |
|---|---|---|
| NIST SP 800-53 Rev 5 | SI-3 Malicious Code Protection | Protection at entry points, of which content substitution is one mechanism |
| NIST SP 800-53 Rev 5 | AC-4(8) Security and Privacy Policy Filters | Policy filters on information flows that modify non-compliant content |
| NIST SP 800-53 Rev 5 | SC-18 Mobile Code | Controls on macros and active code in documents |
| NIST CSF 2.0 | PR.PS-01 | Configuration practices for the substitution policy and platform |
| MITRE D3FEND | D3-CF, D3-CM, D3-CNS | Grandparent, parent and technique |
Practitioner checklist
- Decide keep, remove or replace for every element class, per channel.
- Design substitutes that are inert and tell the user what was replaced.
- Route rewritten links through click-time checking, or make them non-clickable.
- Log a change record for every processed file.
- Start in report-only mode, then pilot one channel and group.
- Verify output after substitution and alert on every failure.
- Test nested and encrypted content, and set an explicit outcome for what cannot be processed.
- Patch and sandbox the libraries that perform substitution.
Standards and references
- MITRE D3FEND: Content Substitution (D3-CNS)
- OPSWAT, Inc.: Method For Content Disarm and Reconstruction (US20190268352A1)
- NCSC: Pattern for safely importing data
- NCSC: Cross domain solutions principles
- NCSC: Cross domain solutions, content based attack protection
- OWASP: File Upload Cheat Sheet
- NIST: SP 800-53 Rev. 5 Security and Privacy Controls
Related NHI Mgmt Group resources: D3-CNR Content Rebuild · Content Disarm and Reconstruction · Office Macro Blocking Guide · Email Security Guide · MITRE D3FEND Guide