Brand impersonation: Microsoft with embedded logo and credential theft language

This rule detects messages impersonating Microsoft via a logo and contains credential theft language. From a new and unsolicited sender.

Sublime rule (View on GitHub)

  1name: "Brand impersonation: Microsoft with embedded logo and credential theft language"
  2description: "This rule detects messages impersonating Microsoft via a logo and contains credential theft language. From a new and unsolicited sender."
  3type: "rule"
  4severity: "high"
  5source: |
  6  type.inbound
  7  and (
  8    (
  9      length(attachments) > 0
 10      and all(attachments,
 11              .file_type in $file_types_images or .file_type == "pdf"
 12      )
 13    )
 14    or length(attachments) == 0
 15  )
 16  and any(ml.logo_detect(file.message_screenshot()).brands,
 17          strings.starts_with(.name, "Microsoft")
 18  )
 19  and (
 20    any(ml.nlu_classifier(body.current_thread.text).intents,
 21        .name == "cred_theft" and .confidence in ("medium", "high")
 22    )
 23    or (
 24      length(body.current_thread.text) == 0
 25      //
 26      // This rule makes use of a beta feature and is subject to change without notice
 27      // using the beta feature in custom rules is not suggested until it has been formally released
 28      //
 29      and any(ml.nlu_classifier(beta.ocr(file.message_screenshot()).text).intents,
 30              .name == "cred_theft" and .confidence in ("medium", "high")
 31      )
 32    )
 33  )
 34  and (
 35    not (
 36      headers.auth_summary.dmarc.pass
 37      and headers.auth_summary.dmarc.details.from.domain in (
 38        "azureadnotifications.us",
 39        "microsoft.com",
 40        "sharepointonline.com",
 41        "cloudappsecurity.com",
 42        "microsoftsupport.com",
 43        "microsoft.onmicrosoft.com",
 44        "yammer.com"
 45      )
 46    )
 47    or headers.auth_summary.dmarc.pass is null
 48    or headers.auth_summary.dmarc.details.from.domain is null
 49  )
 50  and not (
 51    sender.email.domain.domain == "planner.office365.com"
 52    and headers.return_path.email == "noreply@planner.office365.com"
 53    and headers.auth_summary.dmarc.details.from.root_domain == "office365.com"
 54  )
 55  
 56  // Microsoft has some legit onmicrosoft domains...
 57  and not (
 58    sender.email.domain.domain == "microsoft.onmicrosoft.com"
 59    and headers.auth_summary.spf.pass
 60    and all(body.links, .href_url.domain.root_domain == "microsoft.com")
 61  )
 62  
 63  // message is not from sharepoint actual (additional check in case DMARC check above fails to bail out)
 64  and not (
 65    (
 66      strings.ilike(headers.message_id,
 67                    '<Share-*',
 68                    '<MassDelete-*',
 69                    '<FileDeleteAfterExpiration-*',
 70                    '<NotifyOwnerSharedWithExternalUsers*',
 71                    '<OneTimePasscode*'
 72      )
 73      and strings.ends_with(headers.message_id, '@odspnotify>')
 74    )
 75    or (
 76      any(headers.hops,
 77          any(.fields,
 78              .name == "X-Google-Original-Message-ID"
 79              and strings.ilike(.value,
 80                                '<Share-*',
 81                                '<MassDelete-*',
 82                                '<FileDeleteAfterExpiration-*',
 83                                '<NotifyOwnerSharedWithExternalUsers*',
 84                                '<OneTimePasscode*'
 85              )
 86              and strings.ends_with(.value, '@odspnotify>')
 87          )
 88      )
 89    )
 90  )
 91  
 92  // negate legitimate microsoft b2b applications invitations
 93  and not (
 94    length(body.links) > 0
 95    and (
 96      sender.email.local_part == "invites"
 97      and sender.email.domain.root_domain == "onmicrosoft.com"
 98      // infra validated message id
 99      and strings.icontains(headers.message_id, "pepf")
100    )
101  )
102  
103  // sender profiles
104  and (
105    not profile.by_sender().solicited
106    or (
107      profile.by_sender().any_messages_malicious_or_spam
108      and not profile.by_sender().any_messages_benign
109    )
110  )
111  
112  // negate org domains unless they fail DMARC authentication
113  and (
114    (
115      sender.email.domain.root_domain in $org_domains
116      and (
117        not headers.auth_summary.dmarc.pass
118        // MS quarantine digest emails from an org domain are router "internally" to MS, therefore, there is no authentication information
119        or not (
120          headers.auth_summary.dmarc.pass is null
121          and all(headers.domains,
122                  .root_domain in ("outlook.com", "office365.com")
123          )
124          // typical emails from freemail Outlook accounts are from prod.outlook.com
125          and strings.ends_with(headers.message_id, "protection.outlook.com>")
126        )
127      )
128    )
129    or sender.email.domain.root_domain not in $org_domains
130  )
131  
132  // negate sharepoint file shares with mimecast rewrites
133  and not (
134    // rewritten message ID
135    strings.iends_with(headers.message_id, 'mimecast.lan>')
136    and all(filter(body.links,
137                   strings.icontains(subject.subject, .display_text)
138                   or .display_text == "Open"
139            ),
140            .href_url.domain.root_domain in (
141              "mimecastprotect.com",
142              "mimecast.com"
143            )
144            and any(.href_url.query_params_decoded["domain"],
145                    strings.parse_domain(.).tld == "ms"
146                    or strings.parse_domain(.).root_domain == "sharepoint.com"
147            )
148    )
149  )
150  
151  // negate highly trusted sender domains unless they fail DMARC authentication
152  and (
153    (
154      sender.email.domain.root_domain in $high_trust_sender_root_domains
155      and not headers.auth_summary.dmarc.pass
156    )
157    or sender.email.domain.root_domain not in $high_trust_sender_root_domains
158  )
159  and not profile.by_sender().any_messages_benign  
160
161attack_types:
162  - "Credential Phishing"
163tactics_and_techniques:
164  - "Impersonation: Brand"
165  - "Social engineering"
166detection_methods:
167  - "Computer Vision"
168  - "Natural Language Understanding"
169  - "Sender analysis"
170id: "3ee9ef3d-8ec4-5df0-a8a2-5c6d037eb17a"
to-top