HTML smuggling: How attackers bypass your email security

April 9, 2026

HTML smuggling is a cyberattack technique in which a malicious payload is embedded as encoded data inside an HTML page or email attachment. When the recipient opens the file in a browser, embedded JavaScript decodes the data and uses built-in browser APIs to reconstruct and deliver a file directly onto the local machine. Unlike conventional malware delivery, the payload does not arrive as a separate downloadable object. It is generated locally within the browser, which allows the attack to bypass controls that focus primarily on files crossing the network perimeter.

How it works

The technique relies on two standard browser APIs: the Blob API and URL.createObjectURL(). Together, they allow JavaScript to build a file entirely in memory and trigger a download without requesting any external resource.

1 Encode the payload

The attacker converts a malicious file into Base64 or an integer array and embeds it directly into the HTML source - usually inside JavaScript variables.

2 Reconstruct in the browser

When the file opens, the browser executes the script. The encoded content is decoded via atob() and written into a Uint8Array, creating an in-memory binary version of the original file.

3 Trigger the download

The bytes are wrapped in a Blob, a temporary object URL is created, a hidden <a> tag is programmatically clicked, and the file saves to disk. The URL is immediately revoked. At the network level, only an HTML attachment was delivered and inspected. The payload itself never existed as a standalone file during transit.

The victim's view: Building trust before delivery

When the page opens, the victim does not see raw script execution or a blank document. The browser presents a convincing imitation of a trusted service, styled after Microsoft, DocuSign, Adobe, or SharePoint, sometimes even adapted to the targeted organization's own branding. The visible interface is part of the phishing mechanism. A fake sign-in form, a document preview, a cloud-sharing notification, or a message indicating that secure content is being loaded helps frame the file as routine business activity. The downloaded object is rarely presented as an obvious executable. In many campaigns it appears as a password-protected archive, an ISO image, a shortcut, or a document that supposedly requires another step before viewing.

Why it evades detection

This delivery model is particularly effective where email security focuses on attachment inspection but has limited visibility into browser-side execution. Security controls analyse the HTML attachment and find exactly what they expect, an HTML file - because the malicious binary comes into existence only after the browser interprets the embedded script. The trusted client application becomes the delivery mechanism.

Attackers also reduce dependence on external infrastructure. Traditional phishing often requires downloading malware from a remote server, creating observable traffic that can be blocked. With HTML smuggling, the payload is already embedded, so delivery succeeds even if later infrastructure goes offline.

To complicate sandbox analysis further, reconstruction logic is often obfuscated. Payloads may be split into fragments joined at runtime, represented as decimal arrays, or triggered only after a victim clicks a button or completes a fake CAPTCHA - making automated detection unreliable because the critical behavior depends on interaction.

Related variants: The same idea, different wrappers

HTML smuggling belongs to a broader class of client-side techniques in which legitimate application features move hidden content through trusted channels. Several related variants use the same core principle:

JavaScript smuggling

Standalone script files perform the same reconstruction without any HTML wrapper.

SVG-based delivery

Executable script embedded inside vector image markup, triggered when the file opens.

PDF-based delivery

Active JavaScript inside PDF documents shifts reconstruction into the document viewer.

In each case, harmless-looking content becomes malicious only after client-side interpretation.

Why it fits enterprise environments so well

HTML attachments fit naturally into routine business communication. Messages involving secure voicemail, contract review, payroll updates, or shared documents create a credible reason to open browser-rendered content. In remote work environments, where employees constantly receive cloud-generated notifications and file-sharing prompts, such attachments often don't immediately stand out as suspicious. Modern phishing campaigns often use HTML smuggling only as the opening move. The downloaded file may establish persistence, launch a loader, unpack additional malware, or lead the victim into a second credential-theft phase. In many operations, the first downloaded object is simply the bridge between initial trust and deeper compromise.

How to defend against HTML smuggling

Because the payload is assembled inside the browser, defence must extend beyond the network perimeter. Organisations should consider blocking or sandboxing HTML attachments at the email gateway, enforcing remote browser isolation for high-risk content, and deploying behavioural endpoint detection that monitors for suspicious process chains such as a browser writing an archive that immediately spawns a script. Files downloaded via HTML smuggling should carry the Mark-of-the-Web flag - endpoint controls should treat MOTW-tagged archives, ISOs, and shortcuts with elevated scrutiny. No single control eliminates the risk; effective protection layers gateway restrictions, browser-level containment, endpoint detection, and user awareness so that failure at one point does not mean compromise.