This article describes how to configure Microsoft Defender and related Microsoft 365 controls to protect files in SharePoint Online, OneDrive, and Teams in a tenant that uses eSHARE, and how each control interacts with eSHARE. It is written for Microsoft 365 administrators and security teams. The following sections will be reviewed:
REQUIREMENT:
The person performing these steps must be a Global Administrator or Security Administrator for the Defender and Entra settings, a SharePoint Administrator for the tenant settings, and an eSHARE administrator for Sharing Policy changes. eSHARE must already be connected to Microsoft 365.
Overview
Protecting files in Microsoft 365 takes five layers of controls working together, and several important settings are off or permissive by default. No single layer is enough on its own. Malware scanning, for example, does nothing to stop a compromised account from downloading an entire site.
eSHARE keeps shared content inside your Microsoft 365 tenant, so the Microsoft controls below continue to protect it. Some controls, however, only apply to users signed in to your tenant and don't reach external recipients. eSHARE's Sharing Policies cover that part.
Layer | What it protects against | Primary Microsoft control | What eSHARE adds |
|---|---|---|---|
1. Built-in antivirus | Known malware uploaded to libraries | SharePoint Online virus scanning | Upload file-type restrictions on Trusted Shares |
2. Defender for Office 365 | Unknown and zero-day malware, malicious links in documents | Safe Attachments, Safe Documents, Safe Links | Download controls for external recipients, who aren't covered by Safe Links or Safe Documents |
3. Defender for Cloud Apps | Oversharing, risky downloads, anomalous user behavior | File policies, session controls, anomaly detection | Governed external sharing with expiry, approval, and an audit trail |
4. Identity and endpoint | Compromised accounts and unmanaged devices | Conditional Access, Entra ID Protection, Defender for Endpoint | Recipient verification on every access; SSO for internal users |
5. Data protection | Sensitive content leaving the organization | Purview sensitivity labels, DLP, SharePoint sharing settings | Label-based Sharing Policies and Purview DLP applied to Trusted Shares |
How eSHARE Fits into Your Defender Configuration
Keep these points in mind as you work through the layers:
Files stay in Microsoft 365. Content shared through a Trusted Share remains in its SharePoint, OneDrive, or Teams library. Files that external recipients upload to a Trusted Share are written to the same library, where Microsoft's malware scanning applies to them like any other file.
eSHARE connects as an application, not a user. eSHARE reaches your content through the eSHARE app registration in Entra ID, using application permissions and a certificate. User-targeted Conditional Access policies and SharePoint's unmanaged-device setting don't apply to these sign-ins. Conditional Access for workload identities can, as described in Layer 4.
External recipients aren't users in your tenant. Controls that depend on a signed-in, licensed user in your organization don't protect them: Safe Links for Office apps, Safe Documents, device-based Conditional Access, and Defender for Endpoint. Use the download, watermark, and upload controls in your eSHARE Sharing Policies for this audience.
External access doesn't require guest accounts or Anyone links. Recipients reach content through the Trusted Share, so you can keep SharePoint's native external sharing restricted.
Licensing Requirements
Microsoft 365 E5 includes every Microsoft control in this article. Lower tiers get the baseline plus any add-ons you have purchased, so confirm your entitlements before you plan the rollout.
Capability | Included with |
|---|---|
Built-in antivirus, DisallowInfectedFileDownload | All plans that include SharePoint Online |
Safe Attachments for SharePoint, OneDrive, and Teams; Safe Links | Defender for Office 365 Plan 1 or Plan 2 (included in E5) |
Safe Documents | Microsoft 365 E5, E5 Security, or A5 |
Threat Explorer, Automated Investigation and Response (AIR) | Defender for Office 365 Plan 2 (included in E5) |
File policies, session controls, anomaly detection | Defender for Cloud Apps (included in E5) |
Device-based access, endpoint protection for synced files | Defender for Endpoint, Intune (included in E5) |
Risk-based Conditional Access for users | Entra ID P2 (included in E5) |
Conditional Access for workload identities (such as the eSHARE app) | Microsoft Entra Workload ID Premium (separate add-on) |
Auto-labeling, DLP for SharePoint, Insider Risk Management | Microsoft Purview (included in E5) |
Note:
Microsoft changes licensing bundles and default settings periodically. Check current Microsoft documentation for your SKUs. This article was last verified against Microsoft documentation in November 2026.
Layer 1: Built-in Antivirus
Microsoft 365 scans files in SharePoint, OneDrive, and Teams with a common antivirus engine on every plan. Scanning is asynchronous, so it happens some time after upload. By default, users can still download a file flagged as malware after clicking through a warning. Block this:
Connect-SPOService -Url https://<tenant>-admin.sharepoint.com
Set-SPOTenant -DisallowInfectedFileDownload $trueWith this set, users can't open, sync, or download detected files, even from the warning dialog. Administrators can still retrieve them for investigation, so limit who holds those roles.
With eSHARE
Files that external recipients upload to a Trusted Share are stored in your library and scanned like any other upload.
Reduce what can be uploaded in the first place. In your Sharing Policies, use 'Control Upload File Types' to block executables, scripts, and other file types your business doesn't exchange with outside parties.
After you change the setting, test it end to end. Upload the industry-standard EICAR test file to a pilot Trusted Share and confirm that internal users and recipients can't open or download it.
Layer 2: Defender for Office 365
Safe Attachments for SharePoint, OneDrive, and Teams
Safe Attachments adds sandbox detonation on top of signature scanning, catching malware the built-in engine misses. Turn it on and verify it explicitly rather than assuming it is on by default. Enable it in the Defender portal under 'Email & collaboration' > 'Policies & rules' > 'Threat policies' > 'Safe Attachments' > 'Global settings', or with PowerShell:
Connect-ExchangeOnline
Set-AtpPolicyForO365 -EnableATPForSPOTeamsODB $trueKeep three behaviors in mind:
Not every file is scanned, and scanning is asynchronous. Treat this as risk reduction, not a guarantee.
Detected files are locked from opening, moving, copying, and sharing. Users can still download them unless DisallowInfectedFileDownload (Layer 1) is set.
Detected files go to an admin-only quarantine. Grant quarantine release rights to a small, named security role rather than to Global Administrators.
Safe Documents
Safe Documents scans Office files opened in Protected View before editing is allowed. Disable the bypass so users can't open a file before the scan finishes:
Set-AtpPolicyForO365 -EnableSafeDocs $true -AllowSafeDocsOpen $falseSafe Links for Office apps
Make sure your Safe Links policies cover Office apps, not just email. Links in Word, Excel, and PowerPoint files then get a time-of-click check when a licensed user in your organization, signed in with a work account, clicks them in a supported Office app. The Built-in protection preset policy provides this for licensed users who aren't in another Safe Links policy. The Standard or Strict preset policy is the simplest way to apply stricter settings consistently.
Automated Investigation and Response and Threat Explorer (Plan 2)
When a file is flagged, AIR investigates related activity and proposes remediation. Decide in advance who approves pending actions. Use Threat Explorer's malware view, filtered to SharePoint, OneDrive, and Teams, to see who uploaded a file and where it spread.
With eSHARE
Safe Links and Safe Documents protect your internal users only. External recipients who open or download files from a Trusted Share aren't covered.
For sensitive content, configure your Sharing Policies so recipients view and edit online, or use 'Download with Approval' or 'Download with Protection' instead of unrestricted download.
Add user or brand watermarks to discourage onward distribution of downloaded files.
Layer 3: Defender for Cloud Apps
Use Defender for Cloud Apps to control how clean files are shared and downloaded; malware scanning doesn't address oversharing or data theft. Every file policy should have a governance action, not just an alert.
Connect the Microsoft 365 app connector so file inventory and activity logs flow into Defender for Cloud Apps.
Create file policies for risky exposure, with governance actions attached:
Files shared publicly or with Anyone links: remove the public link.
Labeled or sensitive files shared with external users: remove external collaborators or notify the owner.
Files shared with personal email domains: remove the share and notify the owner.
Add session policies through Conditional Access App Control to block or label downloads from unmanaged devices. A matching Entra Conditional Access policy must route SharePoint through App Control, or the session policy never applies.
Tune anomaly detection policies, including mass download, ransomware activity, unusual file deletion, and unusual file sharing. Route their alerts to your SOC queue.
With eSHARE
The file policies above target native SharePoint and OneDrive sharing. External access through Trusted Shares is governed by your eSHARE Sharing Policies (permissions, expiry, recipient verification) and recorded in the eSHARE audit trail.
If you route traffic through a CASB, proxy, or firewall, allowlist the eSHARE service URLs listed in Setup Information and Pre-requisites.
Layer 4: Identity and Endpoint
Gate file access on account risk and device health. Compromised accounts are a more common route to mass data loss than malicious files.
Risk-based Conditional Access (Entra ID P2). Block access or require strong reauthentication when sign-in or user risk is high.
Compliant devices for full access. Require devices to be Intune-compliant or onboarded to Defender for Endpoint before granting full SharePoint access.
Limited access for unmanaged devices. Give everything else browser-only access with no download, print, or sync. When you set this with PowerShell, you must also create an Entra Conditional Access policy for Office 365 SharePoint Online that uses the 'Use app enforced restrictions' session control; the SharePoint setting alone doesn't enforce anything.
Set-SPOTenant -ConditionalAccessPolicy AllowLimitedAccessEndpoint protection for synced files. The OneDrive sync client copies files to the device, where Defender for Endpoint becomes the last line of defense. Make sure every device that can sync is onboarded.
With eSHARE
Include the eSHARE single sign-on app in your user policies. Internal users sign in to eSHARE through the eSHARE enterprise application in Entra ID. Target it with the same MFA and risk-based Conditional Access policies you use for Microsoft 365.
Apply Conditional Access for workload identities to the eSHARE app registration if you have it. User-targeted policies don't apply to the app's sign-ins. With Workload ID Premium, you can block the app's sign-ins when Entra ID Protection flags the service principal as risky, or when it signs in from outside approved locations. Assign the policy directly to the eSHARE service principal, start in 'Report-only' mode, and contact eSHARE Support before you enforce a location-based policy.
Use least-privilege site access. If eSHARE only needs specific sites, use the Sites.Selected model so the app can reach only those sites.
Protect the app registration. Keep the list of app owners short, store the certificate's private key securely, rotate the certificate before it expires, and review the service principal sign-in logs.
Layer 5: Data Protection and Sharing Settings
Pair Defender with Purview and tight SharePoint sharing defaults so sensitive content is classified and restricted wherever it goes. Defender for Cloud Apps can act on sensitivity labels, so the two layers reinforce each other.
Sensitivity labels with auto-labeling. Classify content automatically rather than relying on users to label it.
DLP policies for SharePoint and OneDrive. Block external sharing of highly confidential content and notify the file owner.
Insider Risk Management. Detect patterns such as a departing employee downloading large volumes of files.
Sharing defaults. Default to Specific people links, make Anyone links expire, and restrict external sharing per site based on sensitivity.
Guest access reviews. Review external guests regularly and remove those who no longer need access.
With eSHARE
Map your sensitivity labels to eSHARE Sharing Policies so labeled content is shared with the right permissions, expiry, and download controls automatically.
eSHARE reads Microsoft Purview DLP events so your DLP policies also apply to Trusted Shares.
Because Trusted Shares don't depend on guest accounts or Anyone links, you can keep native external sharing restricted on sensitive sites and route external collaboration through eSHARE. With the Secure Collaboration Gateway, native SharePoint, OneDrive, and Teams links pasted into outbound email are converted to Trusted Share links automatically.
Monitoring, Alerting, and Response
Send every file-related detection to a monitored queue; a detection nobody reviews provides no protection.
Create an alert policy for malware detected in libraries, in the Defender portal under 'Email & collaboration' > 'Policies & rules' > 'Alert policy', or with Security & Compliance PowerShell:
Connect-IPPSSession
New-ProtectionAlert -Name "Malicious Files in Libraries" -Category ThreatManagement `
-ThreatType Activity -Operation FileMalwareDetected -AggregationType None `
-Severity High -NotifyUser secops@yourdomain.comUnified audit logging must be on. Every investigation below depends on it.
Threat protection status report. Use 'View data by' > 'Content' > 'Malware' to track detections in SharePoint, OneDrive, and Teams over time.
Advanced hunting in Defender XDR. Build custom detections on the CloudAppEvents table, such as unusual download or sharing-link volume from one user, and correlate them with sign-in risk.
eSHARE audit trail. Use the eSHARE audit trail alongside the Microsoft 365 audit log to see which external recipients accessed, downloaded, or uploaded content through Trusted Shares.
Testing. Validate detection with the benign EICAR test file in a non-production site, never with real malware.
Verify Your Configuration
Run this read-only check monthly and after any tenant change to confirm settings haven't drifted.
# Defender for Office 365
Connect-ExchangeOnline
Get-AtpPolicyForO365 | Format-List EnableATPForSPOTeamsODB, EnableSafeDocs, AllowSafeDocsOpen
# Alert policies
Connect-IPPSSession
Get-ProtectionAlert | Where-Object Operation -contains "FileMalwareDetected" | Format-List Name, NotifyUser, Disabled
# SharePoint Online
Connect-SPOService -Url https://<tenant>-admin.sharepoint.com
Get-SPOTenant | Format-List DisallowInfectedFileDownload, ConditionalAccessPolicy, SharingCapability, `
DefaultSharingLinkType, RequireAnonymousLinksExpireInDaysSetting | Expected value |
|---|---|
EnableATPForSPOTeamsODB | True |
EnableSafeDocs | True (E5, E5 Security, or A5) |
AllowSafeDocsOpen | False |
DisallowInfectedFileDownload | True |
ConditionalAccessPolicy | AllowLimitedAccess (or BlockAccess), with a matching Entra Conditional Access policy |
DefaultSharingLinkType | Direct (Specific people) |
RequireAnonymousLinksExpireInDays | A set value, such as 30 or fewer, if Anyone links are allowed |
Common Gaps
The most frequent gaps are controls that are licensed but not enforcing anything. They pass a license audit and provide no protection.
Safe Documents is licensed but never enabled.
DisallowInfectedFileDownload is left at its permissive default.
AIR remediation actions pile up unapproved.
Defender for Cloud Apps file policies alert but have no governance actions.
Session policies exist, but no Conditional Access policy routes SharePoint through App Control.
AllowLimitedAccess is set in SharePoint, but no Entra Conditional Access policy uses app-enforced restrictions.
Safe Links and Safe Documents are assumed to protect external recipients. They don't; eSHARE Sharing Policies do.
User Conditional Access policies are assumed to cover the eSHARE app registration. They don't; use workload identity policies.
Rollout Checklist
Work through these in order. The first group closes the largest gaps with the least effort.
Set DisallowInfectedFileDownload to true.
Enable Safe Attachments for SharePoint, OneDrive, and Teams.
Enable Safe Documents with AllowSafeDocsOpen set to false.
Confirm Safe Links covers Office apps (Built-in protection, Standard, or Strict preset policy).
Create the FileMalwareDetected alert policy and route it to the SOC.
Confirm unified audit logging is on.
Restrict upload file types in eSHARE Sharing Policies and test with the EICAR file in a pilot Trusted Share.
Review download, watermark, and expiry settings in eSHARE Sharing Policies.
Connect the Microsoft 365 app connector in Defender for Cloud Apps.
Create file policies with governance actions for public and external sharing.
Configure session policies and the Conditional Access policy that routes SharePoint through App Control.
Require compliant devices and set limited access for unmanaged devices, with the matching Conditional Access policy.
Enable risk-based Conditional Access and include the eSHARE SSO app.
Review the eSHARE app registration: owners, certificate, permissions model, and workload identity policies.
Deploy Purview auto-labeling and DLP, and map labels to eSHARE Sharing Policies.
Tighten native sharing defaults and schedule guest access reviews.
Assign AIR approvers and quarantine release roles.
Schedule the monthly configuration check.
Related Topics
Microsoft