Brand impersonation: Sharepoint fake file share
This rule detects messages impersonating a Sharepoint file sharing email where no links point to known Microsoft domains.
Sublime rule (View on GitHub)
1name: "Brand impersonation: Sharepoint fake file share"
2description: |
3 This rule detects messages impersonating a Sharepoint file sharing email where no links point to known Microsoft domains.
4type: "rule"
5severity: "medium"
6source: |
7 type.inbound
8
9 // Sharepoint body content looks like this
10 and (
11 (
12 (
13 any([body.current_thread.text, body.plain.raw],
14 strings.ilike(.,
15 "*shared a file with you*",
16 "*shared with you*",
17 "*invited you to access a file*",
18 "*received a document*",
19 "*shared a document*",
20 "*shared a new document*",
21 "*shared this document*"
22 )
23 )
24 or any(beta.ml_topic(body.current_thread.text).topics,
25 .name == "File Sharing and Cloud Services"
26 and .confidence == "high"
27 )
28 or any(file.explode(beta.message_screenshot()),
29 strings.ilike(.scan.ocr.raw,
30 "*shared a file with you*",
31 "*shared with you*",
32 "*invited you to access a file*",
33 "*received a document*",
34 "*shared a document*",
35 "*shared a new document*",
36 "*shared this document*"
37 )
38 or any(beta.ml_topic(.scan.ocr.raw).topics,
39 .name == "File Sharing and Cloud Services"
40 and .confidence == "high"
41 )
42 )
43 )
44 and (
45 strings.ilike(subject.subject,
46 "*shared*",
47 "*updated*",
48 "*sign*",
49 "*review*",
50 "*scanned*"
51 )
52 or strings.ilike(subject.subject,
53 "*Excel*",
54 "*SharePoint*",
55 "*PowerPoint*",
56 "*OneNote*"
57 )
58 or strings.ilike(sender.display_name,
59 "*Excel*",
60 "*SharePoint*",
61 "*PowerPoint*",
62 "*OneNote*"
63 )
64 or any(body.links, strings.icontains(.display_text, "OPEN DOCUMENT"))
65 or subject.subject is null
66 or subject.subject == ""
67 // the org as determined by NLU is in the subject
68 or any(ml.nlu_classifier(body.current_thread.text).entities,
69 .name == "org" and strings.icontains(subject.subject, .text)
70 )
71 )
72 )
73 or any([
74 "Contigo", // Spanish
75 "Avec vous", // French
76 "Mit Ihnen", // German
77 "Con te", // Italian
78 "Com você", // Portuguese
79 "Met u", // Dutch
80 "С вами", // Russian
81 "与你", // Chinese (Simplified)
82 "與您", // Chinese (Traditional)
83 "あなたと", // Japanese
84 "당신과", // Korean
85 "معك", // Arabic
86 "آپ کے ساتھ", // Urdu
87 "আপনার সাথে", // Bengali
88 "आपके साथ", // Hindi
89 "Sizinle", // Turkish // Azerbaijani
90 "Med dig", // Swedish
91 "Z tobą", // Polish
92 "З вами", // Ukrainian
93 "Önnel", // Hungarian
94 "Μαζί σας", // Greek
95 "איתך", // Hebrew
96 "กับคุณ", // Thai
97 "Với bạn", // Vietnamese
98 "Dengan Anda", // Indonesian // Malay
99 "Nawe", // Swahili
100 "Cu dumneavoastră", // Romanian
101 "S vámi", // Czech
102 "Med deg", // Norwegian
103 "S vami", // Slovak
104 "Med dig", // Danish
105 "Amb vostè", // Catalan
106 "Teiega", // Estonian
107 "S vama", // Serbian
108 ],
109 strings.icontains(subject.subject, .)
110 )
111 )
112
113 // contains logic that impersonates Microsoft
114 and (
115 any(ml.logo_detect(beta.message_screenshot()).brands,
116 strings.starts_with(.name, "Microsoft")
117 )
118 or any(attachments,
119 .file_type in $file_types_images
120 and any(ml.logo_detect(.).brands,
121 strings.starts_with(.name, "Microsoft")
122 )
123 )
124 or regex.icontains(body.html.raw,
125 '<table[^>]*>\s*<tbody[^>]*>\s*<tr[^>]*>\s*(<td[^>]*bgcolor="#[0-9A-Fa-f]{6}"[^>]*>\s* \s*</td>\s*){2}\s*</tr>\s*<tr[^>]*>\s*(<td[^>]*bgcolor="#[0-9A-Fa-f]{6}"[^>]*>\s* \s*</td>\s*){2}'
126 )
127 or 3 of (
128 regex.icontains(body.html.raw, '.password-expiration'),
129 regex.icontains(body.html.raw, 'color: #2672ec;'),
130 regex.icontains(body.html.raw, 'Microsoft')
131 )
132 or 4 of (
133 regex.icontains(body.html.raw, 'rgb\(246,\s?93,\s?53\)'),
134 regex.icontains(body.html.raw, 'rgb\(129,\s?187,\s?5\)'),
135 regex.icontains(body.html.raw, 'rgb\(4,\s?165,\s?240\)'),
136 regex.icontains(body.html.raw, 'rgb\(255,\s?186,\s?7\)'),
137 )
138 or 4 of (
139 regex.icontains(body.html.raw,
140 '(background-color:|background:|bgcolor=)(.)red'
141 ),
142 regex.icontains(body.html.raw, 'rgb\(19,\s?186,\s?132\)'),
143 regex.icontains(body.html.raw, 'rgb\(4,\s?166,\s?240\)'),
144 regex.icontains(body.html.raw, 'rgb\(255,\s?186,\s?8\)'),
145 )
146 or 4 of (
147 regex.icontains(body.html.raw, 'rgb\(245,\s?189,\s?67\)'),
148 regex.icontains(body.html.raw, 'rgb\(137,\s?184,\s?57\)'),
149 regex.icontains(body.html.raw, 'rgb\(217,\s?83,\s?51\)'),
150 regex.icontains(body.html.raw, 'rgb\(71,\s?160,\s?218\)')
151 )
152 or 4 of (
153 regex.icontains(body.html.raw, 'rgb\(73,\s?161,\s?232\)'),
154 regex.icontains(body.html.raw, 'rgb\(224,\s?92,\s?53\)'),
155 regex.icontains(body.html.raw, 'rgb\(139,\s?183,\s?55\)'),
156 regex.icontains(body.html.raw, 'rgb\(244,\s?188,\s?65\)')
157 )
158 or 4 of (
159 regex.icontains(body.html.raw, 'rgb\(213,\s?56,\s?62\)'),
160 regex.icontains(body.html.raw, 'rgb\(0,\s?114,\s?30\)'),
161 regex.icontains(body.html.raw, 'rgb\(0,\s?110,\s?173\)'),
162 regex.icontains(body.html.raw, 'rgb\(227,\s?209,\s?43\)'),
163 )
164 or 4 of (
165 regex.icontains(body.html.raw, 'rgb\(246,\s?93,\s?53\)'),
166 regex.icontains(body.html.raw, 'rgb\(129,\s?187,\s?5\)'),
167 regex.icontains(body.html.raw, 'rgb\(4,\s?165,\s?240\)'),
168 regex.icontains(body.html.raw, 'rgb\(255,\s?186,\s?7\)')
169 )
170 or 4 of (
171 regex.icontains(body.html.raw, 'rgb\(242,\s?80,\s?34\)'),
172 regex.icontains(body.html.raw, 'rgb\(127,\s?186,\s?0\)'),
173 regex.icontains(body.html.raw, 'rgb\(0,\s?164,\s?239\)'),
174 regex.icontains(body.html.raw, 'rgb\(255,\s?185,\s?0\)'),
175 )
176 or 4 of (
177 regex.icontains(body.html.raw, 'rgb\(243,\s?83,\s?37\)'),
178 regex.icontains(body.html.raw, 'rgb\(129,\s?188,\s?6\)'),
179 regex.icontains(body.html.raw, 'rgb\(5,\s?166,\s?240\)'),
180 regex.icontains(body.html.raw, 'rgb\(255,\s?186,\s?8\)')
181 )
182 or 4 of (
183 regex.icontains(body.html.raw, 'rgb\(243,\s?80,\s?34\)'),
184 regex.icontains(body.html.raw, 'rgb\(128,\s?187,\s?3\)'),
185 regex.icontains(body.html.raw, 'rgb\(3,\s?165,\s?240\)'),
186 regex.icontains(body.html.raw, 'rgb\(255,\s?185,\s?3\)')
187 )
188 or 4 of (
189 regex.icontains(body.html.raw,
190 '(background-color:|background:|bgcolor=)(.)?(#)?(FF1940|eb5024|F25022|FF1941|red)'
191 ),
192 regex.icontains(body.html.raw,
193 '(background-color:|background:|bgcolor=)(.)?(#)?(36ba57|3eb55d|7db606|7FBA00|36ba58|green)'
194 ),
195 regex.icontains(body.html.raw,
196 '(background-color:|background:|bgcolor=)(.)?#(04a1d6|04B5F0|05a1e8|00A4EF|01a4ef|04a5f0)'
197 ),
198 regex.icontains(body.html.raw,
199 '(background-color:|background:|bgcolor=)(.)?#(FFCA07|f7b408|FFB900|FFCA08|ffb901|ffba07)'
200 ),
201 )
202 or 4 of (
203 regex.icontains(body.html.raw,
204 '(background-color:|background:|bgcolor=)(.)?#(f65314|f65d35|49a1e8|E74F23|F35325)'
205 ),
206 regex.icontains(body.html.raw,
207 '(background-color:|background:|bgcolor=)(.)?#(7cbf42|81bb05|e05c35|7AB206|81BC06)'
208 ),
209 regex.icontains(body.html.raw,
210 '(background-color:|background:|bgcolor=)(.)?#(00a4ef|0078d7|8bb737|04a5f0|059EE4|05A6F0)'
211 ),
212 regex.icontains(body.html.raw,
213 '(background-color:|background:|bgcolor=)(.)?#(ffb900|ffba07|f4bc41|F2B108|FFBA08)'
214 ),
215 )
216 // fuzzy approach
217 or 4 of (
218 regex.icontains(body.html.raw,
219 'rgb\((2[1-4][0-9]|250),\s?(7[0-9]|8[0-9]|9[0-3]),\s?(3[0-9]|4[0-9]|5[0-3])\)'
220 ),
221 regex.icontains(body.html.raw,
222 'rgb\((12[0-9]|13[0-9]),\s?(18[0-9]|190),\s?([0-9]|10)\)'
223 ),
224 regex.icontains(body.html.raw,
225 'rgb\(([0-9]|1[0-5]),\s?(16[0-5]|166),\s?(23[0-9]|240)\)'
226 ),
227 regex.icontains(body.html.raw,
228 'rgb\((25[0-5]),\s?(18[5-9]|19[0-9]),\s?([0-9]|10)\)'
229 )
230 )
231 or 4 of (
232 regex.icontains(body.html.raw, 'rgb\((25[0-5]),\s?(2[0-5]),\s?(6[0-4])\)'),
233 regex.icontains(body.html.raw, 'rgb\((6[0-2]),\s?(18[0-1]),\s?(9[0-3])\)'),
234 regex.icontains(body.html.raw, 'rgb\(([0-4]),\s?(18[0-1]),\s?(24[0])\)'),
235 regex.icontains(body.html.raw, 'rgb\((25[0-5]),\s?(20[0-2]),\s?([0-7])\)')
236 )
237 or (
238 any(recipients.to,
239 strings.icontains(body.current_thread.text,
240 strings.concat(.email.domain.sld,
241 " shared a file with you"
242 )
243 )
244 )
245 )
246 or (
247 any(recipients.to,
248 strings.icontains(body.current_thread.text,
249 strings.concat("This link will work for ",
250 .email.email
251 )
252 )
253 )
254 )
255 // contains HTML and wording from the sharepoint template
256 or (
257 (
258 //
259 // This rule makes use of a beta feature and is subject to change without notice
260 // using the beta feature in custom rules is not suggested until it has been formally released
261 //
262
263 // alt text for the global icon
264 length(html.xpath(body.html, '//img[@alt="permission globe icon"]').nodes) > 0
265 // reference to the global icon id
266 or length(html.xpath(body.html, '//img[@id="Picture_x0020_1"]').nodes) > 0
267 // a comment reference the globe icon
268 or strings.icontains(body.html.raw,
269 ' <!-- Permission globe icon placeholder -->'
270 )
271 )
272 // the wording from the sharepoint share
273 and strings.contains(body.current_thread.text,
274 'This invite will only work for you and people with existing access'
275 )
276 )
277 or any(html.xpath(body.html,
278 "//*[contains(translate(@style, 'ABCDEF', 'abcdef'), 'color:#605e5c')]"
279 ).nodes,
280 .display_text =~ "Privacy Statement"
281 )
282 or 2 of (
283 strings.icontains(body.current_thread.text,
284 'Microsoft respects your privacy'
285 ),
286 strings.icontains(body.current_thread.text,
287 'please read our Privacy Statement'
288 ),
289 strings.icontains(body.current_thread.text,
290 'Microsoft Corporation, One Microsoft Way, Redmond, WA 98052'
291 ),
292 )
293 )
294
295 // Negate messages when the message-id indciates the message is from MS actual. DKIM/SPF domains can be custom and therefore are unpredictable.
296 and not (
297 strings.starts_with(headers.message_id, '<Share-')
298 and strings.ends_with(headers.message_id, '@odspnotify>')
299 )
300
301 // fake Sharepoint shares are easy to identify if there are any links
302 // that don't point to microsoft[.]com or *.sharepoint[.]com
303 and not all(body.links,
304 .href_url.domain.root_domain in (
305 "1drv.ms",
306 "aka.ms",
307 "microsoft.com",
308 "sharepoint.com"
309 )
310 )
311 // if there is a Sharepoint link, ensure the link doesn't match any org SLDs
312 and not any(body.links,
313 (.href_url.domain.root_domain == "sharepoint.com"
314 and any($org_slds, . == ..href_url.domain.subdomain))
315 or .href_url.domain.domain in $tenant_domains
316 )
317 and sender.email.domain.root_domain not in $org_domains
318 and sender.email.domain.root_domain not in (
319 "bing.com",
320 "microsoft.com",
321 "microsoftonline.com",
322 "microsoftsupport.com",
323 "microsoft365.com",
324 "office.com",
325 "onedrive.com",
326 "sharepointonline.com",
327 "yammer.com",
328 // ignore microsoft privacy statement links
329 "aka.ms"
330 )
331
332 and not (
333 (
334 (
335 strings.istarts_with(subject.subject, "RE:")
336 or strings.istarts_with(subject.subject, "R:")
337 or strings.istarts_with(subject.subject, "ODG:")
338 or strings.istarts_with(subject.subject, "答复:")
339 or strings.istarts_with(subject.subject, "AW:")
340 or strings.istarts_with(subject.subject, "TR:")
341 or strings.istarts_with(subject.subject, "FWD:")
342 or regex.imatch(subject.subject, '(\[[^\]]+\]\s?){0,3}(re|fwd?)\s?:')
343 or regex.imatch(subject.subject,
344 '^\[?(EXT|EXTERNAL)\]?[: ]\s*(RE|FWD?|FW|AW|TR|ODG|答复):.*'
345 )
346 )
347 and (
348 (
349 length(headers.references) > 0
350 or headers.in_reply_to is not null
351 )
352 // ensure that there are actual threads
353 and (
354 length(body.previous_threads) > 0
355 or (length(body.html.display_text) - length(body.current_thread.text)) > 200
356 )
357 )
358 )
359 )
360
361 // negate highly trusted sender domains unless they fail DMARC authentication
362 and (
363 (
364 sender.email.domain.root_domain in $high_trust_sender_root_domains
365 and not headers.auth_summary.dmarc.pass
366 )
367 or sender.email.domain.root_domain not in $high_trust_sender_root_domains
368 )
369 and (
370 profile.by_sender().solicited == false
371 or profile.by_sender_email().prevalence == "new"
372 or profile.by_sender_email().days_since.last_contact > 30
373 or (
374 profile.by_sender().any_messages_malicious_or_spam
375 and not profile.by_sender().any_messages_benign
376 )
377 // or it's a spoof of the org_domain
378 or (
379 sender.email.domain.domain in $org_domains
380 and not (
381 headers.auth_summary.spf.pass
382 or coalesce(headers.auth_summary.dmarc.pass, false)
383 )
384 )
385 )
386 and not profile.by_sender().any_messages_benign
387
388attack_types:
389 - "Credential Phishing"
390 - "Malware/Ransomware"
391detection_methods:
392 - "Content analysis"
393 - "Header analysis"
394 - "URL analysis"
395 - "Computer Vision"
396tactics_and_techniques:
397 - "Impersonation: Brand"
398 - "Social engineering"
399id: "ff8b296b-aa0d-5df0-b4d2-0e599b688f6a"