8.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"] |
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?