1
2
3
4
5
6
7Network Working Group P. Hoffman
8Request for Comments: 3207 Internet Mail Consortium
9Obsoletes: 2487 February 2002
10Category: Standards Track
11
12
13 SMTP Service Extension for
14 Secure SMTP over Transport Layer Security
15
16Status of this Memo
17
18 This document specifies an Internet standards track protocol for the
19 Internet community, and requests discussion and suggestions for
20 improvements. Please refer to the current edition of the "Internet
21 Official Protocol Standards" (STD 1) for the standardization state
22 and status of this protocol. Distribution of this memo is unlimited.
23
24Copyright Notice
25
26 Copyright (C) The Internet Society (2002). All Rights Reserved.
27
28Abstract
29
30 This document describes an extension to the SMTP (Simple Mail
31 Transfer Protocol) service that allows an SMTP server and client to
32 use TLS (Transport Layer Security) to provide private, authenticated
33 communication over the Internet. This gives SMTP agents the ability
34 to protect some or all of their communications from eavesdroppers and
35 attackers.
36
371. Introduction
38
39 SMTP [RFC2821] servers and clients normally communicate in the clear
40 over the Internet. In many cases, this communication goes through
41 one or more router that is not controlled or trusted by either
42 entity. Such an untrusted router might allow a third party to
43 monitor or alter the communications between the server and client.
44
45 Further, there is often a desire for two SMTP agents to be able to
46 authenticate each others' identities. For example, a secure SMTP
47 server might only allow communications from other SMTP agents it
48 knows, or it might act differently for messages received from an
49 agent it knows than from one it doesn't know.
50
51
52
53
54
55
56
57
58Hoffman Standards Track [Page 1]
59
60RFC 3207 SMTP Service Extension - Secure SMTP over TLS February 2002
61
62
63 TLS [TLS], more commonly known as SSL, is a popular mechanism for
64 enhancing TCP communications with privacy and authentication. TLS is
65 in wide use with the HTTP protocol, and is also being used for adding
66 security to many other common protocols that run over TCP.
67
68 This document obsoletes RFC 2487.
69
701.1 Terminology
71
72 The key words "MUST", "MUST NOT", "REQUIRED", "SHALL", "SHALL NOT",
73 "SHOULD", "SHOULD NOT", "RECOMMENDED", "MAY", and "OPTIONAL" in this
74 document are to be interpreted as described in [RFC2119].
75
762. STARTTLS Extension
77
78 The STARTTLS extension to SMTP is laid out as follows:
79
80 (1) the name of the SMTP service defined here is STARTTLS;
81
82 (2) the EHLO keyword value associated with the extension is STARTTLS;
83
84 (3) the STARTTLS keyword has no parameters;
85
86 (4) a new SMTP verb, "STARTTLS", is defined;
87
88 (5) no additional parameters are added to any SMTP command.
89
903. The STARTTLS Keyword ../smtpserver/server.go:862
91
92 The STARTTLS keyword is used to tell the SMTP client that the SMTP
93 server is currently able to negotiate the use of TLS. It takes no
94 parameters.
95
964. The STARTTLS Command ../smtpserver/server.go:889
97
98 The format for the STARTTLS command is:
99
100 STARTTLS
101
102 with no parameters.
103
104 After the client gives the STARTTLS command, the server responds with
105 one of the following reply codes:
106
107 220 Ready to start TLS ../smtpclient/client.go:759
108 501 Syntax error (no parameters allowed)
109 454 TLS not available due to temporary reason
110
111
112
113
114Hoffman Standards Track [Page 2]
115
116RFC 3207 SMTP Service Extension - Secure SMTP over TLS February 2002
117
118
119 If the client receives the 454 response, the client must decide
120 whether or not to continue the SMTP session. Such a decision is
121 based on local policy. For instance, if TLS was being used for
122 client authentication, the client might try to continue the session,
123 in case the server allows it even with no authentication. However,
124 if TLS was being negotiated for encryption, a client that gets a 454
125 response needs to decide whether to send the message anyway with no
126 TLS encryption, whether to wait and try again later, or whether to
127 give up and notify the sender of the error.
128
129 A publicly-referenced SMTP server MUST NOT require use of the
130 STARTTLS extension in order to deliver mail locally. This rule
131 prevents the STARTTLS extension from damaging the interoperability of
132 the Internet's SMTP infrastructure. A publicly-referenced SMTP
133 server is an SMTP server which runs on port 25 of an Internet host
134 listed in the MX record (or A record if an MX record is not present)
135 for the domain name on the right hand side of an Internet mail
136 address.
137
138 Any SMTP server may refuse to accept messages for relay based on
139 authentication supplied during the TLS negotiation. An SMTP server
140 that is not publicly referenced may refuse to accept any messages for
141 relay or local delivery based on authentication supplied during the
142 TLS negotiation.
143
144 A SMTP server that is not publicly referenced may choose to require
145 that the client perform a TLS negotiation before accepting any
146 commands. In this case, the server SHOULD return the reply code:
147
148 530 Must issue a STARTTLS command first 4954:623 ../smtp/codes.go:34 ../smtpserver/server.go:796
149
150 to every command other than NOOP, EHLO, STARTTLS, or QUIT. If the
151 client and server are using the ENHANCEDSTATUSCODES ESMTP extension
152 [RFC2034], the status code to be returned SHOULD be 5.7.0.
153
154 After receiving a 220 response to a STARTTLS command, the client MUST
155 start the TLS negotiation before giving any other SMTP commands. If,
156 after having issued the STARTTLS command, the client finds out that
157 some failure prevents it from actually starting a TLS handshake, then
158 it SHOULD abort the connection.
159
160 If the SMTP client is using pipelining as defined in RFC 2920, the
161 STARTTLS command must be the last command in a group.
162
163
164
165
166
167
168
169
170Hoffman Standards Track [Page 3]
171
172RFC 3207 SMTP Service Extension - Secure SMTP over TLS February 2002
173
174
1754.1 Processing After the STARTTLS Command
176
177 After the TLS handshake has been completed, both parties MUST
178 immediately decide whether or not to continue based on the
179 authentication and privacy achieved. The SMTP client and server may
180 decide to move ahead even if the TLS negotiation ended with no
181 authentication and/or no privacy because most SMTP services are
182 performed with no authentication and no privacy, but some SMTP
183 clients or servers may want to continue only if a particular level of
184 authentication and/or privacy was achieved.
185
186 If the SMTP client decides that the level of authentication or
187 privacy is not high enough for it to continue, it SHOULD issue an
188 SMTP QUIT command immediately after the TLS negotiation is complete.
189 If the SMTP server decides that the level of authentication or
190 privacy is not high enough for it to continue, it SHOULD reply to
191 every SMTP command from the client (other than a QUIT command) with
192 the 554 reply code (with a possible text string such as "Command
193 refused due to lack of security").
194
195 The decision of whether or not to believe the authenticity of the
196 other party in a TLS negotiation is a local matter. However, some
197 general rules for the decisions are:
198
199 - A SMTP client would probably only want to authenticate an SMTP
200 server whose server certificate has a domain name that is the
201 domain name that the client thought it was connecting to.
202 - A publicly-referenced SMTP server would probably want to accept
203 any verifiable certificate from an SMTP client, and would possibly
204 want to put distinguishing information about the certificate in
205 the Received header of messages that were relayed or submitted
206 from the client.
207
2084.2 Result of the STARTTLS Command
209
210 Upon completion of the TLS handshake, the SMTP protocol is reset to ../smtpserver/server.go:346 ../smtpserver/server.go:933
211 the initial state (the state in SMTP after a server issues a 220
212 service ready greeting). The server MUST discard any knowledge
213 obtained from the client, such as the argument to the EHLO command,
214 which was not obtained from the TLS negotiation itself. The client
215 MUST discard any knowledge obtained from the server, such as the list
216 of SMTP service extensions, which was not obtained from the TLS
217 negotiation itself. The client SHOULD send an EHLO command as the
218 first command after a successful TLS negotiation.
219
220 The list of SMTP service extensions returned in response to an EHLO
221 command received after the TLS handshake MAY be different than the
222 list returned before the TLS handshake. For example, an SMTP server
223
224
225
226Hoffman Standards Track [Page 4]
227
228RFC 3207 SMTP Service Extension - Secure SMTP over TLS February 2002
229
230
231 might not want to advertise support for a particular SASL mechanism
232 [SASL] unless a client has sent an appropriate client certificate
233 during a TLS handshake.
234
235 Both the client and the server MUST know if there is a TLS session ../smtpserver/server.go:895
236 active. A client MUST NOT attempt to start a TLS session if a TLS
237 session is already active. A server MUST NOT return the STARTTLS ../smtpserver/server.go:860
238 extension in response to an EHLO command received after a TLS
239 handshake has completed.
240
2414.3 STARTTLS on the Submission Port
242
243 STARTTLS is a valid ESMTP extension when used on the Submission port,
244 as defined in [RFC2476]. In fact, since the submission port is by
245 definition not a publicly referenced SMTP server, the STARTTLS
246 extension can be particularly useful by providing security and
247 authentication for this service.
248
2495. Usage Example
250
251 The following dialog illustrates how a client and server can start a
252 TLS session:
253
254 S: <waits for connection on TCP port 25>
255 C: <opens connection>
256 S: 220 mail.imc.org SMTP service ready
257 C: EHLO mail.example.com
258 S: 250-mail.imc.org offers a warm hug of welcome
259 S: 250-8BITMIME
260 S: 250-STARTTLS
261 S: 250 DSN
262 C: STARTTLS
263 S: 220 Go ahead
264 C: <starts TLS negotiation>
265 C & S: <negotiate a TLS session>
266 C & S: <check result of negotiation>
267 C: EHLO mail.example.com
268 S: 250-mail.imc.org touches your hand gently for a moment
269 S: 250-8BITMIME
270 S: 250 DSN
271
2726. Security Considerations
273
274 It should be noted that SMTP is not an end-to-end mechanism. Thus,
275 if an SMTP client/server pair decide to add TLS privacy, they are not
276 securing the transport from the originating mail user agent to the
277 recipient. Further, because delivery of a single piece of mail may
278 go between more than two SMTP servers, adding TLS privacy to one pair
279
280
281
282Hoffman Standards Track [Page 5]
283
284RFC 3207 SMTP Service Extension - Secure SMTP over TLS February 2002
285
286
287 of servers does not mean that the entire SMTP chain has been made
288 private. Further, just because an SMTP server can authenticate an
289 SMTP client, it does not mean that the mail from the SMTP client was
290 authenticated by the SMTP client when the client received it.
291
292 Both the SMTP client and server must check the result of the TLS
293 negotiation to see whether an acceptable degree of authentication and
294 privacy was achieved. Ignoring this step completely invalidates
295 using TLS for security. The decision about whether acceptable
296 authentication or privacy was achieved is made locally, is
297 implementation-dependent, and is beyond the scope of this document.
298
299 The SMTP client and server should note carefully the result of the
300 TLS negotiation. If the negotiation results in no privacy, or if it
301 results in privacy using algorithms or key lengths that are deemed
302 not strong enough, or if the authentication is not good enough for
303 either party, the client may choose to end the SMTP session with an
304 immediate QUIT command, or the server may choose to not accept any
305 more SMTP commands.
306
307 A man-in-the-middle attack can be launched by deleting the "250
308 STARTTLS" response from the server. This would cause the client not
309 to try to start a TLS session. Another man-in-the-middle attack is
310 to allow the server to announce its STARTTLS capability, but to alter
311 the client's request to start TLS and the server's response. In
312 order to defend against such attacks both clients and servers MUST be
313 able to be configured to require successful TLS negotiation of an
314 appropriate cipher suite for selected hosts before messages can be
315 successfully transferred. The additional option of using TLS when
316 possible SHOULD also be provided. An implementation MAY provide the
317 ability to record that TLS was used in communicating with a given
318 peer and generating a warning if it is not used in a later session.
319
320 If the TLS negotiation fails or if the client receives a 454
321 response, the client has to decide what to do next. There are three
322 main choices: go ahead with the rest of the SMTP session, retry TLS
323 at a later time, or give up and return the mail to the sender. If a
324 failure or error occurs, the client can assume that the server may be
325 able to negotiate TLS in the future, and should try negotiate TLS in
326 a later session, until some locally-chosen timeout occurs, at which
327 point, the client should return the mail to the sender. However, if
328 the client and server were only using TLS for authentication, the
329 client may want to proceed with the SMTP session, in case some of the
330 operations the client wanted to perform are accepted by the server
331 even if the client is unauthenticated.
332
333 Before the TLS handshake has begun, any protocol interactions are
334 performed in the clear and may be modified by an active attacker.
335
336
337
338Hoffman Standards Track [Page 6]
339
340RFC 3207 SMTP Service Extension - Secure SMTP over TLS February 2002
341
342
343 For this reason, clients and servers MUST discard any knowledge
344 obtained prior to the start of the TLS handshake upon completion of
345 the TLS handshake.
346
347 The STARTTLS extension is not suitable for authenticating the author
348 of an email message unless every hop in the delivery chain, including
349 the submission to the first SMTP server, is authenticated. Another
350 proposal [SMTP-AUTH] can be used to authenticate delivery and MIME
351 security multiparts [MIME-SEC] can be used to authenticate the author
352 of an email message. In addition, the [SMTP-AUTH] proposal offers
353 simpler and more flexible options to authenticate an SMTP client and
354 the SASL EXTERNAL mechanism [SASL] MAY be used in conjunction with
355 the STARTTLS command to provide an authorization identity.
356
3577. References
358
359 [RFC2821] Klensin, J., "Simple Mail Transfer Protocol", RFC 2821,
360 April 2001.
361
362 [RFC2034] Freed, N., "SMTP Service Extension for Returning Enhanced
363 Error Codes", RFC 2034, October 1996.
364
365 [RFC2119] Bradner, S., "Key words for use in RFCs to Indicate
366 Requirement Levels", BCP 14, RFC 2119, March 1997.
367
368 [RFC2476] Gellens, R. and J. Klensin, "Message Submission", RFC
369 2476, December 1998.
370
371 [SASL] Myers, J., "Simple Authentication and Security Layer
372 (SASL)", RFC 2222, October 1997.
373
374 [SMTP-AUTH] Myers, J., "SMTP Service Extension for Authentication",
375 RFC 2554, March 1999.
376
377 [TLS] Dierks, T. and C. Allen, "The TLS Protocol Version 1.0",
378 RFC 2246, January 1999.
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394Hoffman Standards Track [Page 7]
395
396RFC 3207 SMTP Service Extension - Secure SMTP over TLS February 2002
397
398
399Appendix
400
401 This document is a revision of RFC 2487, which is a Proposed
402 Standard. The changes from that document are:
403
404 - Section 5 and 7: More discussion of the man-in-the-middle attacks
405 - Section 5: Additional discussion of when a server should and
406 should not advertise the STARTTLS extension
407 - Section 5: Changed the requirements on SMTP clients after
408 receiving a 220 response.
409 - Section 5.1: Clarified description of verifying certificates.
410 - Section 5.3: Added the section on "STARTTLS on the Submission
411 Port"
412 - Section 6: Bug fix in the example to indicate that the client
413 needs to issue a new EHLO command, as already is described in
414 section 5.2.
415 - Section 7: Clarification of the paragraph on acceptable degree of
416 privacy. Significant change to the discussion of how to avoid a
417 man-in-the-middle attack.
418 - Section A: Update reference from RFC 821 to RFC 2821.
419
420Author's Address
421
422 Paul Hoffman
423 Internet Mail Consortium
424 127 Segre Place
425 Santa Cruz, CA 95060
426
427 Phone: (831) 426-9827
428 EMail: phoffman@imc.org
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450Hoffman Standards Track [Page 8]
451
452RFC 3207 SMTP Service Extension - Secure SMTP over TLS February 2002
453
454
455Full Copyright Statement
456
457 Copyright (C) The Internet Society (2002). All Rights Reserved.
458
459 This document and translations of it may be copied and furnished to
460 others, and derivative works that comment on or otherwise explain it
461 or assist in its implementation may be prepared, copied, published
462 and distributed, in whole or in part, without restriction of any
463 kind, provided that the above copyright notice and this paragraph are
464 included on all such copies and derivative works. However, this
465 document itself may not be modified in any way, such as by removing
466 the copyright notice or references to the Internet Society or other
467 Internet organizations, except as needed for the purpose of
468 developing Internet standards in which case the procedures for
469 copyrights defined in the Internet Standards process must be
470 followed, or as required to translate it into languages other than
471 English.
472
473 The limited permissions granted above are perpetual and will not be
474 revoked by the Internet Society or its successors or assigns.
475
476 This document and the information contained herein is provided on an
477 "AS IS" basis and THE INTERNET SOCIETY AND THE INTERNET ENGINEERING
478 TASK FORCE DISCLAIMS ALL WARRANTIES, EXPRESS OR IMPLIED, INCLUDING
479 BUT NOT LIMITED TO ANY WARRANTY THAT THE USE OF THE INFORMATION
480 HEREIN WILL NOT INFRINGE ANY RIGHTS OR ANY IMPLIED WARRANTIES OF
481 MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE.
482
483Acknowledgement
484
485 Funding for the RFC Editor function is currently provided by the
486 Internet Society.
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506Hoffman Standards Track [Page 9]
507
508