Sharepoint link likely unrelated to sender
Detects when a sender links to a Sharepoint file where the subdomain significantly differs from the sender's domain. The rule checks for OneNote, PDF, or unknown file types and includes various domain validation checks.
Sublime rule (View on GitHub)
1name: "Sharepoint link likely unrelated to sender"
2description: "Detects when a sender links to a Sharepoint file where the subdomain significantly differs from the sender's domain. The rule checks for OneNote, PDF, or unknown file types and includes various domain validation checks."
3type: "rule"
4severity: "medium"
5source: |
6 type.inbound
7 and (
8 any(ml.nlu_classifier(body.current_thread.text).topics,
9 .name == "File Sharing and Cloud Services" and .confidence == "high"
10 )
11 or any(ml.nlu_classifier(body.current_thread.text).intents,
12 .name == "cred_theft" and .confidence == "high"
13 )
14 )
15 and 0 < length(body.links) < 10
16 and length(body.html.display_text) < 2000
17 and any(filter(body.links, .href_url.domain.root_domain == 'sharepoint.com'),
18 // Normalize Levenshtein distance by string length (0 = identical, 0.7+ = different)
19 // Working with what we have in MQL, considering we dont have max() or any other forms of string distancing
20 (
21 (
22 strings.iends_with(.href_url.domain.subdomain,
23 '-my'
24 ) // common Sharepoint subdomain suffix
25 and (
26 (
27 strings.ilevenshtein(.href_url.domain.subdomain,
28 sender.email.domain.sld
29 ) - 3 // subtract aforementioned suffix for more accurate calculation
30 ) / (
31 (
32 (length(.href_url.domain.subdomain) - 3) + length(sender.email.domain.sld
33 )
34 + (
35 (
36 (length(.href_url.domain.subdomain) - 3) - length(sender.email.domain.sld
37 )
38 ) + (
39 length(sender.email.domain.sld) - (
40 length(.href_url.domain.subdomain) - 3
41 )
42 )
43 )
44 ) / 2.0 // to ensure we keep the result as a float
45 )
46 ) > 0.7 // customizable threshold
47 )
48 or (
49 not strings.iends_with(.href_url.domain.subdomain,
50 '-my'
51 ) // no suffix, continue with original calculation
52 and (
53 strings.ilevenshtein(.href_url.domain.subdomain,
54 sender.email.domain.sld
55 ) / (
56 (
57 length(.href_url.domain.subdomain) + length(sender.email.domain.sld
58 )
59 + (
60 (
61 length(.href_url.domain.subdomain) - length(sender.email.domain.sld
62 )
63 ) + (
64 length(sender.email.domain.sld) - length(.href_url.domain.subdomain
65 )
66 )
67 )
68 ) / 2.0 // to ensure we keep the result as a float
69 )
70 ) > 0.7 // customizable threshold
71 )
72 )
73 and not strings.icontains(.href_url.path, sender.email.local_part)
74 and not any($org_slds,
75 strings.icontains(..href_url.domain.subdomain, .)
76 )
77
78 // it is a OneNote, PDF or unknown file, or a shared folder
79 and regex.icontains(.href_url.path, '\/:[obuf]:\/(?:p|g\/personal)')
80 )
81
82 // a way to negate long threads
83 // the full thread must be less than 6 times the length of the current thread
84 and length(body.html.inner_text) < 6 * length(body.current_thread.text)
85 and sender.email.domain.root_domain not in (
86 "sharepoint.com",
87 "sharepointonline.com"
88 )
89
90 // negate highly trusted sender domains unless they fail DMARC authentication
91 and not (
92 sender.email.domain.root_domain in $high_trust_sender_root_domains
93 and coalesce(headers.auth_summary.dmarc.pass, false)
94 )
95tags:
96 - "Attack surface reduction"
97attack_types:
98 - "BEC/Fraud"
99 - "Credential Phishing"
100tactics_and_techniques:
101 - "Impersonation: Employee"
102 - "Lookalike domain"
103 - "OneNote"
104 - "PDF"
105 - "Social engineering"
106detection_methods:
107 - "URL analysis"
108 - "Sender analysis"
109 - "Header analysis"
110 - "HTML analysis"
111id: "6870f489-5581-53f0-a6f7-a03e259fb073"
Related rules
- BEC/Fraud: Fake investment outreach from suspicious senders
- Service abuse: CrossTenant Microsoft notification with link
- Attachment: ICS calendar invite with encoded recipient in link
- Reconnaissance: Email address harvesting attempt
- Reconnaissance: Empty subject with mismatched reply-to from new sender