Guide · SMTP and headers

SMTP smuggling: what it is and how to fix it

SMTP smuggling is an email spoofing technique that works when two mail servers disagree about where a message ends. SMTP ends a message with a line holding only a period, the sequence <CRLF>.<CRLF>. If a sending service passes a non-standard variant such as <LF>.<CR><LF> through unchanged, and the receiving server treats that variant as the end of the message, the receiver reads the rest of the body as new SMTP commands and accepts a second, smuggled message. That message arrives from the sending service's IP address, so it can pass SPF-based DMARC checks for any domain hosted at that service. The technique was made public in December 2023, and CVEs were assigned for Postfix, Sendmail and Exim. The fix belongs in mail servers: update them, turn on strict line-ending handling where it is optional, and ask the providers that run your mail for their status.

Reading time
8 min

How SMTP marks the end of a message

RFC 5321, section 2.3.8, says lines end in CR followed immediately by LF, and that conforming implementations "MUST NOT recognize or generate any other character or character sequence as a line terminator". SMTP clients must not send a bare CR or a bare LF except as part of that pair.

Section 4.1.1.4 defines the end of the mail data as a line containing only a period, the sequence <CRLF>.<CRLF>. It also rules out the lenient reading: accepting lines that end only in LF "has proven to cause more interoperability problems than it solves", servers must not do it, and <LF>.<LF> must not be treated as the end of the mail data.

Ordinary text cannot end a message early, because of the transparency rule in section 4.5.2: before sending a line that starts with a period, the client adds one more period, and the server removes it again. A message can only end early at a server that accepts a line ending other than CRLF, which is where the risk comes from.

How the attack works

Postfix's SMTP smuggling page describes it as a composition of two email services that handle non-standard line endings differently:

RoleWhat goes wrong
Sending service (A)Accepts a message from an authenticated user that contains a non-standard end-of-data sequence in the middle, and forwards it verbatim.
Receiving server (B)Treats the non-standard sequence as the real end of the message, then reads the text after it as SMTP commands.

Both halves are needed. Service B ends up receiving two messages when service A sent only one: the first with the content before the non-standard sequence, the second with whatever followed it. Postfix's page says the vulnerability goes back decades to Sendmail allowing the non-standard LF line ending next to CRLF, a behavior other servers, Postfix and Exim among them, copied for compatibility.

Why the spoofed message passes SPF and DMARC

According to Postfix's page, the attacker can spoof a message from any MAIL FROM address whose domain is hosted at service A, to any recipient whose domain is hosted at service B. The spoofed message passes SPF-based DMARC checks at service B because its MAIL FROM domain is hosted at service A and it arrives from an IP address that belongs to service A.

Nothing about your DNS records is broken in that case. SPF checks whether the connecting server may use the MAIL FROM domain (envelope sender vs From), and here it is one of the servers you authorized. A p=reject policy (DMARC from none to reject) does not stop a message that passes. The weakness is in how the two servers parse the message, so the defense is to fix the servers.

The three CVEs

NVD published all three on 24 December 2023. Each description says remote attackers can use a published exploitation technique to inject messages with a spoofed MAIL FROM address, bypassing an SPF protection mechanism.

CVESoftwareAffected, per NVDFix, per the project
CVE-2023-51764PostfixThrough 3.8.5, unless configured with the workaround settingssmtpd_forbid_bare_newline; see the next section
CVE-2023-51765SendmailThrough 8.17.2, in certain configurations8.18.1 accepts only CRLF . CRLF as the end of a message
CVE-2023-51766EximBefore 4.97.1, in certain PIPELINING/CHUNKING configurations4.97.1 or later

Sendmail. The release notes for 8.18.1 (2024/01/31) say it accepts only CRLF as a line end, and so only CRLF . CRLF as the end of a message, and no longer accepts a CR or LF outside that pair. The new srv_features options O, U and G turn those checks off; the notes recommend doing that only for trusted networks.

Exim. Exim's advisory lists the fixed versions 4.97.1 and 4.98. If you cannot install one, it says to ask your package maintainer for a backported fix. As a workaround it gives disabling the CHUNKING advertisement, or the PIPELINING advertisement, for incoming connections (the EHLO guide shows where a server lists its extensions).

Postfix settings

Postfix has two settings for this, documented in postconf(5):

The yes and no settings arrived in Postfix 3.8.4, 3.7.9, 3.6.13 and 3.5.23; normalize and reject in 3.8.5, 3.7.10, 3.6.14 and 3.5.24. On those older branches the protection is optional and off by default, so an updated package is not enough on its own. The settings Postfix recommends are:

smtpd_forbid_bare_newline = normalize
smtpd_forbid_bare_newline_exclusions = $mynetworks

The exclusion keeps clients in your trusted networks working if they send non-standard line endings. Postfix warns that reject is more likely to refuse legitimate mail, for example from web applications or load balancer health checks. For any Postfix version, its page also gives a short-term workaround that rejects unauthorized command pipelining and removes CHUNKING from the EHLO reply. Patches for releases that are no longer supported are linked from Postfix's download page.

A checklist for mail admins

What senders can do

These are our recommendations. If you only send through email service providers, you have no server to patch. But each service authorized in your SPF record sends from addresses that pass SPF for your domain, so any of them that forwarded a non-standard end-of-data sequence could play the role of service A. Keep that record to the services you still use, ask each one for its status on SMTP smuggling, and keep SPF, DKIM and DMARC in place: an enforced DMARC policy still stops ordinary spoofing from servers you never authorized. A spoofed message that reaches people in your name can also draw complaints that affect your sender reputation.

Questions

Is SMTP smuggling a flaw in SPF or DMARC?

No. SPF and DMARC give the correct answer for what they check: the message did come from a server authorized for the MAIL FROM domain. The flaw is that a receiving server accepted a non-standard end of message, which RFC 5321 forbids.

Does a stricter DMARC policy protect my domain?

Not against this. Postfix's page says the spoofed message passes SPF-based DMARC checks at the receiving service, so a quarantine or reject policy is never applied to it. Patching and configuring the receiving servers is what stops it.

I updated Postfix. Am I protected?

Postfix 3.9 and later turn the protection on by default. On 3.8.5, 3.7.10, 3.6.14 and 3.5.24, and the earlier fixed versions, the long-term protection is an option that is off by default: set smtpd_forbid_bare_newline, then confirm the value the server actually uses.

Will the stricter settings block legitimate mail?

normalize keeps compatibility with many clients that mix line endings: it still accepts bare LF line endings and only requires the standard end-of-data sequence, so it fails only with clients that do not end the message with <CRLF>.<CRLF>. reject refuses more. For both, Postfix's examples exclude trusted networks with smtpd_forbid_bare_newline_exclusions.

Sources

How we wrote this: drafted by the email-validation.org team with the help of AI writing tools, from our product documentation and the sources linked in the text.

Get up to 500 free credits. No card needed.

New accounts get 500 free credits (100 when you sign up with a free email provider such as Gmail, Outlook or Yahoo, another personal mailbox such as a paid one like Fastmail or one from your internet provider, or an address from a relay or alias service). Try it on your own list before you buy.

Updated · Maintained by: Email Validation LLC