9.4 Safe Attachments Policies
Safe Attachments Policies
By the end of this subsection, you will understand sandbox detonation modes, know when to use Dynamic Delivery vs Block, configure Safe Attachments for SharePoint/OneDrive/Teams, and verify detonation results with KQL.
How Safe Attachments works
Safe Attachments opens email attachments in an isolated sandbox (a virtual machine) and observes their behavior. If the file tries to execute code, modify the registry, download additional files, or phone home to a C2 server, it is classified as malicious and blocked.
This catches zero-day malware that signature-based scanning misses — the file has never been seen before, so it has no signature, but its behavior in the sandbox reveals malicious intent.
Detonation modes
| Mode | Behavior | User experience | Best for |
|---|---|---|---|
| Block | Email is held until detonation completes. Malicious = quarantined. Clean = delivered. | Delay of 30 seconds to 2 minutes on every email with attachments | Maximum security, acceptable for most environments |
| Dynamic Delivery | Email body delivered immediately. Attachment placeholder shown until detonation completes. Clean = placeholder replaced with real attachment. | No email delivery delay. Attachment available within 1-2 minutes. | Environments where email delivery speed is critical |
| Monitor | Email delivered immediately. Attachment detonated in background. Malicious = logged but NOT blocked. | No delay, no blocking | Testing only — never for production |
| Replace | Attachment removed and notification inserted in email body | User sees notification instead of attachment | High-security environments |
Block mode is the most secure but introduces noticeable email delay. Dynamic Delivery provides the same detection without the delay — users receive the email body immediately and can read it while the attachment detonates. The only scenario where Block is clearly superior: environments where users must not see any part of a phishing email (military, classified). For commercial organizations, Dynamic Delivery is the correct choice.
Safe Attachments for SharePoint, OneDrive, and Teams
Email attachments are not the only file vector. Attackers upload malicious files to SharePoint or share them via Teams. Safe Attachments for SPO/OD/Teams scans files uploaded to these services and blocks access to files identified as malicious.
Configuration: In Threat policies, enable “Turn on Defender for Office 365 for SharePoint, OneDrive, and Microsoft Teams.” This is a global setting — it applies to all sites and channels.
| |
| Date | MalwareCount | UniqueFiles | FileTypes |
|---|---|---|---|
| Mar 15 | 3 | 2 | ["docm","xlsm"] |
| Mar 18 | 12 | 1 | ["docm"] |
Safe Documents for Office clients
Safe Documents extends sandbox detonation to files opened in Protected View on desktop Office apps. When a user opens a Word, Excel, or PowerPoint file from the internet or an email attachment, Office opens it in Protected View (read-only). Safe Documents scans the file while it is in Protected View. If the file is clean, the user can click “Enable Editing.” If malicious, the file is blocked.
This catches a common attack vector: a user downloads a macro-enabled document from a website (not email), opens it in Word, and the macro detonation in Safe Documents catches the malware before the user enables editing.
Safe Documents is not included in Defender for Office 365 P1 or P2 standalone — it requires the full M365 E5 license. If you are on E5, it is enabled by default. Verify in Threat policies that it is active.
Detonation verdict verification
After configuring Safe Attachments, verify it is working by checking detonation results:
| |
| ThreatTypes | Detections | UniqueHashes | FileTypes | Actions |
|---|---|---|---|---|
| Malware | 8 | 3 | ["docm","xlsm"] | ["Blocked"] |
| Phish | 2 | 2 | ["html"] | ["Blocked"] |
Required role and blast radius
Required role: Security Administrator.
Detonation modes — choosing the right one
Safe Attachments has four modes. The choice affects both security and user experience:
Block. Attachments are detonated in the sandbox. If malicious: the entire email is blocked (not delivered). If clean: delivered normally. Detonation takes 30-120 seconds. During this time, the email is delayed.
Replace (Dynamic Delivery — recommended). The email body is delivered immediately without the attachment. The attachment is detonated in parallel. If clean: the attachment is re-attached (the user sees it appear in the email after a short delay). If malicious: the attachment is removed and the user is notified. The user can read the email immediately and receives the attachment within minutes.
Monitor. Attachments are detonated but no action is taken. The results are logged. Use this for initial deployment to understand the detection volume before enabling blocking.
Off. No detonation. Not recommended for any production environment.
Recommended deployment path:
Week 1: Deploy in Monitor mode. Review detections daily. Assess: how many attachments are flagged, what file types, how many false positives?
Week 2: Switch to Dynamic Delivery. Users receive email bodies immediately; attachments arrive after detonation. This is the best balance of security and usability.
Week 4: Review. If false positive rate is acceptable: maintain Dynamic Delivery. If specific senders are consistently flagged (legitimate automated systems sending unusual file types): create per-sender exceptions.
| |
A steady baseline of 5-20 malware attachments blocked per week is typical. A spike (100+ in a day) indicates a campaign — investigate with Threat Explorer.
Safe Attachments for SharePoint, OneDrive, and Teams
Extend Safe Attachments beyond email. When a file is uploaded to SharePoint, OneDrive, or Teams, Safe Attachments scans it. If malicious: the file is blocked from download (users can see the file name but cannot open it).
Navigate to: Defender → Policies → Safe Attachments → Global settings → Turn on Defender for Office 365 for SharePoint, OneDrive, and Microsoft Teams.
Why this matters for insider threat (Module 16). If a compromised account uploads a malicious file to SharePoint, Safe Attachments blocks other users from downloading it — containing the spread without requiring manual intervention.
Blast radius: File upload delay (scanning takes seconds). False positives block legitimate files from download — rare but impactful when it happens to a shared project file.
Rollback: Disable the global setting. Blocked files become downloadable again immediately.
Verify:
| |
NIST CSF: DE.CM-4 (Malicious code is detected). ISO 27001: A.8.7 (Protection against malware). SOC 2: CC6.8 (Prevent or detect unauthorized software). Safe Attachments is the file-layer sandboxing control for email and cloud storage.
Dynamic Delivery — the user experience
Understanding the user experience helps you set expectations during deployment:
T=0: The email arrives. The user sees the email body, but the attachment shows a placeholder: “This attachment is being scanned. It will be available shortly.”
T=30-120 seconds: The sandbox completes detonation. If clean: the placeholder is replaced with the actual attachment. The user can now open it. If malicious: the placeholder is replaced with a notification: “This attachment has been removed because it contained malware.”
What happens if the user opens the email during scanning? They see the placeholder. They cannot download or preview the attachment. Some users will be confused (“where is the attachment?”). Pre-communicate: “You may occasionally see a ‘scanning’ placeholder on attachments. This is our new malware protection — the attachment will appear within 1-2 minutes.”
| |
Expected: Dynamic Delivery applies to 10-30% of delivered email (emails with attachments). If the percentage is higher: check whether attachments from known-safe internal systems are being scanned unnecessarily (consider per-sender exceptions). If 0%: Safe Attachments is not in Dynamic Delivery mode or is not processing email correctly.
Attachment types that evade sandboxing
Not all file types can be detonated in the sandbox. Some bypass analysis:
Password-protected archives. A ZIP file with a password cannot be opened by the sandbox. The attacker includes the password in the email body — the user extracts the file manually, bypassing the sandbox entirely. Detection relies on: heuristic rules (email with a password-protected attachment is suspicious), the transport rule blocking dangerous file types inside the archive (if extractable), or endpoint detection when the payload executes.
Embedded macros in uncommon formats. The sandbox prioritises Office documents (Word, Excel, PowerPoint) and executables. Less common formats (.slk, .iqy, .settingcontent-ms) may receive less thorough analysis. These are niche attack vectors but worth blocking at the transport layer (subsection 9.7, Rule 3).
Files exceeding the size limit. Safe Attachments has a maximum file size for sandbox detonation. Files exceeding this limit are delivered without detonation. The limit varies by configuration — check the current Microsoft documentation for the active limit.
Safe Attachments operational metrics
Track monthly to assess sandbox effectiveness:
Detection volume: Malware attachments blocked per month. A steady baseline with occasional spikes (campaigns) is normal. A sudden drop to zero: either no malware is targeting your organisation (unlikely), or Safe Attachments is not processing email (investigate).
Detonation time: How long between email arrival and sandbox verdict. The monitoring query from this subsection provides this data indirectly (emails with Dynamic Delivery show a delay). Target: under 2 minutes for 95% of attachments. If slower: consider whether your Safe Attachments policy is scanning too broadly (all attachments vs targeted file types).
File type distribution: What types of malicious files are being caught?
| |
This shows which file types your organisation is being targeted with. If .docm (macro-enabled Word) dominates: your transport rule should block .docm unless specifically needed. If .html or .htm appears frequently: attackers are using HTML smuggling — a technique where the HTML file contains embedded JavaScript that assembles a malicious payload in the browser.
Safe Attachments and the investigation timeline
During an incident investigation (Modules 12-16), the Safe Attachments verdict appears in EmailAttachmentInfo. This tells you:
Was the attachment caught or missed? If ThreatTypes shows “Malware”: the sandbox detected the threat but the email may still have been delivered (depending on the mode — Monitor mode logs but does not block).
What was the detonation result? The sandbox analysis details provide: the file hash (for IOC matching), the observed behaviour (network connections, registry modifications, process creation), and the classification.
| |
The SHA256 hash is critical for: cross-referencing with endpoint detections (did any device execute this hash?), checking against threat intelligence (VirusTotal, MITRE), and creating file-based detection rules in Defender for Endpoint.
Safe Attachments exception management
Not every attachment needs sandboxing. Some legitimate automated systems send attachments that trigger false positives or cause unnecessary processing delays.
Common exception scenarios:
Automated report systems that send PDF reports hourly (ERP, BI tools). These are high-volume, known-benign senders. Exception: create a Safe Attachments policy exception for the specific sender address (e.g., reports@erp.northgateeng.com).
Scanned document systems that send image-heavy PDFs (multifunction printers that scan-to-email). These are internal senders whose output triggers extended detonation times. Exception: bypass scanning for the printer’s sender address.
Partner data feeds that send CSV or XML files on a schedule. These fail detonation (the sandbox cannot meaningfully analyse CSV files) and add processing delay without security benefit. Exception: bypass for the specific sender and file type combination.
How to create exceptions: Defender → Policies → Safe Attachments → create a new policy (higher priority than default) with condition “The sender is [address]” and action “Off” (disable scanning for this sender). Document each exception with: the business justification, the risk assessment (what threats would be missed), the review date (quarterly), and the approver.
Exception governance: Every exception is a hole in the protection stack. Review exceptions quarterly. If the automated system changes (new sender address, new file types): update the exception. If the system is decommissioned: remove the exception. Maintain a register: sender, exception type, date created, justification, next review date.
| |
High-volume senders with zero malicious detections in 30 days are strong candidates for scanning exceptions — they generate processing load without security benefit.
Try it yourself
The Excel attachment should arrive as a placeholder, then appear within 1-2 minutes with a clean verdict. The password-protected ZIP should be delivered without full detonation — the sandbox cannot open it. This demonstrates both the protection (dynamic delivery for analysable files) and the limitation (password-protected archives bypass sandboxing).
Try it yourself
Do not disable Safe Attachments. Instead, switch the policy from Block mode to Dynamic Delivery mode. The user receives the email body immediately and the attachment becomes available after detonation (typically 30-90 seconds). This eliminates the perceived delay while maintaining full protection.
If the user is already on Dynamic Delivery and still experiencing delays, the issue may be network latency or a specific file type that takes longer to detonate. Investigate with the EmailAttachmentInfo table to check detonation times for their recent emails. Creating per-user exceptions to security policy is almost never the correct answer.
Check your understanding
1. Why is Dynamic Delivery preferred over Block mode for most organizations?