skip to content

What was the 2023 SMTP smuggling flaw involving bare line feeds, how do you tell whether your MTA is exposed, and what fixed it?

level: seniorimportance: should knowfreq 21%

answer

  1. two servers, one disagreement
  2. where does the data end?
  3. CR LF only, RFC 5321 2.3.8
  4. December 2023 releases and settings

basics

~20 s

SMTP smuggling (CVE-2023-51764, -51765, -51766): one mail service relayed a non-standard end-of-data sequence built on bare line feeds, and the next took it as the real end, accepting a second message. Patched MTAs end data only at CR LF . CR LF.

solid answer

~40 s

RFC 5321 2.3.8 says lines end only in `CR LF` and clients MUST NOT send a bare `CR` or `LF`, but many servers have long accepted a bare `LF`. The December 2023 smuggling flaw combined two services that disagreed about the end of data: the sending service relayed a non-standard end-of-data marker inside one message, and the receiving service took it as the standard `CR LF . CR LF`, reading what followed as another transaction, so one message became two and the second arrived from the sender's legitimate servers. CVE-2023-51764 covers Postfix, CVE-2023-51765 sendmail through 8.17.2, resolved in 8.18, and CVE-2023-51766 Exim before 4.97.1. To check exposure, compare your MTA's version and its line-ending setting with those fixes; in Postfix that is `smtpd_forbid_bare_newline`, `normalize` by default from 3.9.

go deeper

for a junior

Recall that SMTP lines must end in CR LF and that SMTP smuggling was a 2023 flaw where two mail servers disagreed on where a message ends.

for a middle

Explain the two roles, the service passing a non-standard end marker through and the one honouring it, and why RFC 5321 2.3.8's CR LF rule matters.

for a senior

Check exposure on your own MTA: version against the CVE fixes, the effective setting, the exclusions list, and what your outbound path forwards.

for a principal

Own the decision between normalising and rejecting on the public MX, and the patch window for MTAs that cannot be upgraded at once.

## The rule that was not enforced RFC 5321 2.3.8 defines an SMTP line as data characters ended by `CR LF`, and says conforming implementations MUST NOT recognise any other character or sequence as a line terminator. SMTP clients MUST NOT send a bare `CR` or `LF` except as part of `CR LF`. The end of the message data is a line holding a single period: `CR LF . CR LF`. In practice, many UNIX-based servers accepted a bare `LF` as a line end for decades, for compatibility with programs that relied on that behaviour. Postfix's documentation traces the habit to early sendmail, copied by other servers including Postfix and Exim. As long as every server in a path reads line ends the same way, the leniency is harmless. When two of them differ, it is not. ## The flaw at concept level Published in December 2023, **SMTP smuggling** needs a composition of two mail services: - **Service A**, the sending side, accepts a message from one of its own authenticated users that contains a non-standard end-of-data sequence, and passes that sequence through verbatim when it relays the message. - **Service B**, the receiving side, interprets that non-standard sequence as if it were the standard `CR LF . CR LF`. Service B therefore ends the first message early and reads the remaining text as new SMTP commands and a second message, which service A never checked as a message of its own. The second message comes from service A's IP addresses, so sender-authentication checks tied to that service can pass for it; how those results relate to the visible From domain is a subject of its own. The class of flaw is a **parser differential**: two implementations disagreeing on a protocol boundary. ## Affected implementations and fixes | MTA | Record | What the record says | |---|---|---| | Postfix | CVE-2023-51764 | Postfix through 3.8.5 allows smuggling unless configured with the countermeasures; recent versions have `smtpd_forbid_bare_newline` | | sendmail | CVE-2023-51765 | sendmail through 8.17.2; resolved in 8.18 and later with `o` in `srv_features` | | Exim | CVE-2023-51766 | Exim before 4.97.1, in certain PIPELINING and CHUNKING configurations | Postfix released `smtpd_forbid_bare_newline` with the values `yes` and `no` in 3.8.4, 3.7.9, 3.6.13 and 3.5.23 on 22 December 2023. Releases 3.8.5, 3.7.10, 3.6.14 and 3.5.24 followed in January 2024 with `normalize` and `reject`, and Postfix 3.9 makes `normalize` the default; `yes` is now an alias for `normalize`. Postfix 3.9 also adds `note`, which behaves like `normalize` and logs `notes=bare_lf` for sessions that sent a bare `LF`. Before those releases, Postfix's short-term workaround was to stop unauthorised command pipelining and stop offering `BDAT`: `smtpd_data_restrictions = reject_unauth_pipelining` or `smtpd_forbid_unauth_pipelining = yes`, plus `smtpd_discard_ehlo_keywords = chunking, silent-discard`. Postfix's notes say this blocks many forms of the attack but not a malformed line end, which is what the long-term fix addresses. ## Telling whether you are exposed As the **receiving** side: 1. Check the MTA version against the fixed releases above, including distribution packages that backport fixes. 2. Check the effective setting, not just the file: in Postfix, `postconf smtpd_forbid_bare_newline`. A value of `no`, the default before Postfix 3.9, is the exposed configuration on an internet-facing server. 3. Check the exclusions: `smtpd_forbid_bare_newline_exclusions` defaults to `$mynetworks`, so a wide `mynetworks` leaves more clients unprotected. 4. Treat a scanner's verdict with care. Postfix's documentation warns that some test tools make false vulnerability claims based on non-viable patterns. As the **sending** side, which is service A's role: - RFC 5321 says clients MUST NOT transmit bare `CR` or `LF`. A relay that forwards its users' message text without normalising line ends to `CR LF` can carry the problem to a lenient receiver, so check what your outbound path does with content that arrives with non-standard line ends. ## What the fix changes - The receiver requires the **standard end-of-data sequence**: no other sequence ends the message. - Lines ending in a bare `LF` are either **normalised** to `CR LF` or **rejected** outright; which to choose for a public MX is a policy decision with costs for legitimate senders. - Trusted internal clients can be exempted, so old applications keep working on the inside while the internet-facing listener is strict.

  • Why did the smuggled message pass sender checks at the receiving service?
    Because it really did arrive from the sending service's IP addresses, carrying an envelope sender in a domain hosted there. A check that ties the envelope domain to permitted sending addresses sees a legitimate source. The flaw sits in the dialog's framing, not in the sender-authentication records.
  • Is rejecting pipelining and discarding CHUNKING enough on its own?
    It was Postfix's short-term workaround and stops many forms of the attack, but Postfix's own notes say it does not block a malformed line end. The long-term fix is `smtpd_forbid_bare_newline` set to `normalize` or `reject` on a release that has it.

Two depots pass a sealed parcel along. The first ignores a handwritten 'end of shipment' slip tucked inside; the second treats that slip as the real end and books whatever follows as a separate parcel that nobody checked. The cure is for every depot to recognise only the official end-of-shipment seal.

  • RFC 5321 already makes every server reject bare LF, so no MTA was affected.
  • SMTP smuggling needs only one misconfigured server.
  • A passing SPF result proves the smuggled message came from its sender.
  • Discarding CHUNKING alone fully closes the bare-LF problem.
  • Upgrading the MTA package is enough, whatever the setting's value.