Detection rules › Sublime MQL

Low reputation link to auto-downloaded HTML file with smuggling indicators

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

Message contains a low reputation link to an automatically downloaded HTML file that contains HTML smuggling indicators, such as atob function use, excessive hexadecimal (0x) usage, etc.

Threat classification

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

CategoryValues
Attack typesCredential Phishing
Tactics and techniquesEvasion, Free file host, Free subdomain host, HTML smuggling, Impersonation: Brand, Open redirect, Social engineering

Event coverage

Rule body MQL

type.inbound
and any(body.links,
        (
          .href_url.domain.root_domain not in $tranco_1m
          or .href_url.domain.domain in $free_file_hosts
          or .href_url.domain.root_domain in $free_file_hosts
          or .href_url.domain.root_domain in $free_subdomain_hosts
          or .href_url.domain.domain in $url_shorteners
          or .href_url.domain.domain in $social_landing_hosts
          or 

          // mass mailer link, masks the actual URL
          .href_url.domain.root_domain in (
            "hubspotlinks.com",
            "mandrillapp.com",
            "sendgrid.net",
            "rs6.net"
          )

          // Google AMP redirect
          or (
            .href_url.domain.sld == "google"
            and strings.starts_with(.href_url.path, "/amp/")
          )
        )

        // exclude sources of potential FPs
        and (
          .href_url.domain.root_domain not in (
            "svc.ms",
            "sharepoint.com",
            "1drv.ms",
            "microsoft.com",
            "aka.ms",
            "msftauthimages.net",
            "mimecastprotect.com",
            "office.com"
          )
          or any(body.links, .href_url.domain.domain in $free_file_hosts)
        )
        and .href_url.domain.root_domain not in $org_domains
        and .href_url.domain.valid
)
and any(body.links,
        any(ml.link_analysis(.).files_downloaded,
            any(file.explode(.),
                .scan.entropy.entropy >= 5
                and (
                  length(filter(.scan.javascript.identifiers,
                                strings.like(.,
                                             "document",
                                             "write",
                                             "atob",
                                             "onload"
                                )
                         )
                  ) > 2
                  // usage: document['write'](atob)
                  or any(.scan.strings.strings,
                         regex.icontains(., "document.{0,10}write.{0,10}atob")
                  )
                  or any(.scan.strings.strings, strings.icount(., "_0x") > 50)
                  // usage: some_var = atob();
                  or any(.scan.strings.strings,
                         regex.icontains(., "=.?atob.*;")
                  )
                  // usage: atob(atob
                  or any(.scan.strings.strings, strings.ilike(., "*atob?atob*"))
                  // usage: eval(atob)
                  or any(.scan.strings.strings, strings.ilike(., "*eval?atob*"))
                  // usage: atob(_0x)
                  or any(.scan.strings.strings, strings.ilike(., "*atob(?0x*"))
                  // usage: obfuscating "atob"
                  or any(.scan.javascript.identifiers,
                         strings.ilike(., '*ato\u0062*')
                  )
                  // usage: document.head.insertAdjacentHTML("beforeend", atob(...
                  or any(.scan.strings.strings,
                         strings.ilike(., "*document*insertAdjacentHTML*atob*")
                  )
                )
            )
        )
)
and (
  not profile.by_sender().solicited
  or (
    profile.by_sender().any_messages_malicious_or_spam
    and not profile.by_sender().any_messages_benign
  )
)

Detection logic

Scope: inbound message.

Message contains a low reputation link to an automatically downloaded HTML file that contains HTML smuggling indicators, such as atob function use, excessive hexadecimal (0x) usage, etc.

  1. inbound message
  2. any of body.links where all hold:
    • any of:
      • .href_url.domain.root_domain not in $tranco_1m
      • .href_url.domain.domain in $free_file_hosts
      • .href_url.domain.root_domain in $free_file_hosts
      • .href_url.domain.root_domain in $free_subdomain_hosts
      • .href_url.domain.domain in $url_shorteners
      • .href_url.domain.domain in $social_landing_hosts
      • .href_url.domain.root_domain in ('hubspotlinks.com', 'mandrillapp.com', 'sendgrid.net', 'rs6.net')
      • all of:
        • .href_url.domain.sld is 'google'
        • .href_url.path starts with '/amp/'
    • any of:
      • .href_url.domain.root_domain not in ('svc.ms', 'sharepoint.com', '1drv.ms', 'microsoft.com', 'aka.ms', 'msftauthimages.net', 'mimecastprotect.com', 'office.com')
      • any of body.links where:
        • .href_url.domain.domain in $free_file_hosts
    • .href_url.domain.root_domain not in $org_domains
    • .href_url.domain.valid
  3. any of body.links where:
    • any of ml.link_analysis(.).files_downloaded where:
      • any of file.explode(.) where all hold:
        • .scan.entropy.entropy ≥ 5
        • any of:
          • length(filter(.scan.javascript.identifiers, strings.like(., 'document', 'write', 'atob', 'onload'))) > 2
          • any of .scan.strings.strings where:
            • . matches 'document.{0,10}write.{0,10}atob'
          • any of .scan.strings.strings where:
            • strings.icount(., '_0x') > 50
          • any of .scan.strings.strings where:
            • . matches '=.?atob.*;'
          • any of .scan.strings.strings where:
            • . matches '*atob?atob*'
          • any of .scan.strings.strings where:
            • . matches '*eval?atob*'
          • any of .scan.strings.strings where:
            • . matches '*atob(?0x*'
          • any of .scan.javascript.identifiers where:
            • . matches '*ato\\u0062*'
          • any of .scan.strings.strings where:
            • . matches '*document*insertAdjacentHTML*atob*'
  4. any of:
    • not:
      • profile.by_sender().solicited
    • all of:
      • profile.by_sender().any_messages_malicious_or_spam
      • not:
        • profile.by_sender().any_messages_benign

Inspects: body.links, body.links[].href_url.domain.domain, body.links[].href_url.domain.root_domain, body.links[].href_url.domain.sld, body.links[].href_url.domain.valid, body.links[].href_url.path, type.inbound. Sensors: file.explode, ml.link_analysis, profile.by_sender, regex.icontains, strings.icount, strings.ilike, strings.like, strings.starts_with. Reference lists: $free_file_hosts, $free_subdomain_hosts, $org_domains, $social_landing_hosts, $tranco_1m, $url_shorteners.

Indicators matched (25)

FieldMatchValue
body.links[].href_url.domain.root_domainmemberhubspotlinks.com
body.links[].href_url.domain.root_domainmembermandrillapp.com
body.links[].href_url.domain.root_domainmembersendgrid.net
body.links[].href_url.domain.root_domainmemberrs6.net
body.links[].href_url.domain.sldequalsgoogle
strings.starts_withprefix/amp/
body.links[].href_url.domain.root_domainmembersvc.ms
body.links[].href_url.domain.root_domainmembersharepoint.com
body.links[].href_url.domain.root_domainmember1drv.ms
body.links[].href_url.domain.root_domainmembermicrosoft.com
body.links[].href_url.domain.root_domainmemberaka.ms
body.links[].href_url.domain.root_domainmembermsftauthimages.net
13 more
body.links[].href_url.domain.root_domainmembermimecastprotect.com
body.links[].href_url.domain.root_domainmemberoffice.com
strings.likesubstringdocument
strings.likesubstringwrite
strings.likesubstringatob
strings.likesubstringonload
regex.icontainsregexdocument.{0,10}write.{0,10}atob
regex.icontainsregex=.?atob.*;
strings.ilikesubstring*atob?atob*
strings.ilikesubstring*eval?atob*
strings.ilikesubstring*atob(?0x*
strings.ilikesubstring*ato\u0062*
strings.ilikesubstring*document*insertAdjacentHTML*atob*