Query Details
// Rule : M365 - SharePoint / OneDrive Anonymous Sharing Link Created for Sensitive File
// Severity: High
// Tactics : Exfiltration, Collection
// MITRE : T1567.002 (Exfiltration Over Web Service: Exfiltration to Cloud Storage),
// T1078.004
// Freq : PT1H Period: PT1H
// Description: Detects creation of anonymous sharing links (Anyone links) on files
// that carry a sensitivity label of Confidential or higher, or that reside
// in sites flagged as sensitive.
//==========================================================================================
let LookbackPeriod = 1h;
let SensitiveLabels = dynamic([
"Confidential", "Highly Confidential", "Top Secret", "Restricted"
]);
let SensitiveSitePatterns = dynamic([
"hr", "legal", "finance", "exec", "security", "payroll", "board"
]);
OfficeActivity
| where TimeGenerated > ago(LookbackPeriod)
| where RecordType in ("SharePoint", "OneDrive")
| where Operation in (
"AnonymousLinkCreated", "SharingLinkCreated",
"AddedToSecureLink", "SecureLinkUsed")
| extend
SharingType = tostring(parse_json(EventData).SharingType),
LinkScope = tostring(parse_json(EventData).LinkScope),
TargetUserOrGroup = tostring(parse_json(EventData).TargetUserOrGroup),
SiteLower = tolower(SiteUrl)
| extend
IsAnonymous = (SharingType == "AnonymousAccess" or LinkScope == "Anyone"),
IsSensitiveSite = SiteLower has_any (SensitiveSitePatterns)
| where IsAnonymous or IsSensitiveSite
| project
TimeGenerated,
UserId,
ClientIP,
SourceFileName,
SiteUrl,
ObjectId,
Operation,
SharingType,
TargetUserOrGroup,
IsAnonymous,
IsSensitiveSite,
AlertSeverity = case(
IsAnonymous and IsSensitiveSite, "Critical",
IsAnonymous, "High",
"Medium")
This query is designed to detect potentially risky activities in Microsoft 365, specifically focusing on SharePoint and OneDrive. It looks for the creation of anonymous sharing links (also known as "Anyone links") for files that are either labeled as sensitive (such as "Confidential" or higher) or are located in sites considered sensitive (like HR, legal, or finance sites). The query checks activities from the past hour and flags them based on their risk level:
The query outputs details such as the time of the activity, user ID, client IP, file name, site URL, and the severity of the alert.

David Alonso
Released: March 18, 2026
Tables
Keywords
Operators