This release fixes security issues in the SMTP transport and in the message builder. The most serious ones let a man-in-the-middle forge the replies read after STARTTLS, let message content with bare CR or LF line endings inject SMTP commands, and had messages for an address with a quoted local part sent to a different address. The others let a server exhaust memory, keep a CPU core busy or cause a panic. We recommend that everyone updates to the latest patch release.
To fix them lettre got stricter in the few places listed in the upgrade notes. That technically makes for breaking changes, but we expect most projects not to be affected by them.
Upgrade notes
- Addresses with white space or control characters outside of ASCII are rejected
Mailbox::from_strkeeps a quoted local part as it was written, likeAddress::from_strdoes:"d "@example.comis no longer turned intod@example.com. Quoted local parts are now validated the wayAddress::from_strvalidates them- Connecting fails when the server sends anything after its reply to
STARTTLSand before the TLS handshake - Sending fails when the reply to
DATA, or to the message content, is not of the expected class - The
Displayimplementation ofMailboxwrites a CR or LF in the display name as a space
Security
- Fix
STARTTLSresponse injection, where replies sent in cleartext before the TLS handshake were read as if they came over TLS GHSA-q3jf-wmp2-47pg and b404122 - Fix SMTP command injection through message content with bare CR or LF line endings, which was sent without dot-stuffing 3d9a6e6
- Fix
Mailbox::from_strchanging a quoted local part, which had messages sent to a different address than the one given GHSA-62w5-58xq-p27j and f4d5abc - Check the class of the replies to
DATAand to the message content, so that a reply read out of turn can't have the content read as commands or a rejected message reported as sent 04e3ac3 - Fix unbounded memory use reading an SMTP reply line that never ends GHSA-pmvc-x69f-5p9f and 075849f
- Fix quadratic time parsing an SMTP reply made of many short lines GHSA-pmvc-x69f-5p9f and 8146136
- Fix panic formatting a
Mailboxwith a CR or LF in its display name 0ad883c - Fix panic on an
EHLOreply line made of white space only GHSA-23wm-4vvw-r7p2 and 4a58794
Features
- Add
allow_partial_recipientsto the SMTP transport builders, to still send a message when the server rejects some of its recipients #1169
Bug Fixes
- Keep a raw
Dateheader with a timezone other than UTC instead of replacing it with the current date #1162 - Don't add an empty line to messages ending with CRLF when sending them via SMTP #1175
- Fix building with
rustls-platform-verifieron Android #1178 - Don't close pooled connections after every message with the
async-stdSMTP transport #1179 - Cap the memory allocated up front when deserializing an
Envelope#1180 - Only reuse pooled SMTP connections that reply
250toNOOP#1181 - Fix TLS with
AsyncSmtpTransportwhentokio1-boring-tlsis the only TLS feature enabled #1183 - Fix stack overflow in relaxed DKIM header canonicalization when built without optimizations #1184
- Keep the private key out of the
Debugoutput ofDkimSigningKeyandDkimConfig#1184 - Keep the credentials out of the
Debugoutput of the SMTPAuthcommand #1184 - Accept SMTP replies without text after the reply code #1182
- Fix panic when using or closing an SMTP connection after its TLS upgrade failed #1186
- Accept SMTP reply lines longer than 1000 bytes, as sent by Microsoft 365 #1168 and 075849f
- Reject white space and control characters outside of ASCII in addresses b2b3abf
Misc
- Set
TCP_NODELAYon SMTP connections #1159 - Fix building with
-Z direct-minimal-versions#1174 - Bump minimum supported
email-encodingto v0.4.3 #1174 - Bump minimum supported
tokioto v1.18.2 #1174 - Fix the default port of
smtp://URLs in thefrom_urldocs #1177 - Fix stated MSRV in README and crate docs 4483c42
- Report security issues through GitHub's private vulnerability reporting #1164