Most malicious documents need one hidden part to do harm, a macro, a script, an embedded object or a launch action, and removing that part while keeping the rest usable stops the attack without blocking the business. MITRE D3FEND names this countermeasure Content Excision (D3-CNE) and defines it as "Removing specific, potentially malicious, parts of content". It sits under the Isolate tactic as a child of Content Modification (D3-CM), which itself sits under Content Filtering (D3-CF), alongside Content Format Conversion, Content Rebuild and Content Substitution. This card covers what excision removes in common file formats, how D3FEND relates it to ATT&CK, where it is deployed, how to prove it works, and where it breaks. It is written for email and web security engineers, application teams that accept file uploads, and security architects designing content disarm and reconstruction (CDR) pipelines.
Key takeaways
- Excision is surgical. It removes only the parts that break policy and keeps the file in its original format, which makes it more acceptable to users than blocking or flattening.
- Decide per item, not per file. D3FEND's reference, an OPSWAT CDR patent application, judges each item on risk, visibility to the user and whether the file structure needs it, then keeps, removes or modifies it.
- D3FEND links it to 15 ATT&CK techniques through the File artefact. These include Data from Local System (T1005), File Deletion (T1070.004) and Spearphishing via Service (T1566.003); all are inferred relations, not proof of coverage.
- Removing is harder than it looks. Formats such as PDF keep old content after an edit unless the file is rewritten, so excision must rebuild the output rather than patch it.
- Verify the output, not the engine. Run a strict check after excision that confirms no active content remains, and alert on any failure, as the NCSC's safe import pattern recommends.
D3-CNE at a glance
| Attribute | Value |
|---|---|
| D3FEND ID | D3-CNE (d3f:ContentExcision) |
| Tactic | Isolate |
| Parent technique | Content Modification (D3-CM): "Modify content that does not comply with policy." |
| Siblings | Content Format Conversion (D3-CFC), Content Rebuild (D3-CNR), Content Substitution (D3-CNS) |
| Digital artefacts (inherited) | Modifies File; filters Digital Media, File Content Block and File Metadata; enforces Content Policy |
| D3FEND description | If malicious or unnecessary elements are discovered within the content, or a specific embedded portion does not comply with policy, it may be removed to ensure safety |
| D3FEND reference | OPSWAT Inc., Method For Content Disarm and Reconstruction, US20190268352A1 (application published 29 August 2019; listed as abandoned) |
| Where it runs | Email gateways, web proxies, file upload services, cross-domain and file transfer gateways, endpoint agents |
| Main limitation | Only removes what the parser recognises; the parser itself handles hostile input |
How it works
Excision has four stages: parse the file into its parts, classify each part against a content policy, remove the parts that fail, and write a new, valid file from what remains. The D3FEND reference patent describes this for compound (OLE structured storage) files: the engine breaks the file into storages and streams, assesses each item in each stream, processes it, and reassembles a file with the same format as the input.
The patent's decision logic is a useful model for any excision policy. Each item is judged on three criteria:
- Acceptability of unwanted behaviour: unacceptable, acceptable or unknown risk.
- Visibility: whether the user perceives the item. Images are visible, macros are hidden, fonts are partly visible.
- Necessity: whether the file structure depends on it. A header is mandatory; a hyperlink is not.
Hidden, non-mandatory items with unacceptable or unknown risk are removed. Unacceptable items that are visible or mandatory are modified instead (for example stripping metadata or embedded objects, or re-saving an image), which is where excision hands over to its sibling techniques. Low-risk visible items are kept.
What is typically excised
| Format family | Parts commonly removed | Notes |
|---|---|---|
| Office Open XML (.docx, .xlsx, .pptx and macro-enabled variants) | VBA project part (vbaProject.bin), ActiveX controls, embedded OLE objects, external template and data links, custom XML that triggers external fetches | Removing the VBA project from a macro-enabled file also means the output should use the macro-free extension and content type |
| Legacy Office binary (.doc, .xls, .ppt) | Macro storages, embedded OLE objects, hidden streams | The structured storage case the D3FEND reference patent describes |
| JavaScript, OpenAction and additional actions, Launch actions, embedded files, XFA forms, external links | Must be written as a new file: an edited PDF can retain the original objects in earlier revisions | |
| Images | Metadata blocks (EXIF, XMP, comments), trailing data after the image end marker, embedded thumbnails | Often combined with re-encoding, which is Content Format Conversion |
| Archives | Disallowed member types (executables, scripts, shortcut files), nested archives beyond a depth limit | Each member is processed in turn; set a nesting limit to avoid recursion problems |
| HTML and email bodies | Script elements, event handler attributes, active embeds | See the HTML Sanitisation Guide |
Where identity fits
Metadata excision is also a data protection control. Document properties, tracked changes, comments and embedded file paths can expose user names, internal host names and sometimes connection strings or tokens left in embedded objects. Excising them from outbound documents reduces what an attacker can learn for credential and service account targeting; leaked secrets in files map to Credentials In Files (T1552.001), one of the techniques D3FEND relates to this countermeasure.
ATT&CK techniques D3FEND relates to D3-CNE
Relationship type: inferred only. D3FEND lists no direct ATT&CK mapping for D3-CNE; every row below is inferred through the File artefact that D3-CNE modifies (D3FEND 1.6.0, checked November 2026).
D3FEND derives these rows because each ATT&CK technique acts on a File (accesses, creates, adds, modifies, deletes, encrypts or produces one). D3FEND's page for the technique also shows a much longer list inferred through sub-artefacts of File, such as Office Application File (VBA Stomping, T1564.007) and Executable File (Malicious File, T1204.002); those two are the most practically relevant to excision and are shown at the end. All IDs were checked against ATT&CK v20. The relevance column is NHI Mgmt Group's view.
| ATT&CK ID | Technique | D3FEND relation on File | Practical relevance of excision |
|---|---|---|---|
| T1566.003 | Spearphishing via Service | Produces File | High: files arriving through messaging and collaboration services can be disarmed at the service boundary |
| T1220 | XSL Script Processing | Adds File | Medium: scriptable XSL content can be removed from documents in transit |
| T1072 | Software Deployment Tools | Adds File | Low: deployment packages are not usually disarmed |
| T1552.001 | Credentials In Files | Accesses File | Medium: metadata and embedded object excision removes leaked credentials from outbound files |
| T1005 | Data from Local System | Accesses File | Low: a collection technique, weak relation |
| T1083 | File and Directory Discovery | Accesses File | Low: weak relation |
| T1119 | Automated Collection | Accesses File | Low: weak relation |
| T1036.005 | Match Legitimate Resource Name or Location | May create File | Low: excision does not address naming |
| T1036.006 | Space after Filename | Creates File | Low: handled by file type validation rather than excision |
| T1074.001 | Local Data Staging | May create File | Low: weak relation |
| T1070.004 | File Deletion | Deletes and may modify File | Low: weak relation |
| T1486 | Data Encrypted for Impact | Encrypts File | Low: weak relation |
| T1564.006 | Run Virtual Instance | Creates File | Low: weak relation |
| T1564.012 | File/Path Exclusions | Creates File | Low: weak relation |
| T1565.001 | Stored Data Manipulation | Modifies File | Low: weak relation |
| T1564.007 | VBA Stomping (sub-artefact: Office Application File) | Modifies Office Application File | High: removing the whole VBA project removes both source and compiled code |
| T1204.002 | Malicious File (sub-artefact: Executable File) | Executes Executable File | High: the user can only open what is left after excision |
Most of the 15 same-artefact rows are weak for this countermeasure because D3FEND infers them from any action on a file. Phishing attachments, the main use case in practice, are related in D3FEND through the Email artefact rather than File; see the MITRE ATT&CK T1566 Phishing and T1204 User Execution pages.
Where it is implemented
| Implementation class | Where excision happens | Fits when |
|---|---|---|
| Secure email gateways and cloud email security | Attachments disarmed before delivery, often with the original held for release on request | Phishing attachments are the main exposure |
| Web proxies and secure web gateways | Downloads disarmed in transit | Users download documents from untrusted sites |
| File upload pipelines in applications | Uploaded files processed before storage or onward sharing; the OWASP File Upload Cheat Sheet lists running files through CDR where the type allows | Customers or partners upload documents into your services |
| Cross-domain and managed file transfer gateways | Files moved between trust zones are disarmed and then verified | Regulated or segmented networks, including OT |
| Metadata removal tools | Outbound documents and images stripped of properties, comments and hidden data | Publishing documents externally |
Product category selection is covered in the Content Disarm and Reconstruction buyer's guide and upload handling in the Secure File Upload Handling Guide.
Implementation steps
- Write the content policy first. For each file type you accept, list which parts are allowed, removed or cause a block. Typical first policy: remove macros, ActiveX, embedded executables, PDF JavaScript and launch actions; keep text, images and tables; block password-protected archives you cannot inspect.
- Identify legitimate exceptions. Finance models with macros, signed PDF forms and engineering files with embedded objects will break. Agree a release path (sender allowlist, signed macros, a request workflow) before enforcement.
- Run in monitor mode. Log what would be removed for two to four weeks without changing files. Review the counts per item type and per sender to find business processes the policy would break.
- Enforce for a pilot group. Turn on excision for one department, keep the original files in a quarantine store for a defined period, and give users a clear notice in the file or the message that content was removed.
- Add output verification. After excision, re-scan the output with a strict validator that confirms no active parts remain and that the file opens. Alert on any verification failure, since it means the engine missed something.
- Widen enforcement. Extend to all users and channels (email, web, uploads, file transfer) in stages, measuring helpdesk tickets and release requests at each stage.
- Roll back. Keep the ability to switch a channel back to monitor mode and to release originals from quarantine, so a broken business process can be restored within hours.
How to verify it works
- Benign test corpus: keep a set of harmless files that contain each item your policy removes (a macro that only shows a message box, a PDF with a JavaScript alert, an embedded OLE object, metadata with a test author). Send them through each channel monthly and confirm the output no longer contains them.
- Structure inspection: open outputs with a format inspection tool and confirm the removed parts are absent from the file structure, not just hidden. For PDF, confirm there are no earlier revisions carrying the removed objects.
- Usability check: confirm outputs open in the applications users have, with layout intact.
- Bypass attempts: include renamed extensions, nested archives and unusual encodings in authorised tests to confirm the engine identifies true types and enforces depth limits.
| Metric | Example target (NHI Mgmt Group suggestion, not a standard) | Why it matters |
|---|---|---|
| Test corpus items removed per channel | 100% every month | Proves each channel enforces the policy |
| Output verification failures | Zero, each one investigated | A failure means active content got through |
| Files passed unprocessed (unsupported, encrypted, oversized) | Tracked and falling | Unprocessed files are the real gap |
| Original release requests per 1,000 processed files | Low and stable | Shows the policy fits business use |
| Time to restore a broken process via release or exception | Within one business day | Keeps users from routing around the control |
Limits, bypasses and failure patterns
- Patching instead of rewriting: deleting an object reference but leaving the object bytes in the file, or appending a PDF revision, leaves the content recoverable. ExifTool's documentation notes, for example, that its PDF edits are reversible because original data is never removed from the file. Excision output must be a fresh, rewritten file.
- Unsupported and encrypted files passed through: engines that cannot parse a type often pass it unchanged by default. Decide explicitly whether unsupported means block.
- The parser as an attack surface: the excision engine parses hostile files. The NCSC safe import pattern assumes the transformation engine could be compromised; run it isolated, patched and with resource limits.
- Removing too little: a policy that strips macros but keeps external template links or remote images still lets a document call out to an attacker's server.
- Removing too much without a release path: users who lose working spreadsheets will move files through personal email or cloud storage, which removes the control entirely.
- Treating excision as malware detection: excision does not tell you a file was malicious. Keep scanning and reputation checks alongside it; see D3-FHRA File Hash Reputation Analysis.
Framework mapping
| Framework | Reference | Relevance |
|---|---|---|
| NIST SP 800-53 Rev 5 | SI-3 Malicious Code Protection | Removing malicious code at entry and exit points |
| NIST SP 800-53 Rev 5 | SC-18 Mobile Code | Policy on macros, scripts and active content in documents |
| NIST SP 800-53 Rev 5 | SC-7 Boundary Protection | Disarming files at gateways between trust zones |
| NIST CSF 2.0 | PR.PS-05 | Preventing installation and execution of unauthorised software |
| OWASP | File Upload Cheat Sheet | CDR as one layer of upload handling |
| NCSC | Pattern: safely importing data | Transformation followed by strict verification, in series |
| MITRE D3FEND | D3-CF, D3-CM, D3-CNE | Grandparent, parent and technique |
Related countermeasures
- Content Modification (D3-CM): the parent technique. See D3-CM Content Modification.
- Content Format Conversion (D3-CFC): converts the whole file to a safer format instead of removing parts. See D3-CFC Content Format Conversion.
- Content Rebuild (D3-CNR) and Content Substitution (D3-CNS): rebuild the file to its specification, or replace parts with safe alternatives instead of deleting them.
- Content Validation (D3-CV) and Content Quarantine (D3-CQ): check that content conforms before or after excision, and hold what cannot be made safe. See D3-CV Content Validation and D3-CQ Content Quarantine.
Practitioner checklist
- Write a per-file-type content policy: allowed, removed, blocked.
- Agree release paths for legitimate macros and embedded content before enforcing.
- Run monitor mode first and review removal counts by item type and sender.
- Require rewritten output files, never in-place edits or appended revisions.
- Decide explicitly how unsupported, encrypted and oversized files are handled.
- Verify every output with a strict validator and alert on failures.
- Run the excision engine isolated, patched and with resource and nesting limits.
- Keep originals in quarantine for a defined period with an audited release process.
- Test each channel monthly with a benign corpus and record the result.
Standards and references
- MITRE D3FEND: Content Excision (D3-CNE)
- OPSWAT Inc.: Method For Content Disarm and Reconstruction, US20190268352A1
- NCSC: Pattern: safely importing data
- OWASP: File Upload Cheat Sheet
- NIST: SP 800-53 Rev. 5 Security and Privacy Controls (SI-3, SC-18)
- MITRE ATT&CK: T1564.007 VBA Stomping
- ExifTool: application documentation
Related NHI Mgmt Group resources: Content Disarm and Reconstruction · Macro Malware Guide · Secure File Upload Handling Guide · MITRE D3FEND Guide