Detection rules › Sublime MQL

Attachment: HTML smuggling with atob and high entropy via calendar invite

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

Scans calendar invites (.ics files) to detect HTML smuggling techniques.

Threat classification

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

CategoryValues
Attack typesCredential Phishing, Malware/Ransomware
Tactics and techniquesEvasion, HTML smuggling, ICS Phishing, Scripting

Event coverage

Rule body MQL

type.inbound
and any(attachments,
        (.file_extension =~ "ics" or .content_type == "text/calendar")
        and any(file.explode(.),
                .scan.entropy.entropy >= 5
                and (
                  length(filter(.scan.javascript.identifiers,
                                strings.like(., "document", "write", "atob")
                         )
                  ) == 3
                  // usage: document['write'](atob)
                  or any(.scan.strings.strings,
                         regex.icontains(., "document.{0,10}write.{0,10}atob")
                  )
                  // 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: {src: atob
                  or any(.scan.strings.strings,
                         strings.ilike(., "*{src: 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 : 'at'+'ob'
                  or any(.scan.strings.strings, strings.ilike(., "*'at'+'ob'*"))
                  // 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*")
                  )
                )
        )
)
// negate bouncebacks and undeliverables
and not any(attachments,
            .content_type in (
              "message/global-delivery-status",
              "message/delivery-status"
            )
)
// negate highly trusted sender domains unless they fail DMARC authentication
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
)

Detection logic

Scope: inbound message.

Scans calendar invites (.ics files) to detect HTML smuggling techniques.

  1. inbound message
  2. any of attachments where all hold:
    • any of:
      • .file_extension is 'ics'
      • .content_type is 'text/calendar'
    • any of file.explode(.) where all hold:
      • .scan.entropy.entropy ≥ 5
      • any of:
        • length(filter(.scan.javascript.identifiers, strings.like(., 'document', 'write', 'atob'))) is 3
        • any of .scan.strings.strings where:
          • . matches 'document.{0,10}write.{0,10}atob'
        • any of .scan.strings.strings where:
          • . matches '=.?atob.*;'
        • any of .scan.strings.strings where:
          • . matches '*atob?atob*'
        • any of .scan.strings.strings where:
          • . matches '*{src: atob*'
        • any of .scan.strings.strings where:
          • . matches '*eval?atob*'
        • any of .scan.strings.strings where:
          • . matches '*atob(?0x*'
        • any of .scan.strings.strings where:
          • . matches "*'at'+'ob'*"
        • any of .scan.javascript.identifiers where:
          • . matches '*ato\\u0062*'
        • any of .scan.strings.strings where:
          • . matches '*document*insertAdjacentHTML*atob*'
  3. not:
    • any of attachments where:
      • .content_type in ('message/global-delivery-status', 'message/delivery-status')
  4. 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

Inspects: attachments[].content_type, attachments[].file_extension, headers.auth_summary.dmarc.pass, sender.email.domain.root_domain, type.inbound. Sensors: file.explode, regex.icontains, strings.ilike, strings.like. Reference lists: $high_trust_sender_root_domains.

Indicators matched (16)

FieldMatchValue
attachments[].file_extensionequalsics
attachments[].content_typeequalstext/calendar
strings.likesubstringdocument
strings.likesubstringwrite
strings.likesubstringatob
regex.icontainsregexdocument.{0,10}write.{0,10}atob
regex.icontainsregex=.?atob.*;
strings.ilikesubstring*atob?atob*
strings.ilikesubstring*{src: atob*
strings.ilikesubstring*eval?atob*
strings.ilikesubstring*atob(?0x*
strings.ilikesubstring*'at'+'ob'*
4 more
strings.ilikesubstring*ato\u0062*
strings.ilikesubstring*document*insertAdjacentHTML*atob*
attachments[].content_typemembermessage/global-delivery-status
attachments[].content_typemembermessage/delivery-status