repositories

daemon-sec-cheatsheet

The cheatsheet vault for operators: AD, enumeration, exploitation, priv-esc, web, DFIR

clonegit clone https://git.daemon-sec.xyz/daemon-sec-cheatsheet.git
smtp-smuggling.mdMarkdown147 lines9.2 KiBsource raw download

title: "SMTP Smuggling" section: "Network Services" sectionSlug: "network-services-pentesting" sourcePath: "src/network-services-pentesting/pentesting-smtp/smtp-smuggling.md" sourceUrl: "https://github.com/HackTricks-wiki/hacktricks/blob/188de82beb54e70956b2952367a0af91d26758b8/src/network-services-pentesting/pentesting-smtp/smtp-smuggling.md" sha: "188de82beb54e70956b2952367a0af91d26758b8" isIndex: false modified: true license: "CC-BY-NC-4.0"#

SMTP Smuggling#

Basic Information#

SMTP smuggling exploits disagreement between an outbound SMTP server and a receiving SMTP server about where a DATA body ends. A sequence treated as body text by the first server may be treated as the end-of-data marker by the second, causing following bytes to be parsed as a new SMTP transaction. Depending on the sender, receiver, envelope/header domains, and policy checks, the injected message may bypass SPF-based trust decisions.[1][7]

Why#

The attacker supplies message data containing a nonstandard line-ending sequence. If the sending relay forwards it unchanged while the receiving server recognizes it as a terminator, the receiver parses the remaining bytes as SMTP commands. The original research illustrates that parser differential here:[1]

https://sec-consult.com/fileadmin/user_upload/sec-consult/Dynamisch/Blogartikel/2023_12/SMTP_Smuggling-Overview__09_.png

How#

To exploit this vulnerability, the outbound SMTP server must treat the input as one message while the inbound SMTP server treats it as multiple transactions.

The researchers found servers that disagreed about nonstandard line endings. RFC 5321 defines the end of DATA as <CRLF>.<CRLF>. If the receiver also accepts a variant such as <LF>.<CRLF> while the sender forwards it as body data, bytes after that sequence can begin a second transaction.[1][7]

This works only when the outbound server does not recognize or normalize the same sequence. The exploitable condition is the parser differential between the two hops.[1]

Potential desynchronization data:

SPF may pass when the smuggled envelope sender uses a domain that authorizes the outbound relay's IP. For example, the original research demonstrated changing an envelope identity from user@outlook.com to admin@outlook.com while the message still arrived from an Outlook-authorized relay. DMARC additionally depends on alignment with the visible From domain and on DKIM/SPF results, so SMTP smuggling is not a universal DMARC bypass.[1]


Attacker’s checklist (what conditions must hold?)#

To successfully smuggle a second email, you typically need:[1]

Common end‑of‑DATA variants worth testing (receiver-dependent):

Note: What works is the intersection of “what A forwards” ∩ “what B accepts”.


Schematic Single-Session Example#

The following shows the byte sequence sent after establishing a STARTTLS connection. The \n and \r\n notation below represents actual line-ending bytes, not characters to type literally. OpenSSL's -crlf option normalizes line endings and can destroy the malformed sequence, so generate the payload as bytes and pipe it without -crlf during an authorized test.[1]

Manual smuggling session (STARTTLS)
$ openssl s_client -starttls smtp -quiet -connect smtp.example.com:587 < payload.bin
EHLO a.example
AUTH PLAIN <base64(\0user@example.com\0password)>
MAIL FROM:<user@example.com>
RCPT TO:<victim@target.com>
DATA
From: User <user@example.com>
To: victim <victim@target.com>
Subject: legit

hello A
\n.\r\nMAIL FROM:<admin@target.com>
RCPT TO:<victim@target.com>
DATA
From: Admin <admin@target.com>
To: victim <victim@target.com>
Subject: smuggled

hello B
\r\n.\r\n

If A forwards \n.\r\n and B accepts it as end‑of‑DATA, message “hello B” may be accepted as a second email from admin@target.com while passing SPF (aligned with A’s IPs).

Create payload.bin with Python byte literals so the first message uses normal CRLF while only the candidate terminator contains the intended bare LF. A terminal session cannot reliably express or preserve those distinctions.


Automation and scanners#

These tools help you map the A→B pairs where smuggling actually works.


CHUNKING/BDAT vs DATA#


Notes on affected software and fixes (for targeting)#

Use the scanners above to verify current behavior; many vendors changed defaults in early 2024–2025.


Tips for red team ops#


References#