Detection rules › Sublime MQL

Attachment: HTML smuggling with auto-downloaded file

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

HTML attachments containing files that are automatically downloaded with Javascript.

Threat classification

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

CategoryValues
Attack typesCredential Phishing, Malware/Ransomware
Tactics and techniquesHTML smuggling, Scripting

Event coverage

Rule body MQL

type.inbound
and any(attachments,
        (
          .file_extension in~ ("html", "htm", "shtml", "dhtml")
          or .file_extension in~ $file_extensions_common_archives
          or .file_type == "html"
        )
        and any(file.explode(.),
                any(.scan.javascript.identifiers, strings.ilike(., 'click'))
                and any(.scan.javascript.identifiers,
                        strings.ilike(., 'addEventListener')
                )
                and (
                  length(filter(.scan.javascript.identifiers,
                                strings.like(., "document", "write", "atob")
                         )
                  ) == 3
                  // usage: document['write'](atob)
                  or any(.scan.strings.strings,
                         strings.ilike(., "*document*write*atob*")
                  )
                  // usage: some_var = atob();
                  or any(.scan.strings.strings, strings.ilike(., "*=*atob*;"))
                  // 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*write*atob*",
                                       "*document*insertAdjacentHTML*atob*"
                         )
                  )
                )
        )
)

Detection logic

Scope: inbound message.

HTML attachments containing files that are automatically downloaded with Javascript.

  1. inbound message
  2. any of attachments where all hold:
    • any of:
      • .file_extension in ('html', 'htm', 'shtml', 'dhtml')
      • .file_extension in $file_extensions_common_archives
      • .file_type is 'html'
    • any of file.explode(.) where all hold:
      • any of .scan.javascript.identifiers where:
        • . matches 'click'
      • any of .scan.javascript.identifiers where:
        • . matches 'addEventListener'
      • any of:
        • length(filter(.scan.javascript.identifiers, strings.like(., 'document', 'write', 'atob'))) is 3
        • any of .scan.strings.strings where:
          • . matches '*document*write*atob*'
        • any of .scan.strings.strings where:
          • . matches '*=*atob*;'
        • any of .scan.javascript.identifiers where:
          • . matches '*ato\\u0062*'
        • any of .scan.strings.strings where:
          • . matches any of 2 patterns
            • *document*write*atob*
            • *document*insertAdjacentHTML*atob*

Inspects: attachments[].file_extension, attachments[].file_type, type.inbound. Sensors: file.explode, strings.ilike, strings.like. Reference lists: $file_extensions_common_archives.

Indicators matched (14)

FieldMatchValue
attachments[].file_extensionmemberhtml
attachments[].file_extensionmemberhtm
attachments[].file_extensionmembershtml
attachments[].file_extensionmemberdhtml
attachments[].file_typeequalshtml
strings.ilikesubstringclick
strings.ilikesubstringaddEventListener
strings.likesubstringdocument
strings.likesubstringwrite
strings.likesubstringatob
strings.ilikesubstring*document*write*atob*
strings.ilikesubstring*=*atob*;
2 more
strings.ilikesubstring*ato\u0062*
strings.ilikesubstring*document*insertAdjacentHTML*atob*