Brand impersonation: SendGrid

Detects inbound messages that impersonate Twilio/SendGrid through display name or domain manipulation, combined with security or authentication-themed content, while failing authentication checks and originating from untrusted sources.

Sublime rule (View on GitHub)

  1name: "Brand impersonation: SendGrid"
  2description: "Detects inbound messages that impersonate Twilio/SendGrid through display name or domain manipulation, combined with security or authentication-themed content, while failing authentication checks and originating from untrusted sources."
  3type: "rule"
  4severity: "medium"
  5source: |
  6  type.inbound
  7  and (
  8    (
  9      // SendGrid impersonation patterns
 10      strings.ilike(strings.replace_confusables(sender.display_name),
 11                    '*sendgrid*'
 12      )
 13      or strings.ilevenshtein(strings.replace_confusables(sender.display_name),
 14                              'sendgrid'
 15      ) <= 1
 16      or (
 17        strings.ilike(strings.replace_confusables(sender.email.local_part),
 18                      '*sendgrid*'
 19        )
 20        and (
 21          sender.display_name is null
 22          or strings.ilike(strings.replace_confusables(subject.base),
 23                           '*sendgrid*'
 24          )
 25        )
 26      )
 27      or any(ml.logo_detect(file.message_screenshot()).brands,
 28             .name == "SendGrid" and .confidence == "high"
 29      )
 30    )
 31    or (
 32      // Twilio impersonation patterns
 33      strings.ilike(strings.replace_confusables(sender.display_name), '*twilio*')
 34      or strings.ilevenshtein(strings.replace_confusables(sender.display_name),
 35                              'twilio'
 36      ) <= 1
 37      or (
 38        strings.ilike(strings.replace_confusables(sender.email.local_part),
 39                      '*twilio*'
 40        )
 41        and (
 42          sender.display_name is null
 43          or strings.ilike(strings.replace_confusables(subject.base), '*twilio*')
 44        )
 45      )
 46    )
 47    // SendGrid content from non-SendGrid marketing platforms
 48    or (
 49      sender.email.domain.root_domain in (
 50        "selfcast.com",
 51        "mailchimp.com",
 52        "constantcontact.com",
 53        "hubspot.com",
 54        "klaviyo.com",
 55        "mailgun.com"
 56      )
 57      and (
 58        (
 59          (
 60            strings.icontains(body.current_thread.text, "sendgrid")
 61            or strings.icontains(subject.base, "sendgrid")
 62          )
 63          and 3 of (
 64            strings.icontains(body.current_thread.text, "webhook"),
 65            strings.icontains(body.current_thread.text, "endpoint"),
 66            strings.icontains(body.current_thread.text, "api"),
 67            strings.icontains(body.current_thread.text, "delivery"),
 68            strings.icontains(body.current_thread.text, "event notification")
 69          )
 70        )
 71        and (
 72          // Look for SendGrid-related content with non-SendGrid tracking links
 73          any(body.links,
 74              strings.icontains(.href_url.url, "selfcast.com")
 75              or (
 76                .display_url.url is not null
 77                and strings.icontains(.display_url.url, "sendgrid.com")
 78              )
 79          )
 80        )
 81      )
 82    )
 83  )
 84  and (
 85    // Content analysis using ML/NLU
 86    any(ml.nlu_classifier(body.current_thread.text).topics,
 87        .name in (
 88          "Security and Authentication",
 89          "Secure Message",
 90          "Reminders and Notifications",
 91          "Software and App Updates",
 92          "Customer Service and Support"
 93        )
 94        and .confidence in ("medium", "high")
 95    )
 96    or any(ml.nlu_classifier(beta.ocr(file.message_screenshot()).text).topics,
 97           .name in (
 98             "Security and Authentication",
 99             "Secure Message",
100             "Reminders and Notifications",
101             "Software and App Updates",
102             "Customer Service and Support"
103           )
104           and .confidence in ("medium", "high")
105    )
106    or any(ml.nlu_classifier(body.current_thread.text).intents,
107           .name == "cred_theft" and .confidence == "high"
108    )
109    or any(ml.nlu_classifier(beta.ocr(file.message_screenshot()).text).intents,
110           .name == "cred_theft" and .confidence == "high"
111    )
112  
113    // any capacity or limits mentioned
114    or any([subject.base, body.current_thread.text],
115           (strings.icontains(., "capacity") or strings.icontains(., "limit"))
116           and regex.icontains(., '\breach(?:\b|ed)')
117    )
118  )
119  
120  // and the sender is not in org_domains or from sendgrid domains and passes auth
121  and not (
122    sender.email.domain.valid
123    and (
124      sender.email.domain.root_domain in $org_domains
125      or (
126        sender.email.domain.root_domain in (
127          "sendgrid.com",
128          "sendgrid.net",
129          "twilio.com",
130          "swoogo.com", // events planning software used by Twillio
131          "sendsafely.com" // secure delivery used by Twillio
132        )
133      )
134    )
135    and headers.auth_summary.dmarc.pass
136  )
137  // Exclude high trust domains with valid auth and solicited senders
138  and (
139    (
140      sender.email.domain.root_domain in $high_trust_sender_root_domains
141      and not headers.auth_summary.dmarc.pass
142    )
143    or sender.email.domain.root_domain not in $high_trust_sender_root_domains
144  )
145  and not profile.by_sender().solicited  
146attack_types:
147  - "BEC/Fraud"
148  - "Credential Phishing"
149  - "Spam"
150tactics_and_techniques:
151  - "Impersonation: Brand"
152  - "Social engineering"
153detection_methods:
154  - "Content analysis"
155  - "Header analysis"
156  - "Natural Language Understanding"
157  - "Optical Character Recognition"
158  - "Sender analysis"
159id: "d800124f-6aa4-58e1-8fa7-beec4958924f"
to-top