rfc4616.txt 20KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620
  1. Network Working Group K. Zeilenga, Ed.
  2. Request for Comments: 4616 OpenLDAP Foundation
  3. Updates: 2595 August 2006
  4. Category: Standards Track
  5. The PLAIN Simple Authentication and Security Layer (SASL) Mechanism
  6. Status of This Memo
  7. This document specifies an Internet standards track protocol for the
  8. Internet community, and requests discussion and suggestions for
  9. improvements. Please refer to the current edition of the "Internet
  10. Official Protocol Standards" (STD 1) for the standardization state
  11. and status of this protocol. Distribution of this memo is unlimited.
  12. Copyright Notice
  13. Copyright (C) The Internet Society (2006).
  14. Abstract
  15. This document defines a simple clear-text user/password Simple
  16. Authentication and Security Layer (SASL) mechanism called the PLAIN
  17. mechanism. The PLAIN mechanism is intended to be used, in
  18. combination with data confidentiality services provided by a lower
  19. layer, in protocols that lack a simple password authentication
  20. command.
  21. Zeilenga Standards Track [Page 1]
  22. RFC 4616 The PLAIN SASL Mechanism August 2006
  23. 1. Introduction
  24. Clear-text, multiple-use passwords are simple, interoperate with
  25. almost all existing operating system authentication databases, and
  26. are useful for a smooth transition to a more secure password-based
  27. authentication mechanism. The drawback is that they are unacceptable
  28. for use over network connections where data confidentiality is not
  29. ensured.
  30. This document defines the PLAIN Simple Authentication and Security
  31. Layer ([SASL]) mechanism for use in protocols with no clear-text
  32. login command (e.g., [ACAP] or [SMTP-AUTH]). This document updates
  33. RFC 2595, replacing Section 6. Changes since RFC 2595 are detailed
  34. in Appendix A.
  35. The name associated with this mechanism is "PLAIN".
  36. The PLAIN SASL mechanism does not provide a security layer.
  37. The PLAIN mechanism should not be used without adequate data security
  38. protection as this mechanism affords no integrity or confidentiality
  39. protections itself. The mechanism is intended to be used with data
  40. security protections provided by application-layer protocol,
  41. generally through its use of Transport Layer Security ([TLS])
  42. services.
  43. By default, implementations SHOULD advertise and make use of the
  44. PLAIN mechanism only when adequate data security services are in
  45. place. Specifications for IETF protocols that indicate that this
  46. mechanism is an applicable authentication mechanism MUST mandate that
  47. implementations support an strong data security service, such as TLS.
  48. The key words "MUST", "MUST NOT", "REQUIRED", "SHALL", "SHALL NOT",
  49. "SHOULD", "SHOULD NOT", "RECOMMENDED", "MAY", and "OPTIONAL" in this
  50. document are to be interpreted as described in [Keywords].
  51. 2. PLAIN SASL Mechanism
  52. The mechanism consists of a single message, a string of [UTF-8]
  53. encoded [Unicode] characters, from the client to the server. The
  54. client presents the authorization identity (identity to act as),
  55. followed by a NUL (U+0000) character, followed by the authentication
  56. identity (identity whose password will be used), followed by a NUL
  57. (U+0000) character, followed by the clear-text password. As with
  58. other SASL mechanisms, the client does not provide an authorization
  59. identity when it wishes the server to derive an identity from the
  60. credentials and use that as the authorization identity.
  61. Zeilenga Standards Track [Page 2]
  62. RFC 4616 The PLAIN SASL Mechanism August 2006
  63. The formal grammar for the client message using Augmented BNF [ABNF]
  64. follows.
  65. message = [authzid] UTF8NUL authcid UTF8NUL passwd
  66. authcid = 1*SAFE ; MUST accept up to 255 octets
  67. authzid = 1*SAFE ; MUST accept up to 255 octets
  68. passwd = 1*SAFE ; MUST accept up to 255 octets
  69. UTF8NUL = %x00 ; UTF-8 encoded NUL character
  70. SAFE = UTF1 / UTF2 / UTF3 / UTF4
  71. ;; any UTF-8 encoded Unicode character except NUL
  72. UTF1 = %x01-7F ;; except NUL
  73. UTF2 = %xC2-DF UTF0
  74. UTF3 = %xE0 %xA0-BF UTF0 / %xE1-EC 2(UTF0) /
  75. %xED %x80-9F UTF0 / %xEE-EF 2(UTF0)
  76. UTF4 = %xF0 %x90-BF 2(UTF0) / %xF1-F3 3(UTF0) /
  77. %xF4 %x80-8F 2(UTF0)
  78. UTF0 = %x80-BF
  79. The authorization identity (authzid), authentication identity
  80. (authcid), password (passwd), and NUL character deliminators SHALL be
  81. transferred as [UTF-8] encoded strings of [Unicode] characters. As
  82. the NUL (U+0000) character is used as a deliminator, the NUL (U+0000)
  83. character MUST NOT appear in authzid, authcid, or passwd productions.
  84. The form of the authzid production is specific to the application-
  85. level protocol's SASL profile [SASL]. The authcid and passwd
  86. productions are form-free. Use of non-visible characters or
  87. characters that a user may be unable to enter on some keyboards is
  88. discouraged.
  89. Servers MUST be capable of accepting authzid, authcid, and passwd
  90. productions up to and including 255 octets. It is noted that the
  91. UTF-8 encoding of a Unicode character may be as long as 4 octets.
  92. Upon receipt of the message, the server will verify the presented (in
  93. the message) authentication identity (authcid) and password (passwd)
  94. with the system authentication database, and it will verify that the
  95. authentication credentials permit the client to act as the (presented
  96. or derived) authorization identity (authzid). If both steps succeed,
  97. the user is authenticated.
  98. The presented authentication identity and password strings, as well
  99. as the database authentication identity and password strings, are to
  100. be prepared before being used in the verification process. The
  101. [SASLPrep] profile of the [StringPrep] algorithm is the RECOMMENDED
  102. preparation algorithm. The SASLprep preparation algorithm is
  103. Zeilenga Standards Track [Page 3]
  104. RFC 4616 The PLAIN SASL Mechanism August 2006
  105. recommended to improve the likelihood that comparisons behave in an
  106. expected manner. The SASLprep preparation algorithm is not mandatory
  107. so as to allow the server to employ other preparation algorithms
  108. (including none) when appropriate. For instance, use of a different
  109. preparation algorithm may be necessary for the server to interoperate
  110. with an external system.
  111. When preparing the presented strings using [SASLPrep], the presented
  112. strings are to be treated as "query" strings (Section 7 of
  113. [StringPrep]) and hence unassigned code points are allowed to appear
  114. in their prepared output. When preparing the database strings using
  115. [SASLPrep], the database strings are to be treated as "stored"
  116. strings (Section 7 of [StringPrep]) and hence unassigned code points
  117. are prohibited from appearing in their prepared output.
  118. Regardless of the preparation algorithm used, if the output of a
  119. non-invertible function (e.g., hash) of the expected string is
  120. stored, the string MUST be prepared before input to that function.
  121. Regardless of the preparation algorithm used, if preparation fails or
  122. results in an empty string, verification SHALL fail.
  123. When no authorization identity is provided, the server derives an
  124. authorization identity from the prepared representation of the
  125. provided authentication identity string. This ensures that the
  126. derivation of different representations of the authentication
  127. identity produces the same authorization identity.
  128. The server MAY use the credentials to initialize any new
  129. authentication database, such as one suitable for [CRAM-MD5] or
  130. [DIGEST-MD5].
  131. 3. Pseudo-Code
  132. This section provides pseudo-code illustrating the verification
  133. process (using hashed passwords and the SASLprep preparation
  134. function) discussed above. This section is not definitive.
  135. boolean Verify(string authzid, string authcid, string passwd) {
  136. string pAuthcid = SASLprep(authcid, true); # prepare authcid
  137. string pPasswd = SASLprep(passwd, true); # prepare passwd
  138. if (pAuthcid == NULL || pPasswd == NULL) {
  139. return false; # preparation failed
  140. }
  141. if (pAuthcid == "" || pPasswd == "") {
  142. return false; # empty prepared string
  143. }
  144. Zeilenga Standards Track [Page 4]
  145. RFC 4616 The PLAIN SASL Mechanism August 2006
  146. storedHash = FetchPasswordHash(pAuthcid);
  147. if (storedHash == NULL || storedHash == "") {
  148. return false; # error or unknown authcid
  149. }
  150. if (!Compare(storedHash, Hash(pPasswd))) {
  151. return false; # incorrect password
  152. }
  153. if (authzid == NULL ) {
  154. authzid = DeriveAuthzid(pAuthcid);
  155. if (authzid == NULL || authzid == "") {
  156. return false; # could not derive authzid
  157. }
  158. }
  159. if (!Authorize(pAuthcid, authzid)) {
  160. return false; # not authorized
  161. }
  162. return true;
  163. }
  164. The second parameter of the SASLprep function, when true, indicates
  165. that unassigned code points are allowed in the input. When the
  166. SASLprep function is called to prepare the password prior to
  167. computing the stored hash, the second parameter would be false.
  168. The second parameter provided to the Authorize function is not
  169. prepared by this code. The application-level SASL profile should be
  170. consulted to determine what, if any, preparation is necessary.
  171. Note that the DeriveAuthzid and Authorize functions (whether
  172. implemented as one function or two, whether designed in a manner in
  173. which these functions or whether the mechanism implementation can be
  174. reused elsewhere) require knowledge and understanding of mechanism
  175. and the application-level protocol specification and/or
  176. implementation details to implement.
  177. Note that the Authorize function outcome is clearly dependent on
  178. details of the local authorization model and policy. Both functions
  179. may be dependent on other factors as well.
  180. Zeilenga Standards Track [Page 5]
  181. RFC 4616 The PLAIN SASL Mechanism August 2006
  182. 4. Examples
  183. This section provides examples of PLAIN authentication exchanges.
  184. The examples are intended to help the readers understand the above
  185. text. The examples are not definitive.
  186. "C:" and "S:" indicate lines sent by the client and server,
  187. respectively. "<NUL>" represents a single NUL (U+0000) character.
  188. The Application Configuration Access Protocol ([ACAP]) is used in the
  189. examples.
  190. The first example shows how the PLAIN mechanism might be used for
  191. user authentication.
  192. S: * ACAP (SASL "CRAM-MD5") (STARTTLS)
  193. C: a001 STARTTLS
  194. S: a001 OK "Begin TLS negotiation now"
  195. <TLS negotiation, further commands are under TLS layer>
  196. S: * ACAP (SASL "CRAM-MD5" "PLAIN")
  197. C: a002 AUTHENTICATE "PLAIN"
  198. S: + ""
  199. C: {21}
  200. C: <NUL>tim<NUL>tanstaaftanstaaf
  201. S: a002 OK "Authenticated"
  202. The second example shows how the PLAIN mechanism might be used to
  203. attempt to assume the identity of another user. In this example, the
  204. server rejects the request. Also, this example makes use of the
  205. protocol optional initial response capability to eliminate a round-
  206. trip.
  207. S: * ACAP (SASL "CRAM-MD5") (STARTTLS)
  208. C: a001 STARTTLS
  209. S: a001 OK "Begin TLS negotiation now"
  210. <TLS negotiation, further commands are under TLS layer>
  211. S: * ACAP (SASL "CRAM-MD5" "PLAIN")
  212. C: a002 AUTHENTICATE "PLAIN" {20+}
  213. C: Ursel<NUL>Kurt<NUL>xipj3plmq
  214. S: a002 NO "Not authorized to requested authorization identity"
  215. 5. Security Considerations
  216. As the PLAIN mechanism itself provided no integrity or
  217. confidentiality protections, it should not be used without adequate
  218. external data security protection, such as TLS services provided by
  219. many application-layer protocols. By default, implementations SHOULD
  220. NOT advertise and SHOULD NOT make use of the PLAIN mechanism unless
  221. adequate data security services are in place.
  222. Zeilenga Standards Track [Page 6]
  223. RFC 4616 The PLAIN SASL Mechanism August 2006
  224. When the PLAIN mechanism is used, the server gains the ability to
  225. impersonate the user to all services with the same password
  226. regardless of any encryption provided by TLS or other confidentiality
  227. protection mechanisms. Whereas many other authentication mechanisms
  228. have similar weaknesses, stronger SASL mechanisms address this issue.
  229. Clients are encouraged to have an operational mode where all
  230. mechanisms that are likely to reveal the user's password to the
  231. server are disabled.
  232. General [SASL] security considerations apply to this mechanism.
  233. Unicode, [UTF-8], and [StringPrep] security considerations also
  234. apply.
  235. 6. IANA Considerations
  236. The SASL Mechanism registry [IANA-SASL] entry for the PLAIN mechanism
  237. has been updated by the IANA to reflect that this document now
  238. provides its technical specification.
  239. To: iana@iana.org
  240. Subject: Updated Registration of SASL mechanism PLAIN
  241. SASL mechanism name: PLAIN
  242. Security considerations: See RFC 4616.
  243. Published specification (optional, recommended): RFC 4616
  244. Person & email address to contact for further information:
  245. Kurt Zeilenga <kurt@openldap.org>
  246. IETF SASL WG <ietf-sasl@imc.org>
  247. Intended usage: COMMON
  248. Author/Change controller: IESG <iesg@ietf.org>
  249. Note: Updates existing entry for PLAIN
  250. 7. Acknowledgements
  251. This document is a revision of RFC 2595 by Chris Newman. Portions of
  252. the grammar defined in Section 2 were borrowed from [UTF-8] by
  253. Francois Yergeau.
  254. This document is a product of the IETF Simple Authentication and
  255. Security Layer (SASL) Working Group.
  256. Zeilenga Standards Track [Page 7]
  257. RFC 4616 The PLAIN SASL Mechanism August 2006
  258. 8. Normative References
  259. [ABNF] Crocker, D., Ed. and P. Overell, "Augmented BNF for
  260. Syntax Specifications: ABNF", RFC 4234, October 2005.
  261. [Keywords] Bradner, S., "Key words for use in RFCs to Indicate
  262. Requirement Levels", BCP 14, RFC 2119, March 1997.
  263. [SASL] Melnikov, A., Ed., and K. Zeilenga, Ed., "Simple
  264. Authentication and Security Layer (SASL)", RFC 4422,
  265. June 2006.
  266. [SASLPrep] Zeilenga, K., "SASLprep: Stringprep Profile for User
  267. Names and Passwords", RFC 4013, February 2005.
  268. [StringPrep] Hoffman, P. and M. Blanchet, "Preparation of
  269. Internationalized Strings ("stringprep")", RFC 3454,
  270. December 2002.
  271. [Unicode] The Unicode Consortium, "The Unicode Standard, Version
  272. 3.2.0" is defined by "The Unicode Standard, Version
  273. 3.0" (Reading, MA, Addison-Wesley, 2000. ISBN 0-201-
  274. 61633-5), as amended by the "Unicode Standard Annex
  275. #27: Unicode 3.1"
  276. (http://www.unicode.org/reports/tr27/) and by the
  277. "Unicode Standard Annex #28: Unicode 3.2"
  278. (http://www.unicode.org/reports/tr28/).
  279. [UTF-8] Yergeau, F., "UTF-8, a transformation format of ISO
  280. 10646", STD 63, RFC 3629, November 2003.
  281. [TLS] Dierks, T. and E. Rescorla, "The Transport Layer
  282. Security (TLS) Protocol Version 1.1", RFC 4346, April
  283. 2006.
  284. 9. Informative References
  285. [ACAP] Newman, C. and J. Myers, "ACAP -- Application
  286. Configuration Access Protocol", RFC 2244, November
  287. 1997.
  288. [CRAM-MD5] Nerenberg, L., Ed., "The CRAM-MD5 SASL Mechanism", Work
  289. in Progress, June 2006.
  290. [DIGEST-MD5] Melnikov, A., Ed., "Using Digest Authentication as a
  291. SASL Mechanism", Work in Progress, June 2006.
  292. Zeilenga Standards Track [Page 8]
  293. RFC 4616 The PLAIN SASL Mechanism August 2006
  294. [IANA-SASL] IANA, "SIMPLE AUTHENTICATION AND SECURITY LAYER (SASL)
  295. MECHANISMS",
  296. <http://www.iana.org/assignments/sasl-mechanisms>.
  297. [SMTP-AUTH] Myers, J., "SMTP Service Extension for Authentication",
  298. RFC 2554, March 1999.
  299. Zeilenga Standards Track [Page 9]
  300. RFC 4616 The PLAIN SASL Mechanism August 2006
  301. Appendix A. Changes since RFC 2595
  302. This appendix is non-normative.
  303. This document replaces Section 6 of RFC 2595.
  304. The specification details how the server is to compare client-
  305. provided character strings with stored character strings.
  306. The ABNF grammar was updated. In particular, the grammar now allows
  307. LINE FEED (U+000A) and CARRIAGE RETURN (U+000D) characters in the
  308. authzid, authcid, passwd productions. However, whether these control
  309. characters may be used depends on the string preparation rules
  310. applicable to the production. For passwd and authcid productions,
  311. control characters are prohibited. For authzid, one must consult the
  312. application-level SASL profile. This change allows PLAIN to carry
  313. all possible authorization identity strings allowed in SASL.
  314. Pseudo-code was added.
  315. The example section was expanded to illustrate more features of the
  316. PLAIN mechanism.
  317. Editor's Address
  318. Kurt D. Zeilenga
  319. OpenLDAP Foundation
  320. EMail: Kurt@OpenLDAP.org
  321. Zeilenga Standards Track [Page 10]
  322. RFC 4616 The PLAIN SASL Mechanism August 2006
  323. Full Copyright Statement
  324. Copyright (C) The Internet Society (2006).
  325. This document is subject to the rights, licenses and restrictions
  326. contained in BCP 78, and except as set forth therein, the authors
  327. retain all their rights.
  328. This document and the information contained herein are provided on an
  329. "AS IS" basis and THE CONTRIBUTOR, THE ORGANIZATION HE/SHE REPRESENTS
  330. OR IS SPONSORED BY (IF ANY), THE INTERNET SOCIETY AND THE INTERNET
  331. ENGINEERING TASK FORCE DISCLAIM ALL WARRANTIES, EXPRESS OR IMPLIED,
  332. INCLUDING BUT NOT LIMITED TO ANY WARRANTY THAT THE USE OF THE
  333. INFORMATION HEREIN WILL NOT INFRINGE ANY RIGHTS OR ANY IMPLIED
  334. WARRANTIES OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE.
  335. Intellectual Property
  336. The IETF takes no position regarding the validity or scope of any
  337. Intellectual Property Rights or other rights that might be claimed to
  338. pertain to the implementation or use of the technology described in
  339. this document or the extent to which any license under such rights
  340. might or might not be available; nor does it represent that it has
  341. made any independent effort to identify any such rights. Information
  342. on the procedures with respect to rights in RFC documents can be
  343. found in BCP 78 and BCP 79.
  344. Copies of IPR disclosures made to the IETF Secretariat and any
  345. assurances of licenses to be made available, or the result of an
  346. attempt made to obtain a general license or permission for the use of
  347. such proprietary rights by implementers or users of this
  348. specification can be obtained from the IETF on-line IPR repository at
  349. http://www.ietf.org/ipr.
  350. The IETF invites any interested party to bring to its attention any
  351. copyrights, patents or patent applications, or other proprietary
  352. rights that may cover technology that may be required to implement
  353. this standard. Please address the information to the IETF at
  354. ietf-ipr@ietf.org.
  355. Acknowledgement
  356. Funding for the RFC Editor function is provided by the IETF
  357. Administrative Support Activity (IASA).
  358. Zeilenga Standards Track [Page 11]