Network Working Group Robert Siemborski INTERNET-DRAFT Carnegie Mellon University Intended Category: Proposed Standard November, 2003 SMTP Service Extension for Authentication Status of this Memo This document is an Internet-Draft and is in full conformance with all provisions of Section 10 of RFC2026. Internet-Drafts are working documents of the Internet Task Force (IETF), its areas, and its working groups. Note that other groups may also distribute working documents as Internet-Drafts. Internet-Drafts are draft documents valid for a maximum of six months and may be updated, replaced, or obsoleted by other documents at any time. It is inappropriate to use Internet Drafts as reference material or to cite them other than as "work in progress." The list of current Internet-Drafts can be accessed at http://www.ietf.org/ietf/1id-abstracts.txt The list of Internet-Draft Shadow Directories can be accessed at http://www.ietf.org/shadow.html. Distribution of this memo is unlimited. Abstract This document defines a Simple Mail Transport Protocol (SMTP) extension whereby an SMTP client may indicate an authentication mechanism to the server, perform an authentication protocol exchange, and optionally negotiate a security layer for subsequent protocol interactions during this session. This extension includes a profile of the Simple Authentication and Security Layer (SASL) for SMTP. This document obsoletes RFC 2554 and replaces it as a Proposed Standard. 1. How to Read This Document The key words "MUST", "MUST NOT", "REQUIRED", "SHOULD", "SHOULD NOT", "RECOMMENDED", and "MAY" in this document are to be interpreted as defined in "Key words for use in RFCs to Indicate Siemborski Expires April, 2004 [Page 1] SMTP Service Extension for Authentication November, 2003 Table of Contents 1. How to Read This Document . . . . . . . . . . . . . . . . . . . . 1 2. The Authentication Service Extension . . . . . . . . . . . . . . 3 3. The AUTH Command . . . . . . . . . . . . . . . . . . . . . . . . 3 3.1. Examples . . . . . . . . . . . . . . . . . . . . . . . . . . . 2 4. The AUTH Parameter to the MAIL FROM command . . . . . . . . . . . 7 4.1. Examples . . . . . . . . . . . . . . . . . . . . . . . . . . . 2 5. Error Codes . . . . . . . . . . . . . . . . . . . . . . . . . . . 9 6. Formal Syntax . . . . . . . . . . . . . . . . . . . . . . . . . . 10 7. Security Considerations . . . . . . . . . . . . . . . . . . . . . 11 8. IANA Considerations . . . . . . . . . . . . . . . . . . . . . . . 12 9. Protocol Actions . . . . . . . . . . . . . . . . . . . . . . . . 13 10. Intellectual Property Rights . . . . . . . . . . . . . . . . . . 13 11. Copyright . . . . . . . . . . . . . . . . . . . . . . . . . . . 13 12. References . . . . . . . . . . . . . . . . . . . . . . . . . . . 14 13. Changes Since RFC 2554 . . . . . . . . . . . . . . . . . . . . . 16 14. Author's Address . . . . . . . . . . . . . . . . . . . . . . . . 16 15. Acknowledgments . . . . . . . . . . . . . . . . . . . . . . . . 16 Siemborski Expires April, 2004 [Page 2] SMTP Service Extension for Authentication November, 2003 Requirement Levels" [KEYWORDS] In examples, "C:" and "S:" indicate lines sent by the client and server, respectively. 2. The Authentication Service Extension 1. The name of this [SMTP] service extension is "Authentication" 2. The EHLO keyword value associated with this extension is "AUTH" 3. The AUTH EHLO keyword contains as a parameter a space separated list of the names of available [SASL] mechanisms. The list of available mechanisms MAY change after a successful STARTTLS command [SMTP-TLS]. 4. A new [SMTP] verb "AUTH" is defined. 5. An optional parameter using the keyword "AUTH" is added to the MAIL FROM command, and extends the maximum line length of the MAIL FROM command by 500 characters. 6. This extension is appropriate for the submission protocol [SUBMIT]. 3. The AUTH Command AUTH mechanism [initial-response] Arguments: mechanism: A string identifying a [SASL] authentication mechanism. initial-response: An optional initial client response. If present, this response MUST be [BASE64] encoded. Restrictions: After an AUTH command has been successfully completed, no more AUTH commands may be issued in the same session. After a successful AUTH command completes, a server MUST reject any further AUTH commands with a 503 reply. The AUTH command is not permitted during a mail transaction. Discussion: The AUTH command initiates a [SASL] authentication exchange between the client and the server. The client identifies the Siemborski Expires April, 2004 [Page 3] SMTP Service Extension for Authentication November, 2003 SASL mechanism to use with the first parameter of the AUTH command. If the server supports the requested authentication mechanism, it performs the SASL exchange to authenticate the user. Optionally, it also negotiates a security layer for subsequent protocol interactions during this session. If the requested authentication mechanism is not supported, the server rejects the AUTH command with a 504 reply. The authentication protocol exchange consists of a series of server challenges and client responses that are specific to the chosen [SASL] mechanism. A server challenge is sent as a 334 reply with the text part containing the [BASE64] encoded string supplied by the SASL mechanism. This challenge MUST NOT contain any text other than the BASE64 encoded challenge. A client response consists of a line containing a [BASE64] encoded string. If the client wishes to cancel the authentication exchange, it issues a line with a single "*". If the server receives such a response, it MUST reject the AUTH command by sending a 501 reply. The optional initial response argument to the AUTH command is used to save a round trip when using authentication mechanisms that support an initial client response. If the initial response argument is omitted and the chosen mechanism requires an initial client response, the server MUST proceed as defined in section 5.1 of [SASL]. In SMTP, a server challenge that contains no data is defined as a 334 reply with no text part. Note that there is still a space following the reply code, so the full response line is "334 ". If the client needs to send a zero length initial response, the client MUST transmit the response as a single equals sign ("="). This indicates that the response is present, but contains no data. If the client uses an initial-response argument to the AUTH command with a SASL mechanism that does not support an initial client send, the server MUST reject the AUTH command with a 535 reply. If the server cannot [BASE64] decode any client response, it MUST reject the AUTH command with a 501 reply. If the client cannot BASE64 decode any of the server's challenges, it MUST cancel the authentication using the "*" response. In particular, servers and clients MUST reject (and not ignore) Siemborski Expires April, 2004 [Page 4] SMTP Service Extension for Authentication November, 2003 any character not explicitly allowed by the BASE64 alphabet, and MUST reject any sequence of BASE64 characters that contains the pad character ('=') anywhere other than the end of the string (e.g. "=AAA" and "AAA=BBB" are not allowed). Note that these [BASE64] strings may be of arbitrarily length. Clients and servers MUST be able to handle the maximum encoded size of challenges and responses generated by their supported authentication mechanisms. This requirement is independent of any line length limitations the client or server may have in other parts of its protocol implementation. The authorization identity generated by this [SASL] exchange is a simple username, and MUST use the [SASLprep] profile of the [StringPrep] algorithm to prepare these names for matching. If preparation of the authorization identity fails, the server MUST fail the authentication. If the server is unable to authenticate the client, it SHOULD reject the AUTH command with a 535 reply unless a more specific error code, such as one listed in Section 5, is appropriate. Should the client successfully complete the exchange, the SMTP server issues a 235 reply. If a security layer is negotiated during the SASL exchange, it takes effect for the client on the octet immediately following the CRLF that concludes the last response generated by the client. For the server, it takes effect immediately following the CRLF of its success reply. When a security layer takes effect, 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 obtained from the client, such as the EHLO argument, which was not obtained from the SASL negotiation itself. Likewise, the client MUST discard any knowledge obtained from the server, such as the list of SMTP service extensions, which was not obtained from the SASL negotiation itself (Note that a client MAY compare the advertised SASL mechanisms before and after authentication in order to detect an active down- negotiation attack). The client SHOULD send an EHLO command as the first command after a successful SASL negotiation which results in the enabling of a security layer. When both [TLS] and SASL security layers are in effect, the TLS encoding MUST be applied after the SASL encoding, Siemborski Expires April, 2004 [Page 5] SMTP Service Extension for Authentication November, 2003 regardless of the order in which the layers were negotiated. The service name specified by this protocol's profile of SASL is "smtp". If an AUTH command fails, the client may try another authentication mechanism or present different credentials by issuing another AUTH command. Likewise, the server MUST behave as if the client had not issued the AUTH command. To ensure interoperability, client and server implementations of this extension MUST implement the STARTTLS Extension [SMTP- TLS], and the [PLAIN] SASL mechanism. Implementations MUST support a configuration where SASL mechanisms that are vulnerable to passive eavesdropping attacks are not advertised or used without the presence of an external security layer such as [TLS]. 3.1. Examples Here is an example of a client attempting AUTH PLAIN under TLS and making use of the initial client response: S: 220-smtp.example.com ESMTP Server C: EHLO client.example.com S: 250-smtp.example.com Hello client.example.com, pleased to meet you S: 250-AUTH GSSAPI S: 250-STARTTLS C: STARTTLS S: 220 Ready to start TLS ... TLS negotiation proceeds, further commands protected by TLS layer ... C: EHLO client.example.com S: 250-smtp.example.com Hello client.example.com, pleased to meet you S: 250-AUTH KERBEROS_V4 GSSAPI PLAIN C: AUTH PLAIN dGVzdAB0ZXN0ADEyMzQ= S: 235 Authentication successful Here is another client that is attempting AUTH PLAIN under a TLS layer, this time without the initial response. Parts of the negotiation before the TLS layer was established have been omitted: Siemborski Expires April, 2004 [Page 6] SMTP Service Extension for Authentication November, 2003 ... TLS negotiation proceeds, further commands protected by TLS layer ... C: EHLO client.example.com S: 250-smtp.example.com Hello client.example.com, pleased to meet you S: 250-AUTH KERBEROS_V4 GSSAPI PLAIN C: AUTH PLAIN (note that there is a single space following the 334 on the following line) S: 334 C: dGVzdAB0ZXN0ADEyMzQ= S: 235 Authentication successful Here is an example using a mechanism which does not support an initial client send, and includes server challenges: S: 220-smtp.example.com ESMTP Server C: EHLO client.example.com S: 250-smtp.example.com Hello client.example.com, pleased to meet you S: 250-AUTH KERBEROS_V4 S: 250-STARTTLS C: AUTH KERBEROS_V4 S: 334 asYNKQ== (the following lines are broken for editorial clarity only) C: BAYFQU5EUkVXLkNNVS5FRFUAOCCNPBDBLMcPZH4tgQ5hEI4XrsVr0xzDubFTzrKypQ oxLifPkfRootCpSkFvF+4K3DSnAaok9mQLYW+3MqyH5XmxyKraLHYKtyeRXX0u/X1V O1eJBGBZLmVE S: 334 /HEaZgpK4VA= C: 8YDkh5Lu3cB09Pso3dIRmg== S: 235 Authentication successful ... a security layer has been established, so the client re-issues the EHLO command ... C: EHLO client.example.com S: 250-smtp.example.com Hello client.example.com, pleased to meet you S: 250-AUTH KERBEROS_V4 S: 250-STARTTLS 4. The AUTH Parameter to the MAIL FROM command AUTH=addr-spec Arguments: An addr-spec (see section 3.4.1 or [RFC2822]) that names the identity which submitted the message to the delivery system, or the two character sequence "<>" indicating such an identity is unknown or insufficiently authenticated. To comply with restrictions imposed on ESMTP parameters, the addr-spec is encoded inside an xtext. The syntax of an xtext is described in Section 5 of [ESMTP-DSN]. Siemborski Expires April, 2004 [Page 7] SMTP Service Extension for Authentication November, 2003 Note: For the purposes of this discussion, "authenticated identity" refers to the identity (if any) derived from the authorization identity of previous AUTH command, while the terms "authorized identity" and "supplied addr-spec" refer to the sender identity that is being associated with a particular message. Note that one authenticated identity may be able to identify messages as being sent by any number of authorized identities within a single session. For example, this may be the case when an SMTP server (one authenticated identity) is processing its queue (many messages with distinct authorized identities). Discussion: The optional AUTH parameter to the MAIL FROM command allows cooperating agents in a trusted environment to communicate the authorization identity associated with individual messages. If the server trusts the authenticated identity of the client to assert that the message was originally submitted by the supplied addr-spec, then the server SHOULD supply the same addr-spec in an AUTH parameter when relaying the message to any other server which supports the AUTH extension. For this reason, servers that advertise support for this extension MUST support the AUTH parameter to the MAIL FROM command even when the client has not authenticated itself to the server. A MAIL FROM parameter of AUTH=<> indicates that the original submitter of the message is not known. The server MUST NOT treat the message as having been originally submitted by authenticated identity which resulted from the AUTH command. If the AUTH parameter to the MAIL FROM command is not supplied, the client has authenticated, and the server believes the message is an original submission, the server MAY generate an addr-spec from the user's authenticated identity for use in an AUTH parameter when relaying the message to any server which supports the AUTH extension. The generated addr-spec is implementation specific, but it MUST conform to the syntax of [RFC2822]. If the implementation cannot generate a valid addr- spec, it MUST transmit AUTH=<> when relaying this message. If the server does not sufficiently trust the authenticated identity of the client, or if the client is not authenticated, then the server MUST behave as if the AUTH=<> parameter was supplied. The server MAY, however, write the value of any supplied AUTH parameter to a log file. Siemborski Expires April, 2004 [Page 8] SMTP Service Extension for Authentication November, 2003 If an AUTH=<> parameter was supplied, either explicitly or due to the requirement in the previous paragraph, then the server MUST supply the AUTH=<> parameter when relaying the message to any server which it has authenticated to using the AUTH extension. A server MAY treat expansion of a mailing list as a new submission, setting the AUTH parameter to the mailing list address or mailing list administration address when relaying the message to list subscribers. Note that an implementation which is hard-coded to treat all clients as being insufficiently trusted is compliant with this specification. In that case, the implementation does nothing more than parse and discard syntactically valid AUTH parameters to the MAIL FROM command, and supply AUTH=<> parameters to any servers which it authenticates to. 4.1. Example An example where the original identity of the sender is trusted and known: C: MAIL FROM: AUTH=e+3Dmc2@example.com S: 250 OK One example where the identity of the sender is not trusted or is otherwise being suppressed by the client: C: MAIL FROM: AUTH=<> S: 250 OK 5. Error Codes The following error codes may be used to indicate various failure conditions: 432 A password transition is needed This response to the AUTH command indicates that the user needs to transition to the selected authentication mechanism. This is typically done by authenticating once using the [PLAIN] authentication mechanism. The selected mechanism SHOULD then work for authentications in subsequent sessions. 534 Authentication mechanism is too weak Siemborski Expires April, 2004 [Page 9] SMTP Service Extension for Authentication November, 2003 This response to the AUTH command indicates that the selected authentication mechanism is weaker than server policy permits for that user. 538 Encryption required for requested authentication mechanism This response to the AUTH command indicates that the selected authentication mechanism may only be used when the underlying SMTP connection is encrypted. Note that this response code is documented here for historical purposes only. Modern implementations SHOULD NOT advertise mechanisms that are not permitted due to lack of encryption, unless an encryption layer of sufficient strength is currently being employed. 454 Temporary authentication failure This response to the AUTH command indicates that the authentication failed due to a temporary server failure. 530 Authentication required This response SHOULD be returned by any command other than AUTH, EHLO, HELO, NOOP, RSET, or QUIT when server policy requires authentication in order to perform the requested action and authentication is not currently in force. 6. Formal Syntax The following syntax specification uses the Augmented Backus-Naur Form notation as specified in [ABNF]. Except as noted otherwise, all alphabetic characters are case- insensitive. The use of upper or lower case characters to define token strings is for editorial clarity only. Implementations MUST accept these strings in a case-insensitive fashion. UPALPHA = %x41-5A ;; Uppercase: A-Z LOALPHA = %x61-7A ;; Lowercase: a-z ALPHA = UPALPHA / LOALPHA ;; case insensitive DIGIT = %x30-39 ;; Digits 0-9 HEXDIGIT = %x41-46 / DIGIT ;; hexidecimal digit (uppercase) hexchar = "+" HEXDIGIT HEXDIGIT Siemborski Expires April, 2004 [Page 10] SMTP Service Extension for Authentication November, 2003 xchar = %x21-2A / %x2C-3C / %x3E-7E ;; US-ASCII except for "+", "=", SPACE and CTL xtext = *(xchar / hexchar) AUTH_CHAR = ALPHA / DIGIT / "-" / "_" auth_type = 1*20AUTH_CHAR auth_command = "AUTH" SPACE auth_type [SPACE (base64 / "=")] *(CRLF [base64]) CRLF auth_param = "AUTH=" xtext ;; The decoded form of the xtext MUST be either ;; an addr-spec or the two characters "<>" base64 = base64_terminal / ( 1*(4base64_CHAR) [base64_terminal] ) base64_char = UPALPHA / LOALPHA / DIGIT / "+" / "/" ;; Case-sensitive base64_terminal = (2base64_char "==") / (3base64_char "=") continue_req = "334" SPACE [base64] CRLF CR = %x0C ;; ASCII CR, carriage return CRLF = CR LF CTL = %x00-1F / %x7F ;; any ASCII control character and DEL LF = %x0A ;; ASCII LF, line feed SPACE = %x20 ;; ASCII SP, space 7. Security Considerations Security issues are discussed throughout this memo. If a client uses this extension to get an encrypted tunnel through an insecure network to a cooperating server, it needs to be configured to never send mail to that server when the connection is not mutually authenticated and encrypted. Otherwise, an attacker could steal the client's mail by hijacking the [SMTP] connection and either pretending the server does not support the Authentication extension or causing all AUTH commands to fail. Siemborski Expires April, 2004 [Page 11] SMTP Service Extension for Authentication November, 2003 Before the [SASL] negotiation 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 SASL negotiation upon the establishment of a security layer. This mechanism does not protect the TCP port, so an active attacker may redirect a relay connection attempt (i.e. a connection between two MTAs) to the submission port [SUBMIT]. The AUTH=<> parameter prevents such an attack from causing a relayed message, in the absence of other envelope authentication, from picking up the authentication of the relay client. A message submission client may require the user to authenticate whenever a suitable [SASL] mechanism is advertised. Therefore, it may not be desirable for a submission server [SUBMIT] to advertise a SASL mechanism when use of that mechanism grants the clients no benefits over anonymous submission. This extension is not intended to replace or be used instead of end- to-end message signature and encryption systems such as [S/MIME] or [PGP]. This extension addresses a different problem than end-to-end systems; it has the following key differences: 1. It is generally useful only within a trusted enclave. 2. It protects the entire envelope of a message, not just the message's body. 3. It authenticates the message submission, not authorship of the message content. 4. When mutual authentication is used along with a security layer, it can give the sender some assurance that the message was successfully delivered to the next hop. Additional security considerations are mentioned in the [SASL] specification. 8. IANA Considerations This document requests that the IANA update the entry for the "smtp" SASL protocol name to point at this document. This document requests that the IANA register the Authentication SMTP service extension as defined in Section 2 of this document. Siemborski Expires April, 2004 [Page 12] SMTP Service Extension for Authentication November, 2003 9. Protocol Actions [RFC Editor: Remove this section prior to publication] This document obsoletes RFC 2554 and replaces it as a Proposed Standard. 10. Intellectual Property Rights The IETF takes no position regarding the validity or scope of any intellectual property or other rights that might be claimed to pertain to the implementation or use of the technology described in this document or the extent to which any license under such rights might or might not be available; neither does it represent that it has made any effort to identify any such rights. Information on the IETF's procedures with respect to rights in standards-track and standards-related documentation can be found in BCP-11. Copies of claims of rights made available for publication and any assurances of licenses to be made available, or the result of an attempt made to obtain a general license or permission for the use of such proprietary rights by implementors or users of this specification can be obtained from the IETF Secretariat. The IETF invites any interested party to bring to its attention any copyrights, patents or patent applications, or other proprietary rights which may cover technology that may be required to practice this standard. Please address the information to the IETF Executive Director. 11. Copyright Copyright (C) The Internet Society (2003). 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, provided that 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, except as needed for the purpose of developing Internet standards in which case the procedures for copyrights defined in the Internet Standards process must be followed, or as required to translate it into languages other than English. This document and the information contained herein is provided on an Siemborski Expires April, 2004 [Page 13] SMTP Service Extension for Authentication November, 2003 "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. Siemborski Expires April, 2004 [Page 14] SMTP Service Extension for Authentication November, 2003 12. References The following documents contain normative definitions or specifications that are necessary for correct understanding of this protocol: [ABNF] Crocker, D. and P. Overell, "Augmented BNF for Syntax Specifications: ABNF", RFC 2234, November 1997. [BASE64] Josefsson, S., "The Base16, Base32, and Base64 Data Encodings", RFC 3548, July 2003. [ESMTP-DSN] Moore, K., "SMTP Service Extension for Delivery Status Notifications", RFC 1891, January 1996. [KEYWORDS] Bradner, S., "Key words for use in RFCs to Indicate Requirement Levels", BCP 14, RFC 2119, March 1997 [PLAIN] Newman, C. "Using TLS with IMAP, POP3, and ACAP", RFC 2595, June 1999. [RFC2822] Resnick, P. "Internet Message Format", RFC 2822, April 2001. [SASL] Melnikov, A., "Simple Authentication and Security Layer (SASL)", draft-ietf-sasl-rfc2222bis-*.txt, a work in progress. [SMTP] Klensin, J., "Simple Mail Transfer Protocol", RFC 2821, April 2001. [SMTP-TLS] Hoffman, P. "SMTP Service Extension for Secure SMTP over Transport Layer Security", RFC 3207, February 2002. [SUBMIT] Gellens, R. and J. Klensin, "Message Submission", RFC 2476, December 1998. The following references are for informational purposes only: [PGP] Elkins, M., "MIME Security with Pretty Good Privacy (PGP)", RFC 2015, October 1996. [S/MIME] Ramsdell, B., "S/MIME Version 3 Message Specification", RFC 2633, June 1999. [TLS] Dierks, T. and C. Allen, "The TLS Protocol Version 1.0", RFC 2246, January 1999. Siemborski Expires April, 2004 [Page 15] SMTP Service Extension for Authentication November, 2003 13. Changes Since RFC 2554 1. Clarify that servers MUST support the use of the AUTH=addr-spec parameter to MAIL FROM, even when the client is not authenticated. 2. Clarify the initial-client-send requirements, and give additional examples. 3. Update references to newer versions of various specifications. 4. Require the minimum implementation of TLS+PLAIN. 5. Clarify that the mechanism list can change. 6. Deprecate the use of the 538 response code. 7. General other editorial clarifications. 14. Author's Address: Robert Siemborski Carnegie Mellon, Andrew Systems Group Cyert Hall 207 5000 Forbes Avenue Pittsburgh, PA 15213 +1 412 268 7456 rjs3+@andrew.cmu.edu 15. Acknowledgments: The author would like to acknowledge the contributions of John Myers and other contributors to RFC 2554, on which this document draws from heavily. The author would also like to thank Ken Murchison and Mark Crispin for the time they devoted to reviewing early drafts of this document. Siemborski Expires April, 2004 [Page 16]