7Internet Engineering Task Force (IETF) C. Newman
8Request for Comments: 5802 Oracle
9Category: Standards Track A. Menon-Sen
10ISSN: 2070-1721 Oryx Mail Systems GmbH
18 Salted Challenge Response Authentication Mechanism (SCRAM)
19 SASL and GSS-API Mechanisms
23 The secure authentication mechanism most widely deployed and used by
24 Internet application protocols is the transmission of clear-text
25 passwords over a channel protected by Transport Layer Security (TLS).
26 There are some significant security concerns with that mechanism,
27 which could be addressed by the use of a challenge response
28 authentication mechanism protected by TLS. Unfortunately, the
29 challenge response mechanisms presently on the standards track all
30 fail to meet requirements necessary for widespread deployment, and
31 have had success only in limited use.
33 This specification describes a family of Simple Authentication and
34 Security Layer (SASL; RFC 4422) authentication mechanisms called the
35 Salted Challenge Response Authentication Mechanism (SCRAM), which
36 addresses the security concerns and meets the deployability
37 requirements. When used in combination with TLS or an equivalent
38 security layer, a mechanism from this family could improve the status
39 quo for application protocol authentication and provide a suitable
40 choice for a mandatory-to-implement mechanism for future application
58Newman, et al. Standards Track [Page 1]
60RFC 5802 SCRAM July 2010
65 This is an Internet Standards Track document.
67 This document is a product of the Internet Engineering Task Force
68 (IETF). It represents the consensus of the IETF community. It has
69 received public review and has been approved for publication by the
70 Internet Engineering Steering Group (IESG). Further information on
71 Internet Standards is available in Section 2 of RFC 5741.
73 Information about the current status of this document, any errata,
74 and how to provide feedback on it may be obtained at
75 http://www.rfc-editor.org/info/rfc5802.
79 Copyright (c) 2010 IETF Trust and the persons identified as the
80 document authors. All rights reserved.
82 This document is subject to BCP 78 and the IETF Trust's Legal
83 Provisions Relating to IETF Documents
84 (http://trustee.ietf.org/license-info) in effect on the date of
85 publication of this document. Please review these documents
86 carefully, as they describe your rights and restrictions with respect
87 to this document. Code Components extracted from this document must
88 include Simplified BSD License text as described in Section 4.e of
89 the Trust Legal Provisions and are provided without warranty as
90 described in the Simplified BSD License.
114Newman, et al. Standards Track [Page 2]
116RFC 5802 SCRAM July 2010
121 1. Introduction ....................................................4
122 2. Conventions Used in This Document ...............................5
123 2.1. Terminology ................................................5
124 2.2. Notation ...................................................6
125 3. SCRAM Algorithm Overview ........................................7
126 4. SCRAM Mechanism Names ...........................................8
127 5. SCRAM Authentication Exchange ...................................9
128 5.1. SCRAM Attributes ..........................................10
129 5.2. Compliance with SASL Mechanism Requirements ...............13
130 6. Channel Binding ................................................14
131 6.1. Default Channel Binding ...................................15
132 7. Formal Syntax ..................................................15
133 8. SCRAM as a GSS-API Mechanism ...................................19
134 8.1. GSS-API Principal Name Types for SCRAM ....................19
135 8.2. GSS-API Per-Message Tokens for SCRAM ......................20
136 8.3. GSS_Pseudo_random() for SCRAM .............................20
137 9. Security Considerations ........................................20
138 10. IANA Considerations ...........................................22
139 11. Acknowledgements ..............................................23
140 12. References ....................................................24
141 12.1. Normative References .....................................24
142 12.2. Normative References for GSS-API Implementors ............24
143 12.3. Informative References ...................................25
144 Appendix A. Other Authentication Mechanisms .......................27
145 Appendix B. Design Motivations ....................................27
170Newman, et al. Standards Track [Page 3]
172RFC 5802 SCRAM July 2010
177 This specification describes a family of authentication mechanisms
178 called the Salted Challenge Response Authentication Mechanism (SCRAM)
179 which addresses the requirements necessary to deploy a challenge-
180 response mechanism more widely than past attempts (see Appendix A and
181 Appendix B). When used in combination with Transport Layer Security
182 (TLS; see [RFC5246]) or an equivalent security layer, a mechanism
183 from this family could improve the status quo for application
184 protocol authentication and provide a suitable choice for a
185 mandatory-to-implement mechanism for future application protocol
188 For simplicity, this family of mechanisms does not presently include
189 negotiation of a security layer [RFC4422]. It is intended to be used
190 with an external security layer such as that provided by TLS or SSH,
191 with optional channel binding [RFC5056] to the external security
194 SCRAM is specified herein as a pure Simple Authentication and
195 Security Layer (SASL) [RFC4422] mechanism, but it conforms to the new
196 bridge between SASL and the Generic Security Service Application
197 Program Interface (GSS-API) called "GS2" [RFC5801]. This means that
198 this document defines both, a SASL mechanism and a GSS-API mechanism.
200 SCRAM provides the following protocol features:
202 o The authentication information stored in the authentication
203 database is not sufficient by itself to impersonate the client.
204 The information is salted to prevent a pre-stored dictionary
205 attack if the database is stolen.
207 o The server does not gain the ability to impersonate the client to
208 other servers (with an exception for server-authorized proxies).
210 o The mechanism permits the use of a server-authorized proxy without
211 requiring that proxy to have super-user rights with the back-end
214 o Mutual authentication is supported, but only the client is named
215 (i.e., the server has no name).
217 o When used as a SASL mechanism, SCRAM is capable of transporting
218 authorization identities (see [RFC4422], Section 2) from the
219 client to the server.
226Newman, et al. Standards Track [Page 4]
228RFC 5802 SCRAM July 2010
231 A separate document defines a standard LDAPv3 [RFC4510] attribute
232 that enables storage of the SCRAM authentication information in LDAP.
235 For an in-depth discussion of why other challenge response mechanisms
236 are not considered sufficient, see Appendix A. For more information
237 about the motivations behind the design of this mechanism, see
2402. Conventions Used in This Document
242 The key words "MUST", "MUST NOT", "REQUIRED", "SHALL", "SHALL NOT",
243 "SHOULD", "SHOULD NOT", "RECOMMENDED", "MAY", and "OPTIONAL" in this
244 document are to be interpreted as described in [RFC2119].
246 Formal syntax is defined by [RFC5234] including the core rules
247 defined in Appendix B of [RFC5234].
249 Example lines prefaced by "C:" are sent by the client and ones
250 prefaced by "S:" by the server. If a single "C:" or "S:" label
251 applies to multiple lines, then the line breaks between those lines
252 are for editorial clarity only, and are not part of the actual
257 This document uses several terms defined in [RFC4949] ("Internet
258 Security Glossary") including the following: authentication,
259 authentication exchange, authentication information, brute force,
260 challenge-response, cryptographic hash function, dictionary attack,
261 eavesdropping, hash result, keyed hash, man-in-the-middle, nonce,
262 one-way encryption function, password, replay attack, and salt.
263 Readers not familiar with these terms should use that glossary as a
266 Some clarifications and additional definitions follow:
268 o Authentication information: Information used to verify an identity
269 claimed by a SCRAM client. The authentication information for a
270 SCRAM identity consists of salt, iteration count, "StoredKey" and
271 "ServerKey" (as defined in the algorithm overview) for each
272 supported cryptographic hash function.
274 o Authentication database: The database used to look up the
275 authentication information associated with a particular identity.
276 For application protocols, LDAPv3 (see [RFC4510]) is frequently
282Newman, et al. Standards Track [Page 5]
284RFC 5802 SCRAM July 2010
287 used as the authentication database. For network-level protocols
288 such as PPP or 802.11x, the use of RADIUS [RFC2865] is more
291 o Base64: An encoding mechanism defined in [RFC4648] that converts
292 an octet string input to a textual output string that can be
293 easily displayed to a human. The use of base64 in SCRAM is
294 restricted to the canonical form with no whitespace.
296 o Octet: An 8-bit byte.
298 o Octet string: A sequence of 8-bit bytes.
300 o Salt: A random octet string that is combined with a password
301 before applying a one-way encryption function. This value is used
302 to protect passwords that are stored in an authentication
307 The pseudocode description of the algorithm uses the following
310 o ":=": The variable on the left-hand side represents the octet
311 string resulting from the expression on the right-hand side.
313 o "+": Octet string concatenation.
315 o "[ ]": A portion of an expression enclosed in "[" and "]" may not
316 be included in the result under some circumstances. See the
317 associated text for a description of those circumstances.
319 o Normalize(str): Apply the SASLprep profile [RFC4013] of the
320 "stringprep" algorithm [RFC3454] as the normalization algorithm to
321 a UTF-8 [RFC3629] encoded "str". The resulting string is also in
322 UTF-8. When applying SASLprep, "str" is treated as a "stored
323 strings", which means that unassigned Unicode codepoints are
324 prohibited (see Section 7 of [RFC3454]). Note that
325 implementations MUST either implement SASLprep or disallow use of
326 non US-ASCII Unicode codepoints in "str".
328 o HMAC(key, str): Apply the HMAC keyed hash algorithm (defined in
329 [RFC2104]) using the octet string represented by "key" as the key
330 and the octet string "str" as the input string. The size of the
331 result is the hash result size for the hash function in use. For
332 example, it is 20 octets for SHA-1 (see [RFC3174]).
338Newman, et al. Standards Track [Page 6]
340RFC 5802 SCRAM July 2010
343 o H(str): Apply the cryptographic hash function to the octet string
344 "str", producing an octet string as a result. The size of the
345 result depends on the hash result size for the hash function in
348 o XOR: Apply the exclusive-or operation to combine the octet string
349 on the left of this operator with the octet string on the right of
350 this operator. The length of the output and each of the two
351 inputs will be the same for this use.
355 U1 := HMAC(str, salt + INT(1))
358 Ui-1 := HMAC(str, Ui-2)
359 Ui := HMAC(str, Ui-1)
361 Hi := U1 XOR U2 XOR ... XOR Ui
363 where "i" is the iteration count, "+" is the string concatenation
364 operator, and INT(g) is a 4-octet encoding of the integer g, most
365 significant octet first.
367 Hi() is, essentially, PBKDF2 [RFC2898] with HMAC() as the
368 pseudorandom function (PRF) and with dkLen == output length of
369 HMAC() == output length of H().
3713. SCRAM Algorithm Overview
373 The following is a description of a full, uncompressed SASL SCRAM
374 authentication exchange. Nothing in SCRAM prevents either sending
375 the client-first message with the SASL authentication request defined
376 by an application protocol ("initial client response"), or sending
377 the server-final message as additional data of the SASL outcome of
378 authentication exchange defined by an application protocol. See
379 [RFC4422] for more details.
381 Note that this section omits some details, such as client and server
382 nonces. See Section 5 for more details.
384 To begin with, the SCRAM client is in possession of a username and
385 password (*) (or a ClientKey/ServerKey, or SaltedPassword). It sends
386 the username to the server, which retrieves the corresponding
387 authentication information, i.e., a salt, StoredKey, ServerKey, and
388 the iteration count i. (Note that a server implementation may choose
394Newman, et al. Standards Track [Page 7]
396RFC 5802 SCRAM July 2010
399 to use the same iteration count for all accounts.) The server sends
400 the salt and the iteration count to the client, which then computes
401 the following values and sends a ClientProof to the server:
403 (*) Note that both the username and the password MUST be encoded in
406 Informative Note: Implementors are encouraged to create test cases
407 that use both usernames and passwords with non-ASCII codepoints. In
408 particular, it's useful to test codepoints whose "Unicode
409 Normalization Form C" and "Unicode Normalization Form KC" are
410 different. Some examples of such codepoints include Vulgar Fraction
411 One Half (U+00BD) and Acute Accent (U+00B4).
413 SaltedPassword := Hi(Normalize(password), salt, i)
414 ClientKey := HMAC(SaltedPassword, "Client Key")
415 StoredKey := H(ClientKey)
416 AuthMessage := client-first-message-bare + "," +
417 server-first-message + "," +
418 client-final-message-without-proof
419 ClientSignature := HMAC(StoredKey, AuthMessage)
420 ClientProof := ClientKey XOR ClientSignature
421 ServerKey := HMAC(SaltedPassword, "Server Key")
422 ServerSignature := HMAC(ServerKey, AuthMessage)
424 The server authenticates the client by computing the ClientSignature,
425 exclusive-ORing that with the ClientProof to recover the ClientKey
426 and verifying the correctness of the ClientKey by applying the hash
427 function and comparing the result to the StoredKey. If the ClientKey
428 is correct, this proves that the client has access to the user's
431 Similarly, the client authenticates the server by computing the
432 ServerSignature and comparing it to the value sent by the server. If
433 the two are equal, it proves that the server had access to the user's
436 The AuthMessage is computed by concatenating messages from the
437 authentication exchange. The format of these messages is defined in
4404. SCRAM Mechanism Names
442 A SCRAM mechanism name is a string "SCRAM-" followed by the
443 uppercased name of the underlying hash function taken from the IANA
444 "Hash Function Textual Names" registry (see http://www.iana.org),
445 optionally followed by the suffix "-PLUS" (see below). Note that
446 SASL mechanism names are limited to 20 octets, which means that only
450Newman, et al. Standards Track [Page 8]
452RFC 5802 SCRAM July 2010
455 hash function names with lengths shorter or equal to 9 octets
456 (20-length("SCRAM-")-length("-PLUS") can be used. For cases when the
457 underlying hash function name is longer than 9 octets, an alternative
458 9-octet (or shorter) name can be used to construct the corresponding
459 SCRAM mechanism name, as long as this alternative name doesn't
460 conflict with any other hash function name from the IANA "Hash
461 Function Textual Names" registry. In order to prevent future
462 conflict, such alternative names SHOULD be registered in the IANA
463 "Hash Function Textual Names" registry.
465 For interoperability, all SCRAM clients and servers MUST implement
466 the SCRAM-SHA-1 authentication mechanism, i.e., an authentication
467 mechanism from the SCRAM family that uses the SHA-1 hash function as
468 defined in [RFC3174].
470 The "-PLUS" suffix is used only when the server supports channel
471 binding to the external channel. If the server supports channel
472 binding, it will advertise both the "bare" and "plus" versions of
473 whatever mechanisms it supports (e.g., if the server supports only
474 SCRAM with SHA-1, then it will advertise support for both SCRAM-SHA-1
475 and SCRAM-SHA-1-PLUS). If the server does not support channel
476 binding, then it will advertise only the "bare" version of the
477 mechanism (e.g., only SCRAM-SHA-1). The "-PLUS" exists to allow
478 negotiation of the use of channel binding. See Section 6.
4805. SCRAM Authentication Exchange
482 SCRAM is a SASL mechanism whose client response and server challenge
483 messages are text-based messages containing one or more attribute-
484 value pairs separated by commas. Each attribute has a one-letter
485 name. The messages and their attributes are described in
486 Section 5.1, and defined in Section 7.
488 SCRAM is a client-first SASL mechanism (see [RFC4422], Section 5,
489 item 2a), and returns additional data together with a server's
490 indication of a successful outcome.
492 This is a simple example of a SCRAM-SHA-1 authentication exchange
493 when the client doesn't support channel bindings (username 'user' and
494 password 'pencil' are used):
497 S: r=fyko+d2lbbFgONRv9qkxdawL3rfcNHYJY1ZVvWVs7j,s=QSXCR+Q6sek8bf92,
499 C: c=biws,r=fyko+d2lbbFgONRv9qkxdawL3rfcNHYJY1ZVvWVs7j,
500 p=v0X8v3Bz2T0CJGbJQyF0X+HI4Ts=
501 S: v=rmF9pqV8S7suAoZWja4dJRkFsKQ=
506Newman, et al. Standards Track [Page 9]
508RFC 5802 SCRAM July 2010
511 First, the client sends the "client-first-message" containing:
513 o a GS2 header consisting of a flag indicating whether channel
514 binding is supported-but-not-used, not supported, or used, and an
515 optional SASL authorization identity;
517 o SCRAM username and a random, unique nonce attributes.
519 Note that the client's first message will always start with "n", "y",
520 or "p"; otherwise, the message is invalid and authentication MUST
521 fail. This is important, as it allows for GS2 extensibility (e.g.,
522 to add support for security layers).
524 In response, the server sends a "server-first-message" containing the
525 user's iteration count i and the user's salt, and appends its own
526 nonce to the client-specified one.
528 The client then responds by sending a "client-final-message" with the
529 same nonce and a ClientProof computed using the selected hash
530 function as explained earlier.
532 The server verifies the nonce and the proof, verifies that the
533 authorization identity (if supplied by the client in the first
534 message) is authorized to act as the authentication identity, and,
535 finally, it responds with a "server-final-message", concluding the
536 authentication exchange.
538 The client then authenticates the server by computing the
539 ServerSignature and comparing it to the value sent by the server. If
540 the two are different, the client MUST consider the authentication
541 exchange to be unsuccessful, and it might have to drop the
546 This section describes the permissible attributes, their use, and the
548 letters and are case-sensitive.
550 Note that the order of attributes in client or server messages is
551 fixed, with the exception of extension attributes (described by the
552 "extensions" ABNF production), which can appear in any order in the
553 designated positions. See Section 7 for authoritative reference.
555 o a: This is an optional attribute, and is part of the GS2 [RFC5801]
556 bridge between the GSS-API and SASL. This attribute specifies an
557 authorization identity. A client may include it in its first
558 message to the server if it wants to authenticate as one user, but
562Newman, et al. Standards Track [Page 10]
564RFC 5802 SCRAM July 2010
567 subsequently act as a different user. This is typically used by
568 an administrator to perform some management task on behalf of
569 another user, or by a proxy in some situations.
571 Upon the receipt of this value the server verifies its
572 correctness according to the used SASL protocol profile.
573 Failed verification results in failed authentication exchange.
575 If this attribute is omitted (as it normally would be), the
576 authorization identity is assumed to be derived from the
577 username specified with the (required) "n" attribute.
579 The server always authenticates the user specified by the "n"
580 attribute. If the "a" attribute specifies a different user,
581 the server associates that identity with the connection after
582 successful authentication and authorization checks.
584 The syntax of this field is the same as that of the "n" field
585 with respect to quoting of '=' and ','.
587 o n: This attribute specifies the name of the user whose password is
588 used for authentication (a.k.a. "authentication identity"
589 [RFC4422]). A client MUST include it in its first message to the
590 server. If the "a" attribute is not specified (which would
591 normally be the case), this username is also the identity that
592 will be associated with the connection subsequent to
593 authentication and authorization.
595 Before sending the username to the server, the client SHOULD
596 prepare the username using the "SASLprep" profile [RFC4013] of
597 the "stringprep" algorithm [RFC3454] treating it as a query
598 string (i.e., unassigned Unicode code points are allowed). If
599 the preparation of the username fails or results in an empty
600 string, the client SHOULD abort the authentication exchange
603 (*) An interactive client can request a repeated entry of the
606 Upon receipt of the username by the server, the server MUST
607 either prepare it using the "SASLprep" profile [RFC4013] of the
608 "stringprep" algorithm [RFC3454] treating it as a query string
609 (i.e., unassigned Unicode codepoints are allowed) or otherwise
610 be prepared to do SASLprep-aware string comparisons and/or
611 index lookups. If the preparation of the username fails or
612 results in an empty string, the server SHOULD abort the
618Newman, et al. Standards Track [Page 11]
620RFC 5802 SCRAM July 2010
623 authentication exchange. Whether or not the server prepares
624 the username using "SASLprep", it MUST use it as received in
627 The characters ',' or '=' in usernames are sent as '=2C' and
628 '=3D' respectively. If the server receives a username that
629 contains '=' not followed by either '2C' or '3D', then the
630 server MUST fail the authentication.
633 version of SCRAM, its presence in a client or a server message
634 MUST cause authentication failure when the attribute is parsed by
637 o r: This attribute specifies a sequence of random printable ASCII
638 characters excluding ',' (which forms the nonce used as input to
639 the hash function). No quoting is applied to this string. As
640 described earlier, the client supplies an initial value in its
641 first message, and the server augments that value with its own
642 nonce in its first response. It is important that this value be
643 different for each authentication (see [RFC4086] for more details
644 on how to achieve this). The client MUST verify that the initial
645 part of the nonce used in subsequent messages is the same as the
646 nonce it initially specified. The server MUST verify that the
647 nonce sent by the client in the second message is the same as the
648 one sent by the server in its first message.
650 o c: This REQUIRED attribute specifies the base64-encoded GS2 header
651 and channel binding data. It is sent by the client in its second
652 authentication message. The attribute data consist of:
654 * the GS2 header from the client's first message (recall that the
655 GS2 header contains a channel binding flag and an optional
656 authzid). This header is going to include channel binding type
657 prefix (see [RFC5056]), if and only if the client is using
660 * followed by the external channel's channel binding data, if and
661 only if the client is using channel binding.
663 o s: This attribute specifies the base64-encoded salt used by the
664 server for this user. It is sent by the server in its first
665 message to the client.
667 o i: This attribute specifies an iteration count for the selected
668 hash function and user, and MUST be sent by the server along with
674Newman, et al. Standards Track [Page 12]
676RFC 5802 SCRAM July 2010
679 For the SCRAM-SHA-1/SCRAM-SHA-1-PLUS SASL mechanism, servers
680 SHOULD announce a hash iteration-count of at least 4096. Note
681 that a client implementation MAY cache ClientKey&ServerKey (or
682 just SaltedPassword) for later reauthentication to the same
683 service, as it is likely that the server is going to advertise
684 the same salt value upon reauthentication. This might be
685 useful for mobile clients where CPU usage is a concern.
687 o p: This attribute specifies a base64-encoded ClientProof. The
688 client computes this value as described in the overview and sends
691 o v: This attribute specifies a base64-encoded ServerSignature. It
692 is sent by the server in its final message, and is used by the
693 client to verify that the server has access to the user's
694 authentication information. This value is computed as explained
697 o e: This attribute specifies an error that occurred during
698 authentication exchange. It is sent by the server in its final
699 message and can help diagnose the reason for the authentication
700 exchange failure. On failed authentication, the entire server-
701 final-message is OPTIONAL; specifically, a server implementation
702 MAY conclude the SASL exchange with a failure without sending the
703 server-final-message. This results in an application-level error
704 response without an extra round-trip. If the server-final-message
705 is sent on authentication failure, then the "e" attribute MUST be
708 o As-yet unspecified mandatory and optional extensions. Mandatory
709 extensions are encoded as values of the 'm' attribute (see ABNF
710 for reserved-mext in section 7). Optional extensions use as-yet
711 unassigned attribute names.
713 Mandatory extensions sent by one peer but not understood by the
714 other MUST cause authentication failure (the server SHOULD send
715 the "extensions-not-supported" server-error-value).
717 Unknown optional extensions MUST be ignored upon receipt.
7195.2. Compliance with SASL Mechanism Requirements
721 This section describes compliance with SASL mechanism requirements
722 specified in Section 5 of [RFC4422].
724 1) "SCRAM-SHA-1" and "SCRAM-SHA-1-PLUS".
726 2a) SCRAM is a client-first mechanism.
730Newman, et al. Standards Track [Page 13]
732RFC 5802 SCRAM July 2010
735 2b) SCRAM sends additional data with success.
737 3) SCRAM is capable of transferring authorization identities from
738 the client to the server.
740 4) SCRAM does not offer any security layers (SCRAM offers channel
743 5) SCRAM has a hash protecting the authorization identity.
747 SCRAM supports channel binding to external secure channels, such as
748 TLS. Clients and servers may or may not support channel binding,
749 therefore the use of channel binding is negotiable. SCRAM does not
750 provide security layers, however, therefore it is imperative that
751 SCRAM provide integrity protection for the negotiation of channel
754 Use of channel binding is negotiated as follows:
756 o Servers that support the use of channel binding SHOULD advertise
757 both the non-PLUS (SCRAM-<hash-function>) and PLUS-variant (SCRAM-
758 <hash-function>-PLUS) mechanism name. If the server cannot
759 support channel binding, it SHOULD advertise only the non-PLUS-
760 variant. If the server would never succeed in the authentication
761 of the non-PLUS-variant due to policy reasons, it MUST advertise
762 only the PLUS-variant.
764 o If the client supports channel binding and the server does not
765 appear to (i.e., the client did not see the -PLUS name advertised
766 by the server), then the client MUST NOT use an "n" gs2-cbind-
769 o Clients that support mechanism negotiation and channel binding
770 MUST use a "p" gs2-cbind-flag when the server offers the PLUS-
771 variant of the desired GS2 mechanism.
773 o If the client does not support channel binding, then it MUST use
774 an "n" gs2-cbind-flag. Conversely, if the client requires the use
775 of channel binding then it MUST use a "p" gs2-cbind-flag. Clients
776 that do not support mechanism negotiation never use a "y" gs2-
777 cbind-flag, they use either "p" or "n" according to whether they
778 require and support the use of channel binding or whether they do
781 o Upon receipt of the client-first message, the server checks the
782 channel binding flag (gs2-cbind-flag).
786Newman, et al. Standards Track [Page 14]
788RFC 5802 SCRAM July 2010
791 * If the flag is set to "y" and the server supports channel
792 binding, the server MUST fail authentication. This is because
793 if the client sets the channel binding flag to "y", then the
794 client must have believed that the server did not support
795 channel binding -- if the server did in fact support channel
796 binding, then this is an indication that there has been a
797 downgrade attack (e.g., an attacker changed the server's
798 mechanism list to exclude the -PLUS suffixed SCRAM mechanism
801 * If the channel binding flag was "p" and the server does not
802 support the indicated channel binding type, then the server
803 MUST fail authentication.
805 The server MUST always validate the client's "c=" field. The server
806 does this by constructing the value of the "c=" attribute and then
807 checking that it matches the client's c= attribute value.
809 For more discussions of channel bindings, and the syntax of channel
810 binding data for various security protocols, see [RFC5056].
8126.1. Default Channel Binding
814 A default channel binding type agreement process for all SASL
815 application protocols that do not provide their own channel binding
816 type agreement is provided as follows.
818 'tls-unique' is the default channel binding type for any application
819 that doesn't specify one.
821 Servers MUST implement the "tls-unique" [RFC5929] channel binding
822 type, if they implement any channel binding. Clients SHOULD
823 implement the "tls-unique" [RFC5929] channel binding type, if they
824 implement any channel binding. Clients and servers SHOULD choose the
825 highest-layer/innermost end-to-end TLS channel as the channel to
828 Servers MUST choose the channel binding type indicated by the client,
829 or fail authentication if they don't support it.
833 The following syntax specification uses the Augmented Backus-Naur
834 form (ABNF) notation as specified in [RFC5234]. "UTF8-2", "UTF8-3",
835 and "UTF8-4" non-terminal are defined in [RFC3629].
842Newman, et al. Standards Track [Page 15]
844RFC 5802 SCRAM July 2010
847 ALPHA = <as defined in RFC 5234 appendix B.1>
848 DIGIT = <as defined in RFC 5234 appendix B.1>
849 UTF8-2 = <as defined in RFC 3629 (STD 63)>
850 UTF8-3 = <as defined in RFC 3629 (STD 63)>
851 UTF8-4 = <as defined in RFC 3629 (STD 63)>
853 attr-val = ALPHA "=" value
854 ;; Generic syntax of any attribute sent
855 ;; by server or client
859 value-safe-char = %x01-2B / %x2D-3C / %x3E-7F /
860 UTF8-2 / UTF8-3 / UTF8-4
861 ;; UTF8-char except NUL, "=", and ",".
863 value-char = value-safe-char / "="
865 printable = %x21-2B / %x2D-7E
866 ;; Printable ASCII except ",".
867 ;; Note that any "printable" is also
870 base64-char = ALPHA / DIGIT / "/" / "+"
872 base64-4 = 4base64-char
874 base64-3 = 3base64-char "="
876 base64-2 = 2base64-char "=="
878 base64 = *base64-4 [base64-3 / base64-2]
880 posit-number = %x31-39 *DIGIT
881 ;; A positive number.
883 saslname = 1*(value-safe-char / "=2C" / "=3D")
884 ;; Conforms to <value>.
886 authzid = "a=" saslname
887 ;; Protocol specific.
890 ;; See RFC 5056, Section 7.
891 ;; E.g., "tls-server-end-point" or
898Newman, et al. Standards Track [Page 16]
900RFC 5802 SCRAM July 2010
904 ;; "n" -> client doesn't support channel binding.
905 ;; "y" -> client does support channel binding
906 ;; but thinks the server does not.
907 ;; "p" -> client requires channel binding.
908 ;; The selected channel binding follows "p=".
911 ;; GS2 header for SCRAM
912 ;; (the actual GS2 header includes an optional
913 ;; flag to indicate that the GSS mechanism is not
914 ;; "standard", but since SCRAM is "standard", we
915 ;; don't include that flag).
917 username = "n=" saslname
918 ;; Usernames are prepared using SASLprep.
920 reserved-mext = "m=" 1*(value-char)
921 ;; Reserved for signaling mandatory extensions.
922 ;; The exact syntax will be defined in
926 ;; base64 encoding of cbind-input.
930 nonce = "r=" c-nonce [s-nonce]
931 ;; Second part provided by server.
939 verifier = "v=" base64
940 ;; base-64 encoded ServerSignature.
942 iteration-count = "i=" posit-number
943 ;; A positive number.
945 client-first-message-bare =
947 username "," nonce ["," extensions]
950 gs2-header client-first-message-bare
954Newman, et al. Standards Track [Page 17]
956RFC 5802 SCRAM July 2010
960 [reserved-mext ","] nonce "," salt ","
961 iteration-count ["," extensions]
963 client-final-message-without-proof =
964 channel-binding "," nonce [","
967 client-final-message =
968 client-final-message-without-proof "," proof
970 server-error = "e=" server-error-value
972 server-error-value = "invalid-encoding" /
975 "channel-bindings-dont-match" /
976 "server-does-support-channel-binding" /
977 ; server does not support channel binding
978 "channel-binding-not-supported" /
979 "unsupported-channel-binding-type" /
981 "invalid-username-encoding" /
982 ; invalid username encoding (invalid UTF-8 or
986 server-error-value-ext
987 ; Unrecognized errors should be treated as "other-error".
988 ; In order to prevent information disclosure, the server
989 ; may substitute the real reason with "other-error".
991 server-error-value-ext = value
992 ; Additional error reasons added by extensions
995 server-final-message = (server-error / verifier)
998 extensions = attr-val *("," attr-val)
999 ;; All extensions are optional,
1000 ;; i.e., unrecognized attributes
1001 ;; not defined in this document
1004 cbind-data = 1*OCTET
1010Newman, et al. Standards Track [Page 18]
1012RFC 5802 SCRAM July 2010
1016 ;; cbind-data MUST be present for
1017 ;; gs2-cbind-flag of "p" and MUST be absent
10208. SCRAM as a GSS-API Mechanism
1022 This section and its sub-sections and all normative references of it
1023 not referenced elsewhere in this document are INFORMATIONAL for SASL
1024 implementors, but they are NORMATIVE for GSS-API implementors.
1026 SCRAM is actually also a GSS-API mechanism. The messages are the
1027 same, but a) the GS2 header on the client's first message and channel
1028 binding data is excluded when SCRAM is used as a GSS-API mechanism,
1029 and b) the RFC2743 section 3.1 initial context token header is
1030 prefixed to the client's first authentication message (context
1033 The GSS-API mechanism OID for SCRAM-SHA-1 is 1.3.6.1.5.5.14 (see
1036 SCRAM security contexts always have the mutual_state flag
1037 (GSS_C_MUTUAL_FLAG) set to TRUE. SCRAM does not support credential
1038 delegation, therefore SCRAM security contexts alway have the
1039 deleg_state flag (GSS_C_DELEG_FLAG) set to FALSE.
10418.1. GSS-API Principal Name Types for SCRAM
1043 SCRAM does not explicitly name acceptor principals. However, the use
1044 of acceptor principal names to find or prompt for passwords is
1045 useful. Therefore, SCRAM supports standard generic name syntaxes for
1046 acceptors such as GSS_C_NT_HOSTBASED_SERVICE (see [RFC2743], Section
1047 4.1). Implementations should use the target name passed to
1048 GSS_Init_sec_context(), if any, to help retrieve or prompt for SCRAM
1051 SCRAM supports only a single name type for initiators:
1052 GSS_C_NT_USER_NAME. GSS_C_NT_USER_NAME is the default name type for
1055 There is no name canonicalization procedure for SCRAM beyond applying
1056 SASLprep as described in Section 5.1.
1058 The query, display, and exported name syntaxes for SCRAM principal
1059 names are all the same. There are no SCRAM-specific name syntaxes
1060 (SCRAM initiator principal names are free-form); -- applications
1061 should use generic GSS-API name types such as GSS_C_NT_USER_NAME and
1066Newman, et al. Standards Track [Page 19]
1068RFC 5802 SCRAM July 2010
1071 GSS_C_NT_HOSTBASED_SERVICE (see [RFC2743], Section 4). The exported
1072 name token does, of course, conform to [RFC2743], Section 3.2, but
1073 the "NAME" part of the token is just a SCRAM user name.
10758.2. GSS-API Per-Message Tokens for SCRAM
1077 The per-message tokens for SCRAM as a GSS-API mechanism SHALL be the
1078 same as those for the Kerberos V GSS-API mechanism [RFC4121] (see
1079 Section 4.2 and sub-sections), using the Kerberos V "aes128-cts-hmac-
1080 sha1-96" enctype [RFC3962].
1082 The replay_det_state (GSS_C_REPLAY_FLAG), sequence_state
1083 (GSS_C_SEQUENCE_FLAG), conf_avail (GSS_C_CONF_FLAG) and integ_avail
1084 (GSS_C_CONF_FLAG) security context flags are always set to TRUE.
1086 The 128-bit session "protocol key" SHALL be derived by using the
1087 least significant (right-most) 128 bits of HMAC(StoredKey, "GSS-API
1088 session key" || ClientKey || AuthMessage). "Specific keys" are then
1089 derived as usual as described in Section 2 of [RFC4121], [RFC3961],
1092 The terms "protocol key" and "specific key" are Kerberos V5 terms
1095 SCRAM does support PROT_READY, and is PROT_READY on the initiator
1096 side first upon receipt of the server's reply to the initial security
10998.3. GSS_Pseudo_random() for SCRAM
1101 The GSS_Pseudo_random() [RFC4401] for SCRAM SHALL be the same as for
1102 the Kerberos V GSS-API mechanism [RFC4402]. There is no acceptor-
1103 asserted sub-session key for SCRAM, thus GSS_C_PRF_KEY_FULL and
1104 GSS_C_PRF_KEY_PARTIAL are equivalent for SCRAM's GSS_Pseudo_random().
1105 The protocol key to be used for the GSS_Pseudo_random() SHALL be the
1106 same as the key defined in Section 8.2.
11089. Security Considerations
1110 If the authentication exchange is performed without a strong security
1111 layer (such as TLS with data confidentiality), then a passive
1112 eavesdropper can gain sufficient information to mount an offline
1113 dictionary or brute-force attack that can be used to recover the
1114 user's password. The amount of time necessary for this attack
1115 depends on the cryptographic hash function selected, the strength of
1116 the password, and the iteration count supplied by the server. An
1117 external security layer with strong encryption will prevent this
1122Newman, et al. Standards Track [Page 20]
1124RFC 5802 SCRAM July 2010
1127 If the external security layer used to protect the SCRAM exchange
1128 uses an anonymous key exchange, then the SCRAM channel binding
1129 mechanism can be used to detect a man-in-the-middle attack on the
1130 security layer and cause the authentication to fail as a result.
1131 However, the man-in-the-middle attacker will have gained sufficient
1132 information to mount an offline dictionary or brute-force attack.
1133 For this reason, SCRAM allows to increase the iteration count over
1134 time. (Note that a server that is only in possession of "StoredKey"
1135 and "ServerKey" can't automatically increase the iteration count upon
1136 successful authentication. Such an increase would require resetting
1137 the user's password.)
1139 If the authentication information is stolen from the authentication
1140 database, then an offline dictionary or brute-force attack can be
1141 used to recover the user's password. The use of salt mitigates this
1142 attack somewhat by requiring a separate attack on each password.
1143 Authentication mechanisms that protect against this attack are
1144 available (e.g., the EKE class of mechanisms). RFC 2945 [RFC2945] is
1145 an example of such technology. The WG elected not to use EKE like
1146 mechanisms as a basis for SCRAM.
1148 If an attacker obtains the authentication information from the
1149 authentication repository and either eavesdrops on one authentication
1150 exchange or impersonates a server, the attacker gains the ability to
1151 impersonate that user to all servers providing SCRAM access using the
1152 same hash function, password, iteration count, and salt. For this
1153 reason, it is important to use randomly generated salt values.
1155 SCRAM does not negotiate a hash function to use. Hash function
1156 negotiation is left to the SASL mechanism negotiation. It is
1157 important that clients be able to sort a locally available list of
1158 mechanisms by preference so that the client may pick the appropriate
1159 mechanism to use from a server's advertised mechanism list. This
1160 preference order is not specified here as it is a local matter. The
1161 preference order should include objective and subjective notions of
1162 mechanism cryptographic strength (e.g., SCRAM with a successor to
1163 SHA-1 may be preferred over SCRAM with SHA-1).
1165 Note that to protect the SASL mechanism negotiation applications
1166 normally must list the server mechanisms twice: once before and once
1167 after authentication, the latter using security layers. Since SCRAM
1168 does not provide security layers, the only ways to protect the
1169 mechanism negotiation are a) use channel binding to an external
1170 channel, or b) use an external channel that authenticates a user-
1171 provided server name.
1178Newman, et al. Standards Track [Page 21]
1180RFC 5802 SCRAM July 2010
1183 SCRAM does not protect against downgrade attacks of channel binding
1184 types. The complexities of negotiating a channel binding type, and
1185 handling down-grade attacks in that negotiation, were intentionally
1186 left out of scope for this document.
1188 A hostile server can perform a computational denial-of-service attack
1189 on clients by sending a big iteration count value.
1191 See [RFC4086] for more information about generating randomness.
119310. IANA Considerations
1195 IANA has added the following family of SASL mechanisms to the SASL
1196 Mechanism registry established by [RFC4422]:
1199 Subject: Registration of a new SASL family SCRAM
1201 SASL mechanism name (or prefix for the family): SCRAM-*
1202 Security considerations: Section 7 of [RFC5802]
1203 Published specification (optional, recommended): [RFC5802]
1204 Person & email address to contact for further information:
1205 IETF SASL WG <sasl@ietf.org>
1206 Intended usage: COMMON
1207 Owner/Change controller: IESG <iesg@ietf.org>
1208 Note: Members of this family MUST be explicitly registered
1209 using the "IETF Review" [RFC5226] registration procedure.
1210 Reviews MUST be requested on the SASL mailing list
1211 <sasl@ietf.org> (or a successor designated by the responsible
1214 Note to future SCRAM-mechanism designers: each new SCRAM-SASL
1215 mechanism MUST be explicitly registered with IANA and MUST comply
1216 with SCRAM-mechanism naming convention defined in Section 4 of this
1234Newman, et al. Standards Track [Page 22]
1236RFC 5802 SCRAM July 2010
1239 IANA has added the following entries to the SASL Mechanism registry
1240 established by [RFC4422]:
1243 Subject: Registration of a new SASL mechanism SCRAM-SHA-1
1245 SASL mechanism name (or prefix for the family): SCRAM-SHA-1
1246 Security considerations: Section 7 of [RFC5802]
1247 Published specification (optional, recommended): [RFC5802]
1248 Person & email address to contact for further information:
1249 IETF SASL WG <sasl@ietf.org>
1250 Intended usage: COMMON
1251 Owner/Change controller: IESG <iesg@ietf.org>
1255 Subject: Registration of a new SASL mechanism SCRAM-SHA-1-PLUS
1257 SASL mechanism name (or prefix for the family): SCRAM-SHA-1-PLUS
1258 Security considerations: Section 7 of [RFC5802]
1259 Published specification (optional, recommended): [RFC5802]
1260 Person & email address to contact for further information:
1261 IETF SASL WG <sasl@ietf.org>
1262 Intended usage: COMMON
1263 Owner/Change controller: IESG <iesg@ietf.org>
1266 Per this document, IANA has assigned a GSS-API mechanism OID for
1267 SCRAM-SHA-1 from the iso.org.dod.internet.security.mechanisms prefix
1268 (see "SMI Security for Mechanism Codes" registry).
1272 This document benefited from discussions on the SASL WG mailing list.
1273 The authors would like to specially thank Dave Cridland, Simon
1274 Josefsson, Jeffrey Hutzelman, Kurt Zeilenga, Pasi Eronen, Ben
1275 Campbell, Peter Saint-Andre, and Tobias Markmann for their
1276 contributions to this document. A special thank you to Simon
1277 Josefsson for shepherding this document and for doing one of the
1278 first implementations of this specification.
1290Newman, et al. Standards Track [Page 23]
1292RFC 5802 SCRAM July 2010
129712.1. Normative References
1299 [RFC2104] Krawczyk, H., Bellare, M., and R. Canetti, "HMAC: Keyed-
1300 Hashing for Message Authentication", RFC 2104,
1303 [RFC2119] Bradner, S., "Key words for use in RFCs to Indicate
1304 Requirement Levels", BCP 14, RFC 2119, March 1997.
1306 [RFC3174] Eastlake, D. and P. Jones, "US Secure Hash Algorithm 1
1307 (SHA1)", RFC 3174, September 2001.
1309 [RFC3454] Hoffman, P. and M. Blanchet, "Preparation of
1310 Internationalized Strings ("stringprep")", RFC 3454,
1313 [RFC3629] Yergeau, F., "UTF-8, a transformation format of ISO
1314 10646", STD 63, RFC 3629, November 2003.
1316 [RFC4013] Zeilenga, K., "SASLprep: Stringprep Profile for User Names
1317 and Passwords", RFC 4013, February 2005.
1319 [RFC4422] Melnikov, A. and K. Zeilenga, "Simple Authentication and
1320 Security Layer (SASL)", RFC 4422, June 2006.
1322 [RFC4648] Josefsson, S., "The Base16, Base32, and Base64 Data
1323 Encodings", RFC 4648, October 2006.
1325 [RFC5056] Williams, N., "On the Use of Channel Bindings to Secure
1326 Channels", RFC 5056, November 2007.
1328 [RFC5234] Crocker, D. and P. Overell, "Augmented BNF for Syntax
1329 Specifications: ABNF", STD 68, RFC 5234, January 2008.
1331 [RFC5929] Altman, J., Williams, N., and L. Zhu, "Channel Bindings
1332 for TLS", RFC 5929, July 2010.
133412.2. Normative References for GSS-API Implementors
1336 [RFC2743] Linn, J., "Generic Security Service Application Program
1337 Interface Version 2, Update 1", RFC 2743, January 2000.
1339 [RFC3961] Raeburn, K., "Encryption and Checksum Specifications for
1340 Kerberos 5", RFC 3961, February 2005.
1346Newman, et al. Standards Track [Page 24]
1348RFC 5802 SCRAM July 2010
1351 [RFC3962] Raeburn, K., "Advanced Encryption Standard (AES)
1352 Encryption for Kerberos 5", RFC 3962, February 2005.
1354 [RFC4121] Zhu, L., Jaganathan, K., and S. Hartman, "The Kerberos
1355 Version 5 Generic Security Service Application Program
1356 Interface (GSS-API) Mechanism: Version 2", RFC 4121,
1359 [RFC4401] Williams, N., "A Pseudo-Random Function (PRF) API
1360 Extension for the Generic Security Service Application
1361 Program Interface (GSS-API)", RFC 4401, February 2006.
1363 [RFC4402] Williams, N., "A Pseudo-Random Function (PRF) for the
1364 Kerberos V Generic Security Service Application Program
1365 Interface (GSS-API) Mechanism", RFC 4402, February 2006.
1367 [RFC5801] Josefsson, S. and N. Williams, "Using Generic Security
1368 Service Application Program Interface (GSS-API) Mechanisms
1369 in Simple Authentication and Security Layer (SASL): The
1370 GS2 Mechanism Family", RFC 5801, July 2010.
137212.3. Informative References
1375 Zeilenga, K., "CRAM-MD5 to Historic", Work in Progress,
1379 Melnikov, A., "Moving DIGEST-MD5 to Historic", Work
1380 in Progress, July 2008.
1382 [RFC2865] Rigney, C., Willens, S., Rubens, A., and W. Simpson,
1383 "Remote Authentication Dial In User Service (RADIUS)",
1384 RFC 2865, June 2000.
1386 [RFC2898] Kaliski, B., "PKCS #5: Password-Based Cryptography
1387 Specification Version 2.0", RFC 2898, September 2000.
1389 [RFC2945] Wu, T., "The SRP Authentication and Key Exchange System",
1390 RFC 2945, September 2000.
1392 [RFC4086] Eastlake, D., Schiller, J., and S. Crocker, "Randomness
1393 Requirements for Security", BCP 106, RFC 4086, June 2005.
1395 [RFC4510] Zeilenga, K., "Lightweight Directory Access Protocol
1396 (LDAP): Technical Specification Road Map", RFC 4510,
1402Newman, et al. Standards Track [Page 25]
1404RFC 5802 SCRAM July 2010
1407 [RFC4616] Zeilenga, K., "The PLAIN Simple Authentication and
1408 Security Layer (SASL) Mechanism", RFC 4616, August 2006.
1410 [RFC4949] Shirey, R., "Internet Security Glossary, Version 2",
1411 RFC 4949, August 2007.
1413 [RFC5226] Narten, T. and H. Alvestrand, "Guidelines for Writing an
1414 IANA Considerations Section in RFCs", BCP 26, RFC 5226,
1417 [RFC5246] Dierks, T. and E. Rescorla, "The Transport Layer Security
1418 (TLS) Protocol Version 1.2", RFC 5246, August 2008.
1420 [RFC5803] Melnikov, A., "Lightweight Directory Access Protocol
1421 (LDAP) Schema for Storing Salted Challenge Response
1422 Authentication Mechanism (SCRAM) Secrets", RFC 5803,
1425 [tls-server-end-point]
1426 IANA, "Registration of TLS server end-point channel
1427 bindings", available from http://www.iana.org, June 2008.
1458Newman, et al. Standards Track [Page 26]
1460RFC 5802 SCRAM July 2010
1463Appendix A. Other Authentication Mechanisms
1465 The DIGEST-MD5 [DIGESTHISTORIC] mechanism has proved to be too
1466 complex to implement and test, and thus has poor interoperability.
1467 The security layer is often not implemented, and almost never used;
1468 everyone uses TLS instead. For a more complete list of problems with
1469 DIGEST-MD5 that led to the creation of SCRAM, see [DIGESTHISTORIC].
1471 The CRAM-MD5 SASL mechanism, while widely deployed, also has some
1472 problems. In particular, it is missing some modern SASL features
1473 such as support for internationalized usernames and passwords,
1474 support for passing of authorization identity, and support for
1475 channel bindings. It also doesn't support server authentication.
1476 For a more complete list of problems with CRAM-MD5, see
1479 The PLAIN [RFC4616] SASL mechanism allows a malicious server or
1480 eavesdropper to impersonate the authenticating user to any other
1481 server for which the user has the same password. It also sends the
1482 password in the clear over the network, unless TLS is used. Server
1483 authentication is not supported.
1485Appendix B. Design Motivations
1487 The following design goals shaped this document. Note that some of
1488 the goals have changed since the initial version of the document.
1490 o The SASL mechanism has all modern SASL features: support for
1491 internationalized usernames and passwords, support for passing of
1492 authorization identity, and support for channel bindings.
1494 o The protocol supports mutual authentication.
1496 o The authentication information stored in the authentication
1497 database is not sufficient by itself to impersonate the client.
1499 o The server does not gain the ability to impersonate the client to
1500 other servers (with an exception for server-authorized proxies),
1501 unless such other servers allow SCRAM authentication and use the
1502 same salt and iteration count for the user.
1504 o The mechanism is extensible, but (hopefully) not over-engineered
1507 o The mechanism is easier to implement than DIGEST-MD5 in both
1508 clients and servers.
1514Newman, et al. Standards Track [Page 27]
1516RFC 5802 SCRAM July 2010
1527 EMail: chris.newman@oracle.com
1531 Oryx Mail Systems GmbH
1533 EMail: ams@toroid.org
1539 EMail: Alexey.Melnikov@isode.com
1548 EMail: Nicolas.Williams@oracle.com
1570Newman, et al. Standards Track [Page 28]