Bookmarks

STARTTLS command

An extension to mail protocols that upgrades an already open plain connection to an encrypted one using TLS.

Also: STARTTLS extension, STARTTLS in SMTP, opportunistic TLS

checked 9 Nov

All terms

Mail protocols began without encryption, and ports and programs are hard to change. STARTTLS solves this: the client connects to the ordinary port, the server announces that it supports TLS, and after the command both sides perform a TLS handshake within the same connection.

What it looks like in SMTP

text
S: 220 mail.example.com ESMTPC: EHLO client.example.orgS: 250-mail.example.comS: 250-STARTTLSS: 250 SIZE 52428800C: STARTTLSS: 220 2.0.0 Ready to start TLS   ... TLS handshake ...C: EHLO client.example.org

After the handshake, both sides discard everything they learned before it, and the client sends EHLO again, this time over the encrypted channel. This is defined in RFC 3207 (Paul Hoffman, February 2002); other protocols, such as IMAP, have their own RFCs for the command.

Ports: STARTTLS and implicit TLS

ProtocolSTARTTLSImplicit TLS
SMTP, client to serverport 587port 465
SMTP, server to serverport 25not used
IMAPport 143port 993

RFC 8314 (January 2018) recommends that mail clients prefer implicit TLS: the connection is encrypted from the first byte. When implementations and settings are correct, the two methods are comparable in security, but port 587 with STARTTLS remains very common.

The weak spot

Between servers, STARTTLS is usually opportunistic: if encryption cannot be negotiated, the message is sent in the clear. An attacker in the middle of the channel can strip the 250 STARTTLS line from the server’s reply, and the client will not try to enable TLS. The defence is to require TLS in client and server settings and, between servers, to publish an MTA-STS policy.

Sources

the term is written from these pages

Verified 9 Nov

Not to be confused with

what it is mixed up with and how it differs

  • TLSTLS protocol

    TLS is the encryption protocol itself, while STARTTLS is only the command that enables it in a connection that has already started.

In depth in the references

where the topic is covered in detail