Detection rules › Sublime MQL
Attachment: Embedded Javascript in SVG file
Javascript inside SVG files can be used to smuggle malicious payloads or execute scripts.
Threat classification
Sublime's own taxonomy (not MITRE ATT&CK).
| Category | Values |
|---|---|
| Attack types | Malware/Ransomware |
| Tactics and techniques | Scripting |
Event coverage
| Message attribute |
|---|
| attachments (collection) |
| type |
Rule body MQL
type.inbound
and any(attachments,
(
(
.file_extension in~ ("svg", "svgz")
or .content_type in~ ("image/svg+xml")
or .file_type == "svg"
)
and (
strings.ilike(file.parse_text(.,
encodings=[
"ascii",
"utf8",
"utf16-le"
]
).text,
"*onload*",
"*window.location.href*",
"*onerror*",
"*CDATA*",
"*<script*",
"*</script*",
"*atob*",
"*location.assign*",
"*decodeURIComponent*"
)
or regex.icontains(file.parse_text(.,
encodings=[
"ascii",
"utf8",
"utf16-le"
]
).text,
'<iframe[^\>]+src\s*=\s*\"data:[^\;]+;base64,'
)
or any(beta.scan_base64(file.parse_text(.).text,
encodings=["ascii", "utf8", "utf16-le"]
),
strings.ilike(.,
"*onload*",
"*window.location.href*",
"*onerror*",
"*CDATA*",
"*<script*",
"*</script*",
"*atob*",
"*location.assign*",
"*decodeURIComponent*"
)
)
)
)
or (
(
.file_extension in $file_extensions_common_archives
or .file_type == "gz"
or .content_type == "application/x-gzip"
)
and any(file.explode(.),
(
.file_extension in~ ("svg", "svgz")
or .flavors.mime == "image/svg+xml"
)
and any(.scan.strings.strings,
strings.ilike(.,
"*onload*",
"*window.location.href*",
"*onerror*",
"*CDATA*",
"*<script*",
"*</script*",
"*atob*",
"*location.assign*",
"*decodeURIComponent*"
)
)
)
)
)
Detection logic
Scope: inbound message.
Javascript inside SVG files can be used to smuggle malicious payloads or execute scripts.
- inbound message
any of
attachmentswhere any holds:all of:
any of:
- .file_extension in ('svg', 'svgz')
- .content_type in ('image/svg+xml')
- .file_type is 'svg'
any of:
file.parse_text(., encodings=['ascii', 'utf8', 'utf16-le']).text matches any of 9 patterns
*onload**window.location.href**onerror**CDATA**<script**</script**atob**location.assign**decodeURIComponent*
- file.parse_text(., encodings=['ascii', 'utf8', 'utf16-le']).text matches '<iframe[^\\>]+src\\s*=\\s*\\"data:[^\\;]+;base64,'
any of
beta.scan_base64(...)where:. matches any of 9 patterns
*onload**window.location.href**onerror**CDATA**<script**</script**atob**location.assign**decodeURIComponent*
all of:
any of:
- .file_extension in $file_extensions_common_archives
- .file_type is 'gz'
- .content_type is 'application/x-gzip'
any of
file.explode(.)where all hold:any of:
- .file_extension in ('svg', 'svgz')
- .flavors.mime is 'image/svg+xml'
any of
.scan.strings.stringswhere:. matches any of 9 patterns
*onload**window.location.href**onerror**CDATA**<script**</script**atob**location.assign**decodeURIComponent*
Inspects: attachments[].content_type, attachments[].file_extension, attachments[].file_type, type.inbound. Sensors: beta.scan_base64, file.explode, file.parse_text, regex.icontains, strings.ilike. Reference lists: $file_extensions_common_archives.
Indicators matched (19)
| Field | Match | Value |
|---|---|---|
attachments[].file_extension | member | svg |
attachments[].file_extension | member | svgz |
attachments[].content_type | member | image/svg+xml |
attachments[].file_type | equals | svg |
strings.ilike | substring | *onload* |
strings.ilike | substring | *window.location.href* |
strings.ilike | substring | *onerror* |
strings.ilike | substring | *CDATA* |
strings.ilike | substring | *<script* |
strings.ilike | substring | *</script* |
strings.ilike | substring | *atob* |
strings.ilike | substring | *location.assign* |
7 more
strings.ilike | substring | *decodeURIComponent* |
regex.icontains | regex | <iframe[^\>]+src\s*=\s*\"data:[^\;]+;base64, |
attachments[].file_type | equals | gz |
attachments[].content_type | equals | application/x-gzip |
file.explode(attachments[])[].file_extension | member | svg |
file.explode(attachments[])[].file_extension | member | svgz |
file.explode(attachments[])[].flavors.mime | equals | image/svg+xml |