Skip to content
Triageby WETNav

HTML smuggling: how to analyze a smuggled attachment

By Published Updated

HTML smuggling is a delivery technique in which an HTML or SVG attachment carries a payload as encoded text and uses JavaScript to rebuild it in the browser. The ZIP, ISO or script is assembled and saved on the endpoint, so it never crosses the mail gateway as a file. MITRE ATT&CK tracks it as T1027.006.

The gateway sees a small HTML file. The browser turns it into a ZIP or a disk image on the user's disk. Analysis means reading the script, not running it.

Carrier:
HTML or SVG attachment with script
Builds:
ZIP, ISO, IMG, JS, LNK, HTA
Analysis:
Static: decode the blob
ATT&CK:
T1027.006T1566.001T1204.002T1553.005

Drop the reported email and the file its HTML attachment would build is decoded, typed and hashed in your browser, without running the script.

Extract a smuggled payload
On this page

From HTML attachment to next stage

  1. AttachmentA small HTML or SVG file arrives holding a long base64 string or an array of numbers.
  2. DecodeWhen it is opened, its script decodes the string into bytes and wraps them in a Blob.
  3. SaveA link built with createObjectURL and the download attribute makes the browser save a ZIP, ISO or script.
  4. OpenThe user opens the download. Explorer extracts the archive or mounts the disk image.
  5. RunA script host, shell or mshta runs the JS, LNK or HTA file inside.
  6. Next stageThat process fetches the loader or the payload, usually within seconds.
The gateway only ever sees text. The malicious file first exists on the endpoint, which is where the evidence is.

How does HTML smuggling work?

The attachment holds the payload as a base64 string or an array of numbers. When opened, its JavaScript decodes that into bytes, wraps them in a Blob, creates a link with URL.createObjectURL and the download attribute, and clicks it. The file is assembled on the endpoint, so the gateway never sees an archive or an executable on the wire. SVG files can carry the same script.

Payloads are usually a ZIP holding a JavaScript, LNK or HTA file, a password-protected archive with the password shown on the page, or an ISO or IMG image. Disk images were popular because older Windows builds did not pass Mark-of-the-Web to the files inside, so SmartScreen and Office macro blocking did not apply.

Carriers shift as Microsoft closes gaps. After OneNote attachments with embedded scripts surged in late 2022 and early 2023, Microsoft began blocking embedded files with dangerous extensions in OneNote in 2023. OneNote lures declined but still appear, and the same static approach applies: extract the embedded file and judge what it would run.

How to analyze an HTML smuggling attachment safely

  1. 01Never open the HTML in a browser on your workstation. Read the source as text.
  2. 02Find the builder: atob(, Uint8Array, new Blob, createObjectURL, download=, String.fromCharCode, and long base64 or number arrays. Watch for reversed strings and simple XOR.
  3. 03Decode the payload offline, hash it, and identify it by its magic bytes: PK for ZIP, CD001 at offset 0x8001 for ISO, MZ for executables.
  4. 04Peel each layer: list the archive, read the LNK target and arguments, deobfuscate the script, and extract the next-stage URLs.

The workbench does steps 2 and 3 in your browser without executing the script: it flags the builder, extracts the embedded file, identifies its real type, hashes it, and lists archive contents.

Where it leads

Inside the archive you will typically find a script run by wscript, an LNK that starts cmd or PowerShell, an HTA run by mshta, or a DLL loaded with rundll32. Use the command explainer pages to read what each command line does.

Endpoint evidence

  • Classic Outlook opens the attachment from its cache folder (Content.Outlook) in the default browser.
  • The browser writes the archive or image to Downloads, with a Zone.Identifier stream recording its origin (Sysmon event 15).
  • Explorer mounts the image or extracts the archive, then a script host or shell starts as a child of Explorer (Sysmon event 1, Security event 4688).
  • Network connections to the next stage follow within seconds.

How each role works it

SOC analyst
Treats any HTML attachment whose script builds a file as malicious, purges by attachment hash and subject, and checks who opened it.
Incident responder
On devices where it was opened, looks for the dropped archive, mounted images and script hosts started from Explorer or the browser, then isolates.
DFIR
Recovers the dropped file and its Zone.Identifier stream, proves execution from process events, Prefetch and Amcache, and dates each step.
Malware analyst
Extracts the payload from the script without a browser, peels each layer (archive, LNK, script, loader) and pulls out the next-stage URLs and C2.

What the workbench checks

Drop the reported email into the free workbench and these are checked in your browser before you read a line. Nothing is uploaded.

  • Blob, createObjectURL, atob and download builders in HTML and SVG attachments
  • Extracts the embedded payload and identifies its real type
  • Lists archive contents and flags LNK, JS, HTA, ISO and executables
  • Hashes every attachment and payload for lookups
  • Predicts the endpoint footprint and matches it to Sigma rules

Hunting queries

KQL to scope the campaign and look for impact. The workbench writes these with the real sender, subject, domains and hashes filled in.

Outlook opening an HTML attachment in a browserDefender XDR advanced hunting
DeviceProcessEvents
| where Timestamp > ago(7d)
| where InitiatingProcessFileName =~ "outlook.exe"
| where FileName in~ ("msedge.exe", "chrome.exe", "firefox.exe")
| where ProcessCommandLine has "Content.Outlook"
| where ProcessCommandLine has_any (".htm", ".html", ".shtml", ".svg")
| project Timestamp, DeviceName, AccountName, ProcessCommandLine

Covers classic Outlook. The new Outlook and Outlook on the web open attachments differently.

Archives and disk images written by a browserDefender XDR advanced hunting
DeviceFileEvents
| where Timestamp > ago(7d) and ActionType == "FileCreated"
| where InitiatingProcessFileName in~ ("msedge.exe", "chrome.exe", "firefox.exe")
| where FileName matches regex @"(?i)\.(zip|iso|img|vhdx?|7z|rar)$"
| where FolderPath has @"\Downloads\"
| project Timestamp, DeviceName, FileName, FolderPath, SHA256, FileOriginUrl, FileOriginReferrerUrl

Questions

Why doesn't the email gateway catch HTML smuggling?

The gateway sees text: an HTML file with a long string. The malicious file only exists after the browser runs the script on the endpoint, so attachment sandboxes that don't execute the page see nothing to block.

Is every HTML attachment malicious?

No. Some receipts, voicemail notifications and reports arrive as HTML. Ones whose script builds a file for download, or that contain a sign-in form posting to an outside site, are malicious.

Can I open the HTML in a sandbox?

Yes, in an isolated virtual machine or a detonation service. Static extraction is faster and safer, and some pages check for analysis environments before they build the payload.

References

Related on WETNav

More phishing analysis

More free triage tools