rfc-5802

Salted Challenge Response Authentication Mechanism (SCRAM) SASL and GSS-API Mechanisms

C. Newman, A. Menon-Sen, A. Melnikov, N. Williams
date2010-07 streamIETF areasec wgsasl statusPROPOSED STANDARD pages28 canonicalhttps://www.rfc-editor.org/rfc/rfc5802 doi10.17487/RFC5802 errataview
The secure authentication mechanism most widely deployed and used by Internet application protocols is the transmission of clear-text passwords over a channel protected by Transport Layer Security (TLS). There are some significant security concerns with that mechanism, which could be addressed by the use of a challenge response authentication mechanism protected by TLS. Unfortunately, the challenge response mechanisms presently on the standards track all fail to meet requirements necessary for widespread deployment, and have had success only in limited use. This specification describes a family of Simple Authentication and Security Layer (SASL; RFC 4422) authentication mechanisms called the Salted Challenge Response Authentication Mechanism (SCRAM), which addresses the security concerns and meets the deployability requirements. When used in combination with TLS or an equivalent security layer, a mechanism from this family could improve the status quo for application protocol authentication and provide a suitable choice for a mandatory-to-implement mechanism for future application protocol standards. [STANDARDS-TRACK]

updated by

Extracted elements (30)

design-rationale §1

SCRAM intentionally omits security layer negotiation (confidentiality/integrity). It is designed to be used with an external security layer such as TLS or SSH, with optional channel binding to that layer, rather than providing its own.

security, tls

design-rationale §2.2

The Hi() function is essentially PBKDF2 with HMAC as the PRF and dkLen equal to the HMAC output length. The iteration count 'i' is deliberately configurable and recommended to increase over time to raise the cost of offline attacks as hardware improves.

crypto, security

design-rationale §1

The server stores only StoredKey = H(ClientKey) and ServerKey rather than the plaintext password or SaltedPassword. This means the stored authentication information is not sufficient by itself to impersonate the client, and a server compromise does not directly yield impersonation capability.

security, crypto

interoperability-note §8

SCRAM conforms to the GS2 bridge (RFC 5801) between SASL and GSS-API, defining both a SASL mechanism and a GSS-API mechanism. When used as a GSS-API mechanism, the GS2 header and channel binding data are excluded from the first message, and the RFC 2743 Section 3.1 initial context token header is prepended instead.

security, crypto

normative-requirement §5.1 SHOULD

Before sending the username to the server, the client SHOULD prepare it using the SASLprep profile of stringprep treating it as a query string; if preparation fails or yields an empty string, the client SHOULD abort the exchange.

security

normative-requirement §3 MUST

Both the username and the password MUST be encoded in UTF-8. Implementations MUST either implement SASLprep or disallow use of non-US-ASCII Unicode codepoints.

security

normative-requirement §4 MUST

For interoperability, all SCRAM clients and servers MUST implement the SCRAM-SHA-1 authentication mechanism using the SHA-1 hash function as defined in RFC 3174.

crypto, security

normative-requirement §5.1 SHOULD

For SCRAM-SHA-1/SCRAM-SHA-1-PLUS, servers SHOULD announce a hash iteration-count of at least 4096.

security, crypto

normative-requirement §6 MUST

If the channel binding flag is 'y' and the server supports channel binding, the server MUST fail authentication, as this indicates a potential downgrade attack.

security, tls

normative-requirement §6 MUST

If the channel binding flag was 'p' and the server does not support the indicated channel binding type, the server MUST fail authentication.

security, tls

normative-requirement §5 MUST

If the ServerSignature computed by the client does not match the value sent by the server, the client MUST consider the authentication exchange unsuccessful and may need to drop the connection.

security, crypto

normative-requirement §5.1 MUST

Mandatory extensions sent by one peer but not understood by the other MUST cause authentication failure; unknown optional extensions MUST be ignored upon receipt.

security

normative-requirement §6.1 MUST

Servers MUST implement the 'tls-unique' channel binding type if they implement any channel binding; clients SHOULD implement 'tls-unique' as well.

security, tls

normative-requirement §5.1 MUST

The characters ',' and '=' in usernames are sent as '=2C' and '=3D' respectively. If the server receives a username containing '=' not followed by '2C' or '3D', the server MUST fail the authentication.

security

normative-requirement §5.1 MUST

The client MUST verify that the initial part of the nonce used in subsequent messages is the same as the nonce it initially specified; the server MUST verify that the nonce sent by the client in the second message matches the one sent by the server in its first message.

security, crypto

normative-requirement §5.1 MUST

The presence of the 'm' attribute (reserved for mandatory extensions) in a client or server message MUST cause authentication failure when parsed by the other end.

security

normative-requirement §6 MUST

The server MUST always validate the client's 'c=' field by constructing the expected value and checking that it matches.

security, crypto

normative-requirement §5.1 MUST

Upon receipt of the username, the server MUST either prepare it using SASLprep or be prepared to do SASLprep-aware comparisons and lookups; regardless, the server MUST use the username as received (unprepared) in hash calculations.

security, crypto

protocol-element §4

SCRAM mechanism names take the form 'SCRAM-<HASH>' and optionally 'SCRAM-<HASH>-PLUS' for channel-binding variants. SASL mechanism names are limited to 20 octets, allowing hash names up to 9 octets long.

security, registry

protocol-element §7

The gs2-cbind-flag signals channel binding intent: 'n' = client does not support channel binding; 'y' = client supports it but believes server does not; 'p=<type>' = client requires channel binding of the named type. The flag must be the first element of the client-first-message.

security, tls

protocol-element §3

The SCRAM algorithm derives: SaltedPassword = Hi(Normalize(password), salt, i); ClientKey = HMAC(SaltedPassword, "Client Key"); StoredKey = H(ClientKey); ClientProof = ClientKey XOR HMAC(StoredKey, AuthMessage); ServerKey = HMAC(SaltedPassword, "Server Key"); ServerSignature = HMAC(ServerKey, AuthMessage). The server stores only StoredKey and ServerKey.

crypto, security

registry §10

IANA registered the SCRAM-* family of SASL mechanisms, SCRAM-SHA-1, and SCRAM-SHA-1-PLUS in the SASL Mechanism registry. New SCRAM-SASL mechanisms MUST be explicitly registered via IETF Review. A GSS-API OID for SCRAM-SHA-1 (1.3.6.1.5.5.14) was also assigned.

registry, security

security-consideration §9

A hostile server can perform a computational denial-of-service attack on clients by advertising a very large iteration count value.

security

security-consideration §9

If authentication information is stolen from the database, an attacker who also eavesdrops on or impersonates a server can impersonate the user to all servers using the same hash function, password, iteration count, and salt. Using randomly generated salts is therefore critical.

security, crypto

security-consideration §9

SCRAM's channel binding 'y' flag mechanism detects downgrade attacks on mechanism negotiation (e.g., an attacker stripping the '-PLUS' suffix from advertised mechanisms), causing authentication to fail rather than silently proceeding over an unbound channel.

security, tls

security-consideration §9

Without a strong security layer (e.g., TLS with confidentiality), a passive eavesdropper can gather sufficient information to mount an offline dictionary or brute-force attack to recover the user's password. The iteration count and external encryption layer are the primary mitigations.

security, crypto, tls

wire-format §7

The client-final-message consists of: 'c=' (base64-encoded GS2 header + optional channel binding data), 'r=' (complete nonce), optional extensions, and 'p=' (base64-encoded ClientProof).

crypto, security

wire-format §7

The client-first-message consists of a GS2 header (gs2-cbind-flag ',' optional-authzid ',') followed by an optional reserved-mext, the 'n=' username attribute, and the 'r=' client nonce (printable ASCII excluding ','). Example: 'n,,n=user,r=fyko+d2lbbFgONRv9qkxdawL'.

crypto, security

wire-format §7

The server-final-message is either a 'v=' (base64-encoded ServerSignature) on success or an 'e=' (server-error-value) on failure, optionally followed by extensions. The server-final-message is OPTIONAL on authentication failure.

crypto, security

wire-format §7

The server-first-message contains: optional reserved-mext, 'r=' (client nonce + server nonce), 's=' (base64-encoded salt), and 'i=' (positive iteration count). Example: 'r=fyko+...,s=QSXCR+Q6sek8bf92,i=4096'.

crypto, security