Detection rules › Sublime MQL

Brand impersonation: SendGrid

Severity
medium
Type
rule
Source
github.com/sublime-security/sublime-rules

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.

Threat classification

Sublime's own taxonomy (not MITRE ATT&CK).

CategoryValues
Attack typesBEC/Fraud, Credential Phishing, Spam
Tactics and techniquesImpersonation: Brand, Social engineering

Event coverage

Rule body MQL

type.inbound
and (
  (
    // SendGrid impersonation patterns
    strings.ilike(strings.replace_confusables(sender.display_name),
                  '*sendgrid*'
    )
    or strings.ilevenshtein(strings.replace_confusables(sender.display_name),
                            'sendgrid'
    ) <= 1
    or (
      strings.ilike(strings.replace_confusables(sender.email.local_part),
                    '*sendgrid*'
      )
      and (
        sender.display_name is null
        or strings.ilike(strings.replace_confusables(subject.base),
                         '*sendgrid*'
        )
      )
    )
    or any(ml.logo_detect(file.message_screenshot()).brands,
           .name == "SendGrid" and .confidence == "high"
    )
  )
  or (
    // Twilio impersonation patterns
    strings.ilike(strings.replace_confusables(sender.display_name), '*twilio*')
    or strings.ilevenshtein(strings.replace_confusables(sender.display_name),
                            'twilio'
    ) <= 1
    or (
      strings.ilike(strings.replace_confusables(sender.email.local_part),
                    '*twilio*'
      )
      and (
        sender.display_name is null
        or strings.ilike(strings.replace_confusables(subject.base), '*twilio*')
      )
    )
  )
  or strings.icontains(body.current_thread.text, "the sendgrid team")
  or 2 of (
    regex.icontains(body.current_thread.text, '(?:Twilio|SendGrid)'),
    strings.icontains(body.current_thread.text, '1801 California St'),
    strings.icontains(body.current_thread.text, 'Denver, CO 80202')
  )
  // SendGrid content from non-SendGrid marketing platforms
  or (
    sender.email.domain.root_domain in (
      "selfcast.com",
      "mailchimp.com",
      "constantcontact.com",
      "hubspot.com",
      "klaviyo.com",
      "mailgun.com"
    )
    and (
      (
        (
          strings.icontains(body.current_thread.text, "sendgrid")
          or strings.icontains(subject.base, "sendgrid")
        )
        and 3 of (
          strings.icontains(body.current_thread.text, "webhook"),
          strings.icontains(body.current_thread.text, "endpoint"),
          strings.icontains(body.current_thread.text, "api"),
          strings.icontains(body.current_thread.text, "delivery"),
          strings.icontains(body.current_thread.text, "event notification")
        )
      )
      and (
        // Look for SendGrid-related content with non-SendGrid tracking links
        any(body.links,
            strings.icontains(.href_url.url, "selfcast.com")
            or (
              .display_url.url is not null
              and strings.icontains(.display_url.url, "sendgrid.com")
            )
        )
      )
    )
  )
)
and (
  // Content analysis using ML/NLU
  any(ml.nlu_classifier(body.current_thread.text).topics,
      .name in (
        "Security and Authentication",
        "Secure Message",
        "Reminders and Notifications",
        "Software and App Updates",
        "Customer Service and Support"
      )
      and .confidence in ("medium", "high")
  )
  or any(ml.nlu_classifier(beta.ocr(file.message_screenshot()).text).topics,
         .name in (
           "Security and Authentication",
           "Secure Message",
           "Reminders and Notifications",
           "Software and App Updates",
           "Customer Service and Support"
         )
         and .confidence in ("medium", "high")
  )
  or any(ml.nlu_classifier(body.current_thread.text).intents,
         .name == "cred_theft" and .confidence == "high"
  )
  or any(ml.nlu_classifier(beta.ocr(file.message_screenshot()).text).intents,
         .name == "cred_theft" and .confidence == "high"
  )

  // any capacity or limits mentioned
  or any([subject.base, body.current_thread.text],
         (strings.icontains(., "capacity") or strings.icontains(., "limit"))
         and regex.icontains(., '\breach(?:\b|ed)')
  )
)

// and the sender is not in org_domains or from sendgrid domains and passes auth
and not (
  sender.email.domain.valid
  and (
    sender.email.domain.root_domain in $org_domains
    or (
      sender.email.domain.root_domain in (
        "sendgrid.com",
        "sendgrid.net",
        "twilio.com",
        "swoogo.com", // events planning software used by Twillio
        "sendsafely.com", // secure delivery used by Twillio
        "evolve.com", // same address as Twillio
        "sendgridsolutions.com"
      )
    )
  )
  and headers.auth_summary.dmarc.pass
)
// Exclude high trust domains with valid auth and solicited senders
and (
  (
    sender.email.domain.root_domain in $high_trust_sender_root_domains
    and not headers.auth_summary.dmarc.pass
  )
  or sender.email.domain.root_domain not in $high_trust_sender_root_domains
)
and not profile.by_sender().solicited

Detection logic

Scope: inbound message.

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.

  1. inbound message
  2. any of:
    • any of:
      • strings.replace_confusables(sender.display_name) matches '*sendgrid*'
      • strings.replace_confusables(sender.display_name) is similar to 'sendgrid'
      • all of:
        • strings.replace_confusables(sender.email.local_part) matches '*sendgrid*'
        • any of:
          • sender.display_name is missing
          • strings.replace_confusables(subject.base) matches '*sendgrid*'
      • any of ml.logo_detect(file.message_screenshot()).brands where all hold:
        • .name is 'SendGrid'
        • .confidence is 'high'
    • any of:
      • strings.replace_confusables(sender.display_name) matches '*twilio*'
      • strings.replace_confusables(sender.display_name) is similar to 'twilio'
      • all of:
        • strings.replace_confusables(sender.email.local_part) matches '*twilio*'
        • any of:
          • sender.display_name is missing
          • strings.replace_confusables(subject.base) matches '*twilio*'
    • body.current_thread.text contains 'the sendgrid team'
    • at least 2 of:
      • body.current_thread.text matches '(?:Twilio|SendGrid)'
      • body.current_thread.text contains '1801 California St'
      • body.current_thread.text contains 'Denver, CO 80202'
    • all of:
      • sender.email.domain.root_domain in ('selfcast.com', 'mailchimp.com', 'constantcontact.com', 'hubspot.com', 'klaviyo.com', 'mailgun.com')
      • all of:
        • all of:
          • any of:
            • body.current_thread.text contains 'sendgrid'
            • subject.base contains 'sendgrid'
          • at least 3 of 5: body.current_thread.text contains any of 5 patterns
            • webhook
            • endpoint
            • api
            • delivery
            • event notification
        • any of body.links where any holds:
          • .href_url.url contains 'selfcast.com'
          • all of:
            • .display_url.url is set
            • .display_url.url contains 'sendgrid.com'
  3. any of:
    • any of ml.nlu_classifier(body.current_thread.text).topics where all hold:
      • .name in ('Security and Authentication', 'Secure Message', 'Reminders and Notifications', 'Software and App Updates', 'Customer Service and Support')
      • .confidence in ('medium', 'high')
    • any of ml.nlu_classifier(beta.ocr(file.message_screenshot()).text).topics where all hold:
      • .name in ('Security and Authentication', 'Secure Message', 'Reminders and Notifications', 'Software and App Updates', 'Customer Service and Support')
      • .confidence in ('medium', 'high')
    • any of ml.nlu_classifier(body.current_thread.text).intents where all hold:
      • .name is 'cred_theft'
      • .confidence is 'high'
    • any of ml.nlu_classifier(beta.ocr(file.message_screenshot()).text).intents where all hold:
      • .name is 'cred_theft'
      • .confidence is 'high'
    • any of [subject.base, body.current_thread.text] where all hold:
      • any of:
        • . contains 'capacity'
        • . contains 'limit'
      • . matches '\\breach(?:\\b|ed)'
  4. not:
    • all of:
      • sender.email.domain.valid
      • any of:
        • sender.email.domain.root_domain in $org_domains
        • sender.email.domain.root_domain in ('sendgrid.com', 'sendgrid.net', 'twilio.com', 'swoogo.com', 'sendsafely.com', 'evolve.com', 'sendgridsolutions.com')
      • headers.auth_summary.dmarc.pass
  5. any of:
    • all of:
      • sender.email.domain.root_domain in $high_trust_sender_root_domains
      • not:
        • headers.auth_summary.dmarc.pass
    • sender.email.domain.root_domain not in $high_trust_sender_root_domains
  6. not:
    • profile.by_sender().solicited

Inspects: body.current_thread.text, body.links, body.links[].display_url.url, body.links[].href_url.url, headers.auth_summary.dmarc.pass, sender.display_name, sender.email.domain.root_domain, sender.email.domain.valid, sender.email.local_part, subject.base, type.inbound. Sensors: beta.ocr, file.message_screenshot, ml.logo_detect, ml.nlu_classifier, profile.by_sender, regex.icontains, strings.icontains, strings.ilevenshtein, strings.ilike, strings.replace_confusables. Reference lists: $high_trust_sender_root_domains, $org_domains.

Indicators matched (52)

FieldMatchValue
strings.ilikesubstring*sendgrid*
strings.ilevenshteinfuzzysendgrid
ml.logo_detect(file.message_screenshot()).brands[].nameequalsSendGrid
ml.logo_detect(file.message_screenshot()).brands[].confidenceequalshigh
strings.ilikesubstring*twilio*
strings.ilevenshteinfuzzytwilio
strings.icontainssubstringthe sendgrid team
regex.icontainsregex(?:Twilio|SendGrid)
strings.icontainssubstring1801 California St
strings.icontainssubstringDenver, CO 80202
sender.email.domain.root_domainmemberselfcast.com
sender.email.domain.root_domainmembermailchimp.com
40 more
sender.email.domain.root_domainmemberconstantcontact.com
sender.email.domain.root_domainmemberhubspot.com
sender.email.domain.root_domainmemberklaviyo.com
sender.email.domain.root_domainmembermailgun.com
strings.icontainssubstringsendgrid
strings.icontainssubstringwebhook
strings.icontainssubstringendpoint
strings.icontainssubstringapi
strings.icontainssubstringdelivery
strings.icontainssubstringevent notification
strings.icontainssubstringselfcast.com
strings.icontainssubstringsendgrid.com
ml.nlu_classifier(body.current_thread.text).topics[].namememberSecurity and Authentication
ml.nlu_classifier(body.current_thread.text).topics[].namememberSecure Message
ml.nlu_classifier(body.current_thread.text).topics[].namememberReminders and Notifications
ml.nlu_classifier(body.current_thread.text).topics[].namememberSoftware and App Updates
ml.nlu_classifier(body.current_thread.text).topics[].namememberCustomer Service and Support
ml.nlu_classifier(body.current_thread.text).topics[].confidencemembermedium
ml.nlu_classifier(body.current_thread.text).topics[].confidencememberhigh
ml.nlu_classifier(beta.ocr(file.message_screenshot()).text).topics[].namememberSecurity and Authentication
ml.nlu_classifier(beta.ocr(file.message_screenshot()).text).topics[].namememberSecure Message
ml.nlu_classifier(beta.ocr(file.message_screenshot()).text).topics[].namememberReminders and Notifications
ml.nlu_classifier(beta.ocr(file.message_screenshot()).text).topics[].namememberSoftware and App Updates
ml.nlu_classifier(beta.ocr(file.message_screenshot()).text).topics[].namememberCustomer Service and Support
ml.nlu_classifier(beta.ocr(file.message_screenshot()).text).topics[].confidencemembermedium
ml.nlu_classifier(beta.ocr(file.message_screenshot()).text).topics[].confidencememberhigh
ml.nlu_classifier(body.current_thread.text).intents[].nameequalscred_theft
ml.nlu_classifier(body.current_thread.text).intents[].confidenceequalshigh
ml.nlu_classifier(beta.ocr(file.message_screenshot()).text).intents[].nameequalscred_theft
ml.nlu_classifier(beta.ocr(file.message_screenshot()).text).intents[].confidenceequalshigh
strings.icontainssubstringcapacity
strings.icontainssubstringlimit
regex.icontainsregex\breach(?:\b|ed)
sender.email.domain.root_domainmembersendgrid.com
sender.email.domain.root_domainmembersendgrid.net
sender.email.domain.root_domainmembertwilio.com
sender.email.domain.root_domainmemberswoogo.com
sender.email.domain.root_domainmembersendsafely.com
sender.email.domain.root_domainmemberevolve.com
sender.email.domain.root_domainmembersendgridsolutions.com