← Back to SOC feed Coverage →

ATP policy status check

kql MEDIUM Azure-Sentinel
T1562
CloudAppEvents
backdoorhuntingmicrosoftofficial
This rule was pulled from an open-source repository and enriched with AI. Validate in a test environment before deploying to production.
View original rule at Azure-Sentinel →
Retrieved: 2026-05-09T23:00:01Z · Confidence: medium

Hunt Hypothesis

Adversaries may disable or bypass Safe Attachments and Safe Documents policies to exfiltrate malicious files through SharePoint, OneDrive, or Teams. SOC teams should proactively hunt for this behavior to identify potential exfiltration attempts and prevent data loss in their Azure Sentinel environment.

KQL Query

CloudAppEvents
| where Application == "Microsoft Exchange Online"
| where ActionType == "Set-AtpPolicyForO365"
| mv-expand ActivityObjects
| extend Name = tostring(ActivityObjects.Name)
| extend Value = tostring(ActivityObjects.Value)
| where Name in ("EnableATPForSPOTeamsODB", "EnableSafeDocs", "AllowSafeDocsOpen")
| extend packed = pack(Name, Value)
| summarize PackedInfo = make_bag(packed), ActionType = any(ActionType) by Timestamp, AccountDisplayName
| evaluate bag_unpack(PackedInfo)

Analytic Rule Definition

id: 518e6938-10ef-4165-af19-82f1287141bc
name: ATP policy status check
description: |
  This query displays the configuration auditing for 'Safe Attachments for SharePoint, OneDrive, and Microsoft Teams' and 'Safe Documents' in Microsoft Defender for Office 365.
description-detailed: |
  This query displays the configuration auditing for 'Safe Attachments for SharePoint, OneDrive, and Microsoft Teams' and 'Safe Documents' settings in Microsoft Defender for Office 365.
  Reference - https://learn.microsoft.com/en-us/defender-office-365/safe-attachments-about
requiredDataConnectors:
  - connectorId: MicrosoftThreatProtection
    dataTypes:
      - CloudAppEvents
tactics:
  - DefenseEvasion
relevantTechniques:
  - T1562
query: |
  CloudAppEvents
  | where Application == "Microsoft Exchange Online"
  | where ActionType == "Set-AtpPolicyForO365"
  | mv-expand ActivityObjects
  | extend Name = tostring(ActivityObjects.Name)
  | extend Value = tostring(ActivityObjects.Value)
  | where Name in ("EnableATPForSPOTeamsODB", "EnableSafeDocs", "AllowSafeDocsOpen")
  | extend packed = pack(Name, Value)
  | summarize PackedInfo = make_bag(packed), ActionType = any(ActionType) by Timestamp, AccountDisplayName
  | evaluate bag_unpack(PackedInfo)
version: 1.0.0

Required Data Sources

Sentinel TableNotes
CloudAppEventsEnsure this data connector is enabled

MITRE ATT&CK Context

References

False Positive Guidance

Original source: https://github.com/Azure/Azure-Sentinel/blob/main/Hunting Queries/Microsoft 365 Defender/Email and Collaboration Queries/Attachment/ATP policy status check.yaml