RFC 3207
SMTP Service Extension for Secure SMTP over Transport Layer Security
RFC 3207: SMTP Service Extension for Secure SMTP over Transport Layer Security ๐
okay bestie, RFC 3207 is from February 2002 ๐ and it's a Standards Track doc, so it's a real spec, not just vibes. It was written by P. Hoffman from the Internet Mail Consortium for the Network Working Group ๐ง and it obsoletes RFC 2487. It doesn't update anything else. Let's get into it ๐
Status of this Memo โจ
this doc is an Internet standards track protocol for the Internet community, and it's asking for discussion and suggestions for improvements ๐ซถ for the standardization state and status of this protocol, check the current "Internet Official Protocol Standards" (STD 1). distribution of this memo is unlimited, so share away ๐ฆ
Copyright Notice ๐ธ
Copyright (C) The Internet Society (2002). All Rights Reserved.
Abstract ๐
this doc describes an extension to SMTP (Simple Mail Transfer Protocol) that lets an SMTP server and client use TLS (Transport Layer Security) to get private, authenticated communication over the Internet ๐ so SMTP agents can protect some or all of their messages from eavesdroppers and attackers. no more letting the nosy people read your mail ๐
1. Introduction ๐ฆ
okay so SMTP [RFC2821] servers and clients normally talk in the clear over the Internet, which is lowkey terrifying ๐ญ a lot of the time that traffic goes through one or more routers that neither side controls or trusts. an untrusted router could let some third party snoop on or mess with the conversation between server and client ๐
it's also really common for two SMTP agents to want to verify each other's identities ๐ชช like, a secure SMTP server might only accept messages from other agents it already knows, or it might treat messages from known agents differently than from strangers. main character behavior ๐
TLS [TLS], more commonly known as SSL, is the popular way to add privacy and authentication on top of TCP ๐ it's everywhere with HTTP, and it's also getting added to a bunch of other protocols that run over TCP. iykyk ๐
this document obsoletes RFC 2487. ๐
1.1 Terminology ๐
The key words "MUST", "MUST NOT", "REQUIRED", "SHALL", "SHALL NOT", "SHOULD", "SHOULD NOT", "RECOMMENDED", "MAY", and "OPTIONAL" in this document are to be interpreted as described in [RFC2119]. โจ
2. STARTTLS Extension ๐
the STARTTLS extension to SMTP is set up like this ๐ง
- (1) the name of the SMTP service defined here is
STARTTLS; - (2) the EHLO keyword value associated with the extension is
STARTTLS; - (3) the STARTTLS keyword has no parameters;
- (4) a new SMTP verb,
STARTTLS, is defined; - (5) no additional parameters are added to any SMTP command.
3. The STARTTLS Keyword ๐
the STARTTLS keyword is how the server tells the client that it's currently able to negotiate TLS ๐ฅ it takes no parameters, so it's giving simple and clean ๐
4. The STARTTLS Command ๐
the format for the STARTTLS command is just this, with no parameters ๐
STARTTLS
after the client sends the STARTTLS command, the server answers with one of these reply codes ๐ง
220 Ready to start TLS
501 Syntax error (no parameters allowed)
454 TLS not available due to temporary reason
if the client gets the 454 response, it's on the client to decide whether to keep the SMTP session going ๐ค that call is based on local policy. for example, if TLS was being used for client authentication, the client might try to keep going, in case the server lets it through even with no authentication. but if TLS was being negotiated for encryption, a client that gets a 454 has to figure out whether to send the message anyway with no TLS encryption, whether to wait and try again later, or whether to give up and tell the sender about the error ๐ญ
a publicly-referenced SMTP server MUST NOT require use of the STARTTLS extension in order to deliver mail locally ๐ซ this rule keeps STARTTLS from wrecking the interoperability of the Internet's SMTP infrastructure, which is a huge deal ๐ a publicly-referenced SMTP server is one that runs on port 25 of an Internet host listed in the MX record (or A record if an MX record is not present) for the domain name on the right hand side of an Internet mail address ๐ฆ
any SMTP server may refuse to accept messages for relay based on authentication supplied during the TLS negotiation ๐ โโ๏ธ and an SMTP server that is not publicly referenced may refuse to accept any messages for relay or local delivery based on authentication supplied during the TLS negotiation. that's its call ๐
a SMTP server that is not publicly referenced may choose to require that the client do a TLS negotiation before accepting any commands ๐ in that case, the server SHOULD return this reply code:
530 Must issue a STARTTLS command first
to every command other than NOOP, EHLO, STARTTLS, or QUIT. if the client and server are using the ENHANCEDSTATUSCODES ESMTP extension [RFC2034], the status code to be returned SHOULD be 5.7.0. โจ
after the client gets a 220 response to a STARTTLS command, it MUST start the TLS negotiation before giving any other SMTP commands ๐ซถ if, after sending STARTTLS, the client finds out some failure is stopping it from actually starting a TLS handshake, then it SHOULD abort the connection. no drama, just bounce ๐
if the SMTP client is using pipelining as defined in RFC 2920, the STARTTLS command must be the last command in a group ๐ง
4.1 Processing After the STARTTLS Command ๐
once the TLS handshake is done, both parties MUST immediately decide whether or not to continue, based on the authentication and privacy they got ๐ช the SMTP client and server may decide to move ahead even if the TLS negotiation ended with no authentication and/or no privacy, because most SMTP services run with no authentication and no privacy. but some clients or servers may only want to continue if a particular level of authentication and/or privacy was achieved ๐
if the SMTP client decides the level of authentication or privacy isn't high enough, it SHOULD issue an SMTP QUIT command right after the TLS negotiation is complete ๐ if the SMTP server decides the same thing, it SHOULD reply to every SMTP command from the client (other than a QUIT command) with the 554 reply code, with a possible text string such as "Command refused due to lack of security" ๐ โโ๏ธ
whether to believe the authenticity of the other party in a TLS negotiation is a local matter ๐ but some general rules for that decision are:
- A SMTP client would probably only want to authenticate an SMTP server whose server certificate has a domain name that is the domain name that the client thought it was connecting to. ๐
- A publicly-referenced SMTP server would probably want to accept any verifiable certificate from an SMTP client, and would possibly want to put distinguishing information about the certificate in the Received header of messages that were relayed or submitted from the client. ๐งพ
4.2 Result of the STARTTLS Command ๐
once the TLS handshake is complete, the SMTP protocol is reset to the initial state (the state in SMTP after a server issues a 220 service ready greeting) ๐ the server MUST discard any knowledge it got from the client, like the argument to the EHLO command, that did NOT come from the TLS negotiation itself. the client MUST discard any knowledge it got from the server, like the list of SMTP service extensions, that did not come from the TLS negotiation itself. the client SHOULD send an EHLO command as the first command after a successful TLS negotiation ๐งน
the list of SMTP service extensions returned in response to an EHLO command received after the TLS handshake MAY be different from the list returned before it ๐ฆ for example, an SMTP server might not want to advertise support for a particular SASL mechanism [SASL] unless a client has sent an appropriate client certificate during the TLS handshake ๐ชช
both the client and the server MUST know if there is a TLS session active ๐ a client MUST NOT attempt to start a TLS session if one is already active, and a server MUST NOT return the STARTTLS extension in response to an EHLO command received after a TLS handshake has completed. no double-wrapping, we don't do that here ๐ โโ๏ธ
4.3 STARTTLS on the Submission Port ๐ฎ
STARTTLS is a valid ESMTP extension when used on the Submission port, as defined in [RFC2476]. and honestly? since the submission port is by definition not a publicly referenced SMTP server, STARTTLS can be super useful there for security and authentication for this service ๐
5. Usage Example ๐
here's a dialog showing how a client and server can start a TLS session ๐ฌ
S: <waits for connection on TCP port 25>
C: <opens connection>
S: 220 mail.imc.org SMTP service ready
C: EHLO mail.example.com
S: 250-mail.imc.org offers a warm hug of welcome
S: 250-8BITMIME
S: 250-STARTTLS
S: 250 DSN
C: STARTTLS
S: 220 Go ahead
C: <starts TLS negotiation>
C & S: <negotiate a TLS session>
C & S: <check result of negotiation>
C: EHLO mail.example.com
S: 250-mail.imc.org touches your hand gently for a moment
S: 250-8BITMIME
S: 250 DSN
6. Security Considerations ๐๐
okay bestie, this section is SERIOUS but also iconic ๐ SMTP is not end-to-end, so if an SMTP client/server pair decides to add TLS privacy, they are NOT securing the transport from the originating mail user agent to the recipient ๐ญ Also, one piece of mail can hop between more than two SMTP servers, so adding TLS to one pair of servers does not mean the whole SMTP chain is private. And just because an SMTP server can authenticate an SMTP client doesn't mean the mail was authenticated by that client when the client received it ๐
Both the SMTP client and server must check the result of the TLS negotiation to see whether an acceptable degree of authentication and privacy was achieved. Skipping this step completely invalidates using TLS for security ๐ Whether the authentication or privacy is acceptable is decided locally, it's implementation-dependent, and it's beyond the scope of this document ๐ง
The SMTP client and server should note carefully the result of the TLS negotiation. If there's no privacy, or the privacy uses algorithms or key lengths that aren't strong enough, or the authentication isn't good enough for either party, the client may choose to end the SMTP session with an immediate QUIT command, or the server may choose to not accept any more SMTP commands ๐ซถ
Man-in-the-middle alert ๐จ An attacker can launch a man-in-the-middle attack by deleting the 250 STARTTLS response from the server. That makes the client not even try to start a TLS session. Another man-in-the-middle attack lets the server announce its STARTTLS capability but alters the client's request to start TLS and the server's response. To defend against attacks like these, both clients and servers MUST be able to be configured to require successful TLS negotiation of an appropriate cipher suite for selected hosts before messages can be successfully transferred. The additional option of using TLS when possible SHOULD also be provided. An implementation MAY provide the ability to record that TLS was used in communicating with a given peer and generate a warning if it is not used in a later session ๐
If the TLS negotiation fails, or the client receives a 454 response, the client has to decide what to do next ๐ค There are three main choices: go ahead with the rest of the SMTP session, retry TLS at a later time, or give up and return the mail to the sender. If a failure or error happens, the client can assume the server may be able to negotiate TLS in the future, so it should try to negotiate TLS in a later session, until some locally-chosen timeout occurs. At that point, the client should return the mail to the sender. However, if the client and server were only using TLS for authentication, the client may want to proceed with the SMTP session, in case some of the operations the client wanted to perform are accepted by the server even if the client is unauthenticated ๐ฆ
Before the TLS handshake has begun, any protocol interactions are performed in the clear and may be modified by an active attacker ๐
For this reason, clients and servers MUST discard any knowledge obtained prior to the start of the TLS handshake upon completion of the TLS handshake. No keeping old info around, periodt ๐งนโจ
The STARTTLS extension is not suitable for authenticating the author of an email message unless every hop in the delivery chain, including the submission to the first SMTP server, is authenticated ๐ โโ๏ธ Another proposal, [SMTP-AUTH], can be used to authenticate delivery, and MIME security multiparts [MIME-SEC] can be used to authenticate the author of an email message. On top of that, the [SMTP-AUTH] proposal offers simpler and more flexible options for authenticating an SMTP client, and the SASL EXTERNAL mechanism [SASL] MAY be used in conjunction with the STARTTLS command to provide an authorization identity ๐ธ
7. References ๐
- [RFC2821] Klensin, J., "Simple Mail Transfer Protocol", RFC 2821, April 2001.
- [RFC2034] Freed, N., "SMTP Service Extension for Returning Enhanced Error Codes", RFC 2034, October 1996.
- [RFC2119] Bradner, S., "Key words for use in RFCs to Indicate Requirement Levels", BCP 14, RFC 2119, March 1997.
- [RFC2476] Gellens, R. and J. Klensin, "Message Submission", RFC 2476, December 1998.
- [SASL] Myers, J., "Simple Authentication and Security Layer (SASL)", RFC 2222, October 1997.
- [SMTP-AUTH] Myers, J., "SMTP Service Extension for Authentication", RFC 2554, March 1999.
- [TLS] Dierks, T. and C. Allen, "The TLS Protocol Version 1.0", RFC 2246, January 1999.
Appendix ๐
This document is a revision of RFC 2487, which is a Proposed Standard. Here's what changed, bestie ๐
- Section 5 and 7: More discussion of the man-in-the-middle attacks
- Section 5: Additional discussion of when a server should and should not advertise the STARTTLS extension
- Section 5: Changed the requirements on SMTP clients after receiving a 220 response.
- Section 5.1: Clarified description of verifying certificates.
- Section 5.3: Added the section on "STARTTLS on the Submission Port"
- Section 6: Bug fix in the example to indicate that the client needs to issue a new EHLO command, as already is described in section 5.2.
- Section 7: Clarification of the paragraph on acceptable degree of privacy. Significant change to the discussion of how to avoid a man-in-the-middle attack.
- Section A: Update reference from RFC 821 to RFC 2821.
Author's Address ๐๏ธ
Paul Hoffman Internet Mail Consortium 127 Segre Place Santa Cruz, CA 95060
Phone: (831) 426-9827 EMail: phoffman@imc.org
Full Copyright Statement โ๏ธ
Copyright (C) The Internet Society (2002). All Rights Reserved.
This document and translations of it may be copied and furnished to others, and derivative works that comment on or otherwise explain it or assist in its implementation may be prepared, copied, published and distributed, in whole or in part, without restriction of any kind, as long as the above copyright notice and this paragraph are included on all such copies and derivative works. However, this document itself may not be modified in any way, such as by removing the copyright notice or references to the Internet Society or other Internet organizations. The exceptions are when it's needed for developing Internet standards, in which case the procedures for copyrights defined in the Internet Standards process must be followed, or when it's required to translate it into languages other than English.
The limited permissions granted above are perpetual and will not be revoked by the Internet Society or its successors or assigns.
This document and the information contained herein is provided on an "AS IS" basis, and THE INTERNET SOCIETY AND THE INTERNET ENGINEERING TASK FORCE DISCLAIMS ALL WARRANTIES, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO ANY WARRANTY THAT THE USE OF THE INFORMATION HEREIN WILL NOT INFRINGE ANY RIGHTS OR ANY IMPLIED WARRANTIES OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE.
Acknowledgement ๐
Funding for the RFC Editor function is currently provided by the Internet Society. ๐
๐ฆ where this page comes from
- ietf: rfc3207 2002-02
- ๐ girlified by claude-haiku-5-5 on : a language model's rewrite of the original, under its terms