RFC 7616

HTTP Digest Access Authentication

๐Ÿ“… published September 2015, from ietf

Part 1 of 7, more to come ๐ŸŽ€

HTTP Digest Access Authentication ๐Ÿ’–

  • RFC: 7616
  • Category: Standards Track
  • Date: September 2015
  • Authors: R. Shekh-Yusef, Ed. (Avaya), D. Ahrens (Independent), S. Bremer (Netzkonform)
  • Obsoletes: RFC 2617
  • Updates: nothing listed
  • ISSN: 2070-1721
  • Series: Internet Engineering Task Force (IETF)

Abstract โœจ

okay so HTTP already has this simple challenge-response auth thing where a server can challenge a client's request, and the client can reply with its auth info ๐Ÿซถ this doc defines the HTTP Digest Authentication scheme that plugs into that mechanism. it's giving clean and it's giving organized ๐Ÿ’…

Status of This Memo ๐Ÿงš

this is an Internet Standards Track document ๐Ÿ”ฅ

it's a product of the Internet Engineering Task Force (IETF) and it represents the consensus of the IETF community. it got public review and was approved for publication by the Internet Engineering Steering Group (IESG). for more info on Internet Standards, check Section 2 of RFC 5741.

for the current status, any errata, and how to give feedback, go to http://www.rfc-editor.org/info/rfc7616.

Copyright (c) 2015 IETF Trust and the persons identified as the document authors. All rights reserved.

this document is subject to BCP 78 and the IETF Trust's Legal Provisions Relating to IETF Documents (http://trustee.ietf.org/license-info) as in effect on the date of publication. please read these carefully, because they describe your rights and restrictions for this document. Code Components extracted from this document must include Simplified BSD License text as described in Section 4.e of the Trust Legal Provisions, and they are provided without warranty as described in the Simplified BSD License.

this document may contain material from IETF Documents or IETF Contributions published or made publicly available before November 10, 2008. the person(s) controlling the copyright in some of that material may not have granted the IETF Trust the right to allow modifications outside the IETF Standards Process. without an adequate license from those copyright holders, this document may not be modified outside the IETF Standards Process, and derivative works of it may not be created outside the IETF Standards Process. the exceptions are formatting it for publication as an RFC or translating it into languages other than English. ๐Ÿซ 

Table of Contents ๐Ÿ“–

   1.  Introduction  . . . . . . . . . . . . . . . . . . . . . . . .   4
     1.1.  Terminology . . . . . . . . . . . . . . . . . . . . . . .   4
   2.  Syntax Convention . . . . . . . . . . . . . . . . . . . . . .   4
     2.1.  Examples  . . . . . . . . . . . . . . . . . . . . . . . .   4
     2.2.  ABNF  . . . . . . . . . . . . . . . . . . . . . . . . . .   4
   3.  Digest Access Authentication Scheme . . . . . . . . . . . . .   5
     3.1.  Overall Operation . . . . . . . . . . . . . . . . . . . .   5
     3.2.  Representation of Digest Values . . . . . . . . . . . . .   5
     3.3.  The WWW-Authenticate Response Header Field  . . . . . . .   5
     3.4.  The Authorization Header Field  . . . . . . . . . . . . .   9
       3.4.1.  Response  . . . . . . . . . . . . . . . . . . . . . .  11
       3.4.2.  A1  . . . . . . . . . . . . . . . . . . . . . . . . .  11
       3.4.3.  A2  . . . . . . . . . . . . . . . . . . . . . . . . .  12
       3.4.4.  Username Hashing  . . . . . . . . . . . . . . . . . .  12
       3.4.5.  Parameter Values and Quoted-String  . . . . . . . . .  12
       3.4.6.  Various Considerations  . . . . . . . . . . . . . . .  13
     3.5.  The Authentication-Info and Proxy-Authentication-Info
           Header Fields . . . . . . . . . . . . . . . . . . . . . .  14
     3.6.  Digest Operation  . . . . . . . . . . . . . . . . . . . .  15
     3.7.  Security Protocol Negotiation . . . . . . . . . . . . . .  16
     3.8.  Proxy-Authenticate and Proxy-Authorization  . . . . . . .  17
     3.9.  Examples  . . . . . . . . . . . . . . . . . . . . . . . .  18
       3.9.1.  Example with SHA-256 and MD5  . . . . . . . . . . . .  18
       3.9.2.  Example with SHA-512-256, Charset, and Userhash . . .  19
   4.  Internationalization Considerations . . . . . . . . . . . . .  20
   5.  Security Considerations . . . . . . . . . . . . . . . . . . .  21
     5.1.  Limitations . . . . . . . . . . . . . . . . . . . . . . .  21
     5.2.  Storing Passwords . . . . . . . . . . . . . . . . . . . .  21
     5.3.  Authentication of Clients Using Digest Authentication . .  22
     5.4.  Limited-Use Nonce Values  . . . . . . . . . . . . . . . .  23
     5.5.  Replay Attacks  . . . . . . . . . . . . . . . . . . . . .  23
     5.6.  Weakness Created by Multiple Authentication Schemes . . .  24
     5.7.  Online Dictionary Attacks . . . . . . . . . . . . . . . .  24
     5.8.  Man-in-the-Middle Attacks . . . . . . . . . . . . . . . .  25
     5.9.  Chosen Plaintext Attacks  . . . . . . . . . . . . . . . .  25
     5.10. Precomputed Dictionary Attacks  . . . . . . . . . . . . .  26
     5.11. Batch Brute-Force Attacks . . . . . . . . . . . . . . . .  26
     5.12. Parameter Randomness  . . . . . . . . . . . . . . . . . .  26
     5.13. Summary . . . . . . . . . . . . . . . . . . . . . . . . .  26
   6.  IANA Considerations . . . . . . . . . . . . . . . . . . . . .  27
     6.1.  Hash Algorithms for HTTP Digest Authentication  . . . . .  27
     6.2.  Digest Scheme Registration  . . . . . . . . . . . . . . .  28
   7.  References  . . . . . . . . . . . . . . . . . . . . . . . . .  28
     7.1.  Normative References  . . . . . . . . . . . . . . . . . .  28
     7.2.  Informative References  . . . . . . . . . . . . . . . . .  30
   Appendix A.  Changes from RFC 2617  . . . . . . . . . . . . . . .  31
   Acknowledgments . . . . . . . . . . . . . . . . . . . . . . . . .  31
   Authors' Addresses  . . . . . . . . . . . . . . . . . . . . . . .  32

1. Introduction ๐Ÿฆ‹

okay so HTTP gives you a simple challenge-response auth mechanism. a server can use it to challenge a client's request, and the client uses it to send its auth info. this document defines the HTTP Digest Authentication scheme that works with that HTTP authentication mechanism. iconic.

this doc extends [RFC2617] and is generally backward compatible with it. see Appendix A for the new capabilities this spec brings in โœจ

the nitty-gritty of the challenge-response flow lives in "Hypertext Transfer Protocol (HTTP/1.1): Authentication" [RFC7235].

the combo of this doc, the "Basic" authentication scheme [RFC7617], "HTTP Authentication-Info and Proxy-Authentication-Info Response Header Fields" [RFC7615], and "Hypertext Transfer Protocol (HTTP/1.1): Authentication" [RFC7235] is what obsoletes [RFC2617]. so yeah, RFC 2617 is retired, bestie ๐Ÿซก

1.1. Terminology ๐Ÿ“

the key words "MUST", "MUST NOT", "REQUIRED", "SHALL", "SHALL NOT", "SHOULD", "SHOULD NOT", "RECOMMENDED", "NOT RECOMMENDED", "MAY", and "OPTIONAL" in this document are to be interpreted as described in [RFC2119]. these capital words are the official requirement language, so pay attention to them ๐Ÿ‘‘

2. Syntax Convention ๐Ÿ’œ

2.1. Examples ๐ŸŒธ

for clarity and readability, the extended parameters, or the header fields and parameters in the examples, might get broken into multiple lines. any line that's indented in this document is a continuation of the line before it. ๐Ÿ™ˆ

2.2. ABNF ๐Ÿ’…

this spec uses the Augmented Backus-Naur Form (ABNF) notation of [RFC5234] and the ABNF List Extension of [RFC7230].

3. Digest Access Authentication Scheme โœจ

3.1. Overall Operation ๐Ÿงš

the Digest scheme is built on a simple challenge-response paradigm. it challenges using a nonce value, and it might indicate that username hashing is supported. a valid response contains an unkeyed digest of the username, the password, the given nonce value, the HTTP method, and the requested URI. so the password is never sent in the clear, and the username can be hashed depending on what the server indicated. the username and password must be prearranged in some way that this document doesn't cover. main character energy ๐Ÿ’–

3.2. Representation of Digest Values ๐Ÿ”ฅ

an optional header field lets the server say which algorithm was used to make the unkeyed digest or digest. this document adds the SHA-256 and SHA-512/256 algorithms. to keep backwards compatibility with [RFC2617], the MD5 algorithm is still supported, but it is NOT RECOMMENDED ๐Ÿ’€

the size of the digest depends on the algorithm. the bits in the digest get converted from most significant to least significant bit, four bits at a time, into ASCII. each group of four bits is written in hex using the characters 0123456789abcdef. so binary 0000 is the character '0', 0001 is '1', and so on, all the way up to 1111 being 'f' ๐ŸŒˆ

if the MD5 algorithm is used, the MD5 digest is 32 hexadecimal characters long. SHA-256 and SHA-512/256 are each 64 hexadecimal characters long. slay the math โœจ

3.3. The WWW-Authenticate Response Header Field โœจ

okay so ๐Ÿฅน when a server gets a request for something that's behind a lock ๐Ÿ”’ and there's no acceptable Authorization header field, it hits back with a 401 Unauthorized status code plus a WWW-Authenticate header field using the Digest scheme, just like the framework above says. ๐Ÿ’… This header can carry these parameters:

realm ๐ŸŽ€ A string that gets shown to users so they know which username and password to use. It should contain at least the name of the host doing the authentication, and it might also say which group of users can get in. For example: "registered_users@example.com". (See Section 2.2 of [RFC7235] for more details.) ๐Ÿ’–

domain ๐ŸŒธ A quoted, space-separated list of URIs, as specified in [RFC3986], that defines the protection space. If a URI is a path-absolute, it's relative to the canonical root URL. (See Section 2.2 of [RFC7235].) An absolute-URI in this list can point to a different server than the web-origin [RFC6454]. The client can use this list to figure out which URIs the same auth info can be sent to: any URI that has a URI in this list as a prefix (after both have been made absolute) MAY be assumed to be in the same protection space. If this parameter is left out or its value is empty, the client SHOULD assume the protection space is every URI on the web-origin. ๐Ÿฆ‹

This parameter isn't meaningful in Proxy-Authenticate header fields, since the protection space there is always the entire proxy. If it shows up anyway, it MUST be ignored. ๐Ÿ™ˆ

nonce ๐Ÿงš A server-specified string that should be uniquely generated each time a 401 response is made. It's advised that this string be Base64 or hexadecimal data. Since the string gets passed in the header field lines as a quoted string, the double-quote character isn't allowed unless it's suitably escaped. ๐Ÿ’…

The contents of the nonce are implementation dependent, and the quality of the implementation depends on making a good choice. โœจ A nonce might, for example, be built as the Base64 encoding of

timestamp H(timestamp ":" ETag ":" secret-data)

where timestamp is a server-generated time, which preferably includes micro- or nanoseconds, or other non-repeating values. ETag is the value of the HTTP ETag header field associated with the requested entity, and secret-data is data known only to the server. ๐Ÿ” With a nonce of this form, a server would recalculate the hash portion after getting the client's authentication header field, and it would reject the request if the hash didn't match the nonce from that header field or if the timestamp isn't recent enough. That's how the server limits how long the nonce stays valid. โฐ Including the ETag stops a replay request for an updated version of the resource. ๐Ÿ™Œ

Putting the client's IP address in the nonce sounds like it would let the server limit reuse of the nonce to the same client that originally got it. But that breaks, because requests from a single user often go through different proxies. Also, IP address spoofing is not that hard. ๐Ÿ’€

An implementation might choose not to accept a previously used nonce or a previously used digest, to protect against a replay attack. Or, an implementation might choose to use one-time nonces or digests for POST or PUT requests and a timestamp for GET requests. For more details on the issues involved, see Section 5 of this document. ๐Ÿ“–

The nonce is opaque to the client. ๐Ÿซถ

opaque ๐Ÿ“ A string of data, specified by the server, that SHOULD be returned by the client unchanged in the Authorization header field of later requests with URIs in the same protection space. It is RECOMMENDED that this string be Base64 or hexadecimal data. ๐ŸŒˆ

stale โญ A case-insensitive flag that says the client's previous request was rejected because the nonce value was stale. If stale is true, the client may wish to simply retry the request with a new encrypted response, without re-prompting the user for a new username and password. The server SHOULD only set stale to true if it receives a request for which the nonce is invalid. If stale is false, or anything other than true, or if the stale parameter isn't present, then the username and/or password are invalid, and new values MUST be obtained. ๐Ÿ˜ญ

algorithm ๐Ÿ”ฅ A string that tells you which algorithm was used to produce the digest and an unkeyed digest. If this isn't present, it's assumed to be "MD5". If the algorithm isn't understood, the challenge SHOULD be ignored (and a different one used, if there's more than one). ๐Ÿ™ƒ

When it's used with the Digest mechanism, each algorithm has two variants: a Session variant and a non-Session variant. The non-Session variant is written as "<algorithm>", e.g., "SHA-256", and the Session variant is written as "<algorithm>-sess", e.g., "SHA-256-sess". ๐Ÿง 

In this document, the string you get by applying the digest algorithm to the data "data" with secret "secret" is written as KD(secret, data). The string you get by applying the unkeyed digest algorithm to the data "data" is written as H(data). KD stands for Keyed Digest, and the notation unq(X) means the value of the quoted-string X without the surrounding quotes and with quoting slashes removed. ๐Ÿงฉ

For "<algorithm>" and "<algorithm>-sess":

H(data) = <algorithm>(data)

and

KD(secret, data) = H(concat(secret, ":", data))

For example, for the "SHA-256" and "SHA-256-sess" algorithms:

H(data) = SHA-256(data)

So the digest is the "<algorithm>" of the secret concatenated with a colon concatenated with the data. โœจ The "<algorithm>-sess" variant is meant to allow efficient third-party authentication servers. For how it differs in usage, see the description in Section 3.4.2. ๐Ÿ‘‘

qop ๐Ÿ’œ This parameter MUST be used by all implementations. It's a quoted string of one or more tokens listing the "quality of protection" values the server supports. The value "auth" means authentication, and the value "auth-int" means authentication with integrity protection. See the descriptions below for calculating the response parameter value for whichever one you pick. Unrecognized options MUST be ignored. ๐Ÿ›ก๏ธ

charset ๐ŸŒท This is an OPTIONAL parameter the server uses to say which encoding scheme it supports. The only allowed value is "UTF-8". ๐Ÿ‡บ๐Ÿ‡น

userhash ๐Ÿซง This is an OPTIONAL parameter the server uses to say it supports username hashing. Valid values are "true" or "false". The default value is "false". ๐Ÿ™Œ

For historical reasons, a sender MUST only generate the quoted string syntax for the following parameters: realm, domain, nonce, opaque, and qop. ๐Ÿ•ฐ๏ธ

For historical reasons, a sender MUST NOT generate the quoted string syntax for the following parameters: stale and algorithm. ๐Ÿ™…โ€โ™€๏ธ


3.4. The Authorization Header Field ๐ŸŽ€

The client is expected to retry the request, sending an Authorization header field line with the Digest scheme, which is defined according to the framework above. The values of the opaque and algorithm fields must be the ones supplied in the WWW-Authenticate response header field for the entity being requested. ๐Ÿ’…

The request can include parameters from the following list:

response ๐Ÿ” A string of hex digits computed as defined below. It proves that the user knows a password. ๐Ÿ—๏ธ

username ๐Ÿ™‹โ€โ™€๏ธ The user's name in the specified realm. The quoted string contains the name in plaintext or the hash code in hexadecimal notation. If the username has characters that aren't allowed inside the ABNF quoted-string production, the username* parameter can be used. Sending both username and username* in the same header option MUST be treated as an error. ๐Ÿšซ

username* ๐ŸŒบ If the userhash parameter value is set to "false" and the username has characters that aren't allowed inside the ABNF quoted-string production, the user's name can be sent with this parameter, using the extended notation defined in [RFC5987]. ๐ŸŽจ

realm ๐ŸŽ€ See the "realm" definition in Section 3.3. ๐Ÿ”

uri ๐Ÿงญ The Effective Request URI (Section 5.5 of [RFC7230]) of the HTTP request. It's duplicated here because proxies are allowed to change the request target ("request-target", Section 3.1.1 of [RFC7230]) in transit. ๐Ÿšš

qop ๐Ÿ’– Shows what "quality of protection" the client applied to the message. Its value MUST be one of the alternatives the server indicated it supports in the WWW-Authenticate header field. These values affect how the response is computed. Note that this is a single token, not a quoted list of alternatives like in WWW-Authenticate. ๐Ÿงฉ

cnonce ๐Ÿฆ‹ This parameter MUST be used by all implementations. The cnonce value is an opaque, quoted, ASCII-only string provided by the client. Both the client and server use it to avoid chosen plaintext attacks, to provide mutual authentication, and to provide some message integrity protection. See the descriptions below of how the rspauth and response values are calculated. ๐Ÿซถ

nc ๐Ÿ”ข This parameter MUST be used by all implementations. The nc parameter stands for "nonce count". The nc value is the hexadecimal count of the number of requests (including the current request) that the client has sent with the nonce value in this request. For example, in the first request sent in response to a given nonce value, the client sends nc=00000001. The point of this parameter is to let the server detect request replays by keeping its own copy of this count. If the same nc value shows up twice, then the request is a replay. See the description below of how the response value is constructed. ๐Ÿ•ต๏ธโ€โ™€๏ธ

userhash ๐Ÿซง This OPTIONAL parameter is used by the client to say the username has been hashed. Valid values are "true" or "false". The default value is "false". ๐ŸŒˆ

For historical reasons, a sender MUST only generate the quoted string syntax for the following parameters: username, realm, nonce, uri, response, cnonce, and opaque. ๐Ÿ•ฐ๏ธ

For historical reasons, a sender MUST NOT generate the quoted string syntax for the following parameters: algorithm, qop, and nc. ๐Ÿ™…โ€โ™€๏ธ

If a parameter or its value is improper, or required parameters are missing, the proper response is a 4xx error code. ๐Ÿšจ If the response is invalid, then a login failure SHOULD be logged, since repeated login failures from a single client may indicate an attacker trying to guess passwords. ๐Ÿ•ต๏ธ The server implementation SHOULD be careful with the information it logs, so that it won't put a cleartext password (e.g., one entered into the username field) into the log. ๐Ÿ™ˆ

The definition of the response above shows the encoding for its value. The following definitions show how that value gets computed. โœจ

3.4.1. Response ๐Ÿ’–

okay so if the qop value is "auth" or "auth-int", the response gets built like this ๐Ÿ”ฅ

response = <"> < KD ( H(A1), unq(nonce)
                             ":" nc
                             ":" unq(cnonce)
                             ":" unq(qop)
                             ":" H(A2)
                    ) <">

see below for the definitions of A1 and A2 ๐Ÿซถ

3.4.2. A1 ๐ŸŒธ

if the algorithm parameter's value is "<algorithm>", e.g., "SHA-256", then A1 is:

A1       = unq(username) ":" unq(realm) ":" passwd

where

passwd   = < user's password >

if the algorithm parameter's value is "<algorithm>-sess", e.g., "SHA-256-sess", then A1 gets calculated using the nonce value from the server's challenge, plus the cnonce value from the client's request, after the client gets a WWW-Authenticate challenge from the server. it uses the server nonce from that challenge (called nonce-prime here) and the client nonce from the response (called cnonce-prime here) to build A1 like this:

A1       = H( unq(username) ":" unq(realm) ":" passwd )
                ":" unq(nonce-prime) ":" unq(cnonce-prime)

this makes a "session key" for authenticating later requests and responses, and it's different for each "authentication session" โœจ, which means way less material gets hashed with any one key. ๐Ÿฆ‹ (note: see further discussion of the authentication session in Section 3.6.) because the server only needs the hash of the user credentials to make the A1 value, this construction could be used with a third-party authentication service so the web server never needs the actual password value ๐Ÿ‘‘. the spec for a protocol like that is beyond the scope of this specification, so we're not going there today ๐Ÿ™ˆ

3.4.3. A2 ๐Ÿงš

if the qop parameter's value is "auth" or is unspecified, then A2 is:

A2       = Method ":" request-uri

if the qop value is "auth-int", then A2 is:

A2       = Method ":" request-uri ":" H(entity-body)

3.4.4. Username Hashing ๐ŸŒˆ

to protect the username while it travels from the client to the server, the server SHOULD set the userhash parameter with the value of "true" in the WWW-Authentication header field. ๐Ÿซถ

if the client supports the userhash parameter, and the userhash parameter value in the WWW-Authentication header field is set to "true", then the client MUST calculate a hash of the username after any other hash calculation and include the userhash parameter with the value of "true" in the Authorization header field. if the client doesn't give the username as a hash value, or doesn't include the userhash parameter with the value of "true", the server MAY reject the request ๐Ÿ’€

the client does this to hash the username, using the same algorithm it used to hash the credentials:

username = H( unq(username) ":" unq(realm) )

3.4.5. Parameter Values and Quoted-String ๐Ÿ’…

heads up, a lot of the parameter values (like the username value) are defined as a "quoted-string". the "unq" notation means the surrounding quotation marks get removed when forming the string A1 โœ‚๏ธ so if the Authorization header field includes the fields

username="Mufasa", realm="myhost@example.com"

and the user Mufasa has the password "Circle Of Life", then H(A1) would be H(Mufasa:myhost@example.com:Circle Of Life) with no quotation marks in the digested string ๐ŸŽ€

no white space is allowed in any of the strings that the digest function H() gets applied to, unless that white space is inside the quoted strings or entity body that make up the string being digested. for example, the string A1 from above must be:

Mufasa:myhost@example.com:Circle Of Life

with no white space on either side of the colons, but with the white space between the words in the password value ๐Ÿ“ the other strings digested by H() must not have white space on either side of the colons that separate their fields, unless that white space was in the quoted strings or entity body being digested.

also, if integrity protection is applied (qop=auth-int), the H(entity-body) is the hash of the entity body, not the message body. it's computed before any transfer encoding is applied by the sender, and after it's been removed by the recipient ๐Ÿ”ฅ this includes multipart boundaries and embedded header fields in each part of any multipart content-type. main character energy for the entity body, ngl ๐Ÿ’œ

3.4.6. Various Considerations ๐Ÿฆ‹

the "Method" value is the HTTP request method, in US-ASCII letters, as specified in Section 3.1.1 of [RFC7230]. the "request-target" value is the request-target from the request line, as specified in Section 3.1.1 of [RFC7230]. this MAY be "*", an "absolute-URI", or an "absolute-path" as specified in Section 2.7 of [RFC7230], but it MUST agree with the request-target. in particular, it MUST be an "absolute-URI" if the request-target is an "absolute-URI". the cnonce value is a client-chosen value whose purpose is to foil chosen plaintext attacks ๐Ÿ›ก๏ธ

the authenticating server MUST assure that the resource designated by the "uri" parameter is the same as the resource specified in the Request-Line. if they aren't, the server SHOULD return a 400 Bad Request error. (since this may be a symptom of an attack, server implementers may want to consider logging such errors ๐Ÿ‘€) the whole point of copying info from the request URL into this field is to handle the possibility that an intermediate proxy alters the client's Request-Line. that altered (but presumably semantically equivalent) request would not produce the same digest the client calculated ๐Ÿซ 

implementers should be aware of how authenticated transactions need to interact with shared caches (see [RFC7234]) ๐Ÿง 


3.5. The Authentication-Info and Proxy-Authentication-Info Header Fields ๐ŸŽ€

the Authentication-Info header field and the Proxy-Authentication-Info header field [RFC7615] are generic fields that MAY be used by a server to share some info about the successful authentication of a client response โœจ

the Digest Authentication scheme MAY add the Authentication-Info header field in the confirmation request, and include parameters from the following list:

nextnonce

the value of the nextnonce parameter is the nonce the server wants the client to use for a future authentication response. the server MAY send the Authentication-Info header field with a nextnonce field as a way of implementing one-time nonces or otherwise changing nonces. if the nextnonce field is present, the client SHOULD use it when constructing the Authorization header field for its next request. if the client fails to do that, it MAY result in a request to re-authenticate from the server with the "stale=true". ๐Ÿ˜ญ server implementations SHOULD carefully consider the performance implications of using this mechanism. pipelined requests won't be possible if every response includes a nextnonce parameter that MUST be used on the next request the server receives. consideration SHOULD be given to the performance vs. security tradeoffs of letting an old nonce value be used for a limited time, so requests can be pipelined. using the nc parameter can keep most of the security advantages of a new server nonce without the deleterious effects on pipelining ๐ŸŒธ

qop

indicates the "quality of protection" options the server applied to the response. the value "auth" indicates authentication; the value "auth-int" indicates authentication with integrity protection. the server SHOULD use the same value for the qop parameter in the response that the client sent in the corresponding request ๐Ÿ’…

rspauth

the optional response digest in the rspauth parameter supports mutual authentication. the server proves it knows the user's secret, and with qop=auth-int it also provides limited integrity protection of the response ๐Ÿ” the rspauth value is calculated like the response in the Authorization header field, except that if qop is set to "auth" or isn't specified in the Authorization header field for the request, A2 is: A2 = ":" request-uri and if "qop=auth-int", then A2 is: A2 = ":" request-uri ":" H(entity-body)

cnonce and nc

the cnonce value and nc value MUST be the ones from the client request this message is responding to. the rspauth, cnonce, and nc parameters MUST be present if "qop=auth" or "qop=auth-int" is specified. ๐Ÿซถ

the Authentication-Info header field is allowed in the trailer of an HTTP message sent with chunked transfer coding ๐Ÿงš

for historical reasons, a sender MUST only generate the quoted string syntax for the following parameters: nextnonce, rspauth, and cnonce.

for historical reasons, a sender MUST NOT generate the quoted string syntax for the following parameters: qop and nc.

for historical reasons, the nc value MUST be exactly 8 hexadecimal digits. it's giving precise, and I'm obsessed ๐ŸŒˆ

3.6. Digest Operation ๐ŸŽ€

okay so once the Authorization header shows up, the server MAY check its validity by looking up the password for the username that was sent ๐Ÿ”. Then it MUST run the exact same digest operation the client ran (like MD5 or SHA-256 ๐Ÿ”ฅ) and compare the result to the given response value. that's the whole vibe โœจ.

ngl this part is so cute: the HTTP server doesn't actually need to know the user's cleartext password ๐Ÿ™ˆ. as long as it has H(A1), it can verify an Authorization header field. no cap, that's iconic. ๐Ÿ’…

the client's response to a WWW-Authenticate challenge for a protection space starts an authentication session with that protection space ๐Ÿฆ‹. the session lasts until the client gets another WWW-Authenticate challenge from any server in that protection space. during the session, a client SHOULD remember the username, password, nonce, nonce count, and opaque values, so it can build the Authorization header field for future requests in that protection space ๐Ÿง . the Authorization header field MAY be included preemptively, which improves server efficiency and skips extra round trips for challenges ๐Ÿš€. the server MAY choose to accept the old Authorization info even though the nonce might not be fresh ๐Ÿคทโ€โ™€๏ธ. or, the server MAY return a 401 response with a new nonce in the WWW-Authenticate header field, which makes the client retry the request. by sending "stale=true" with that response, the server tells the client to retry with the new nonce without prompting for a new username and password ๐Ÿซถ.

because the client is required to send back the opaque parameter the server gave it for the whole session, the opaque data can carry authentication session state ๐ŸŽ. (fyi, anything like that can also be done more easily and safely by putting the state in the nonce, bestie ๐Ÿ‘€.) for example, a server could be responsible for authenticating content that actually lives on another server ๐ŸŒˆ. it would do that by having the first 401 response include a domain parameter whose value includes a URI on the second server, plus an opaque parameter holding the state info. the client retries, and the server might respond with "HTTP Redirection" (Section 6.4 of [RFC7231]) pointing at the URI on the second server. the client follows the redirect and passes an Authorization header field that includes the <opaque> data ๐Ÿ’–.

proxies MUST be totally transparent in the Digest access authentication scheme ๐Ÿ‘ป. that means they MUST forward the WWW-Authenticate, Authentication-Info, and Authorization header fields untouched ๐Ÿ™Œ. if a proxy wants to authenticate a client before forwarding a request to the server, it can do that with the Proxy-Authenticate and Proxy-Authorization header fields from Section 3.8 below ๐Ÿงš.


3.7. Security Protocol Negotiation ๐Ÿฆ‹

it's super useful for a server to know which security schemes a client can handle ๐Ÿ‘€.

it's possible a server wants to require Digest as its authentication method, even if it doesn't know the client supports it ๐Ÿ’…. a client is encouraged to fail gracefully if the server only specifies authentication schemes it can't handle ๐Ÿ™ƒ.

when a server gets a request for a resource, it might challenge the client by responding with a "401 Unauthorized" response that includes one or more WWW-Authenticate header fields ๐Ÿ”. if the server sends multiple challenges, then each one of them MUST use a different digest algorithm ๐ŸŽ€. the server MUST add these challenges to the response in order of preference, starting with the most preferred algorithm and followed by the less preferred one โœจ.

this specification defines the following algorithms:

  • SHA2-256 (mandatory to implement) ๐Ÿ‘‘
  • SHA2-512/256 (as a backup algorithm) ๐Ÿซง
  • MD5 (for backward compatibility) ๐Ÿ•ฐ๏ธ

when the client gets the first challenge, it SHOULD use the first challenge it supports, unless a local policy says otherwise ๐Ÿ’œ.


3.8. Proxy-Authenticate and Proxy-Authorization ๐ŸŒธ

the Digest Authentication scheme can also be used to authenticate users to proxies, proxies to proxies, or proxies to origin servers, using the Proxy-Authenticate and Proxy-Authorization header fields ๐Ÿ›ก๏ธ. these header fields are instances of the ones specified in Sections 4.3 and 4.4 of the HTTP/1.1 specification [RFC7235], and their behavior is subject to the restrictions described there ๐Ÿ“œ. the transactions for proxy authentication are very similar to the ones we already covered ๐Ÿ˜Œ.

upon receiving a request that requires authentication, the proxy/server MUST issue the "407 Proxy Authentication Required" response with a "Proxy-Authenticate" header field ๐Ÿšฆ. the digest-challenge used in the Proxy-Authenticate header field is the same as the one for the WWW-Authenticate header field defined above in Section 3.3 ๐Ÿ”.

then the client/proxy MUST reissue the request with a Proxy-Authorization header field, with parameters specified just like the Authorization header field in Section 3.4 above ๐Ÿ’ซ.

on subsequent responses, the server sends Proxy-Authentication-Info with parameters that match the ones for the Authentication-Info header field ๐Ÿ“จ.

note that, in principle, a client could be asked to authenticate itself to both a proxy and an end-server, but never in the same response ๐Ÿ™ˆ.


3.9. Examples ๐Ÿงš

3.9.1. Example with SHA-256 and MD5 ๐Ÿ’–

this example assumes an access-protected document is being requested from the server with a GET request ๐Ÿ“ฅ. the URI of the document is http://www.example.org/dir/index.html. both client and server know the username for this document is "Mufasa" and the password is "Circle of Life" (with one space between each of the three words) ๐Ÿฆ.

the first time the client requests the document, no Authorization header field is sent, so the server responds with:

HTTP/1.1 401 Unauthorized
WWW-Authenticate: Digest
    realm="http-auth@example.org",
    qop="auth, auth-int",
    algorithm=SHA-256,
    nonce="7ypf/xlj9XXwfDPEoM4URrv/xwf94BcCAzFZH4GiTo0v",
    opaque="FQhe/qaU925kfnzjCev0ciny7QMkPqMAFRtzCUYo5tdS"
WWW-Authenticate: Digest
    realm="http-auth@example.org",
    qop="auth, auth-int",
    algorithm=MD5,
    nonce="7ypf/xlj9XXwfDPEoM4URrv/xwf94BcCAzFZH4GiTo0v",
    opaque="FQhe/qaU925kfnzjCev0ciny7QMkPqMAFRtzCUYo5tdS"

the client can prompt the user for their username and password, and then it responds with a new request that includes the following Authorization header field if the client picks MD5 digest ๐Ÿ”‘:

Authorization: Digest username="Mufasa",
    realm="http-auth@example.org",
    uri="/dir/index.html",
    algorithm=MD5,
    nonce="7ypf/xlj9XXwfDPEoM4URrv/xwf94BcCAzFZH4GiTo0v",
    nc=00000001,
    cnonce="f2/wE4q74E6zIJEtWaHKaf5wv/H5QzzpXusqGemxURZJ",
    qop=auth,
    response="8ca523f5e9506fed4657c9700eebdbec",
    opaque="FQhe/qaU925kfnzjCev0ciny7QMkPqMAFRtzCUYo5tdS"

if the client chooses SHA-256 to calculate the response, the client responds with a new request including this Authorization header field ๐Ÿ’…:

Authorization: Digest username="Mufasa",
    realm="http-auth@example.org",
    uri="/dir/index.html",
    algorithm=SHA-256,
    nonce="7ypf/xlj9XXwfDPEoM4URrv/xwf94BcCAzFZH4GiTo0v",
    nc=00000001,
    cnonce="f2/wE4q74E6zIJEtWaHKaf5wv/H5QzzpXusqGemxURZJ",
    qop=auth,
    response="753927fa0e85d155564e2e272a28d1802ca10daf449
       6794697cf8db5856cb6c1",
    opaque="FQhe/qaU925kfnzjCev0ciny7QMkPqMAFRtzCUYo5tdS"

3.9.2. Example with SHA-512-256, Charset, and Userhash ๐ŸŒธ

this example assumes an access-protected document is being requested from the server with a GET request ๐Ÿ“ฅ. the URI for the request is http://api.example.org/doe.json. both client and server know the userhash of the username, support the UTF-8 character encoding scheme, and use the SHA-512-256 algorithm ๐ŸŒˆ. the username for the request is a variation of "Jason Doe", where the 'a' is actually Unicode code point U+00E4 ("LATIN SMALL LETTER A WITH DIAERESIS"), and the first 'o' is Unicode code point U+00F8 ("LATIN SMALL LETTER O WITH STROKE"). that leads to this octet sequence in the UTF-8 encoding scheme ๐Ÿ“:

   J  U+00E4 s  U+00F8 n      D  o  e
   4A C3A4   73 C3B8   6E 20 44  6F 65

the password is "Secret, or not?" ๐Ÿคซ.

the first time the client requests the document, no Authorization header field is sent, so the server responds with:

HTTP/1.1 401 Unauthorized
WWW-Authenticate: Digest
    realm="api@example.org",
    qop="auth",
    algorithm=SHA-512-256,
    nonce="5TsQWLVdgBdmrQ0XsxbDODV+57QdFR34I9HAbC/RVvkK",
    opaque="HRPCssKJSGjCrkzDg8OhwpzCiGPChXYjwrI2QmXDnsOS",
    charset=UTF-8,
    userhash=true

the client can prompt the user for the required credentials and send a new request with the following Authorization header field ๐Ÿซง:

Authorization: Digest
    username="488869477bf257147b804c45308cd62ac4e25eb717
       b12b298c79e62dcea254ec",
    realm="api@example.org",
    uri="/doe.json",
    algorithm=SHA-512-256,
    nonce="5TsQWLVdgBdmrQ0XsxbDODV+57QdFR34I9HAbC/RVvkK",
    nc=00000001,
    cnonce="NTg6RKcb9boFIAS3KrFK9BGeh+iDa/sm6jUMp2wds69v",
    qop=auth,
    response="ae66e67d6b427bd3f120414a82e4acff38e8ecd9101d
       6c861229025f607a79dd",
    opaque="HRPCssKJSGjCrkzDg8OhwpzCiGPChXYjwrI2QmXDnsOS",
    userhash=true

if the client can't provide a hashed username for any reason, it can try a request with this Authorization header field ๐Ÿฅบ:

Authorization: Digest
    username*=UTF-8''J%C3%A4s%C3%B8n%20Doe,
    realm="api@example.org",
    uri="/doe.json",
    algorithm=SHA-512-256,
    nonce="5TsQWLVdgBdmrQ0XsxbDODV+57QdFR34I9HAbC/RVvkK",
    nc=00000001,
    cnonce="NTg6RKcb9boFIAS3KrFK9BGeh+iDa/sm6jUMp2wds69v",
    qop=auth,
    response="ae66e67d6b427bd3f120414a82e4acff38e8ecd9101d
       6c861229025f607a79dd",
    opaque="HRPCssKJSGjCrkzDg8OhwpzCiGPChXYjwrI2QmXDnsOS",
    userhash=false

4. Internationalization Considerations ๐ŸŒ

in challenges, servers SHOULD use the "charset" authentication parameter (case-insensitive) to say which character encoding they expect the user agent to use when generating A1 (see Section 3.4.2) and when doing username hashing (see Section 3.4.4) ๐Ÿ—ฃ๏ธ.

the only allowed value is "UTF-8", matched case-insensitively (see Section 2.3 in [RFC2978]). it tells the user agent that the server expects the username and password to be converted to Unicode Normalization Form C ("NFC", see Section 3 of [RFC5198]) and encoded into octets using the UTF-8 character encoding scheme [RFC3629] ๐ŸŒธ.

for the username, recipients MUST support all characters defined in the "UsernameCasePreserved" profile defined in Section 3.3 of [RFC7613], with the exception of the colon (":") character ๐Ÿง‘โ€๐Ÿคโ€๐Ÿง‘.

for the password, recipients MUST support all characters defined in the "OpaqueString" profile defined in Section 4.2 of [RFC7613] ๐Ÿ”’.

if the user agent doesn't support the encoding the server indicated, it can fail the request ๐Ÿ’€.

when usernames can't be sent hashed and include non-ASCII characters, clients can include the username* parameter instead, using the value encoding defined in [RFC5987] ๐ŸŽ€.

5. Security Considerations ๐Ÿ’€

5.1. Limitations โœจ

okay bestie, so Digest Authentication with human-memorable passwords is vulnerable to dictionary attacks ๐Ÿ˜ญ. Those are way easier than cryptographic attacks on any widely used algorithm, even the ones that are no longer considered secure ๐Ÿ’€. So algorithm agility does not make this usage any more secure ๐Ÿ™ˆ.

As a result, Digest Authentication SHOULD be used only with passwords that have a reasonable amount of entropy, e.g., 128-bit or more ๐Ÿ”. Passwords like that typically cannot be memorized by humans, but they're perfect for automated web services ๐Ÿค–.

If Digest Authentication is being used, it SHOULD be over a secure channel like HTTPS [RFC2818] ๐Ÿซถ.


5.2. Storing Passwords ๐Ÿ—๏ธ

Digest Authentication requires the authenticating agent (usually the server) to store some data derived from the user's name and password in a "password file" associated with a given realm ๐Ÿ“. Normally that might contain pairs of username and H(A1), where H(A1) is the digested value of the username, realm, and password as described above.

Here's the tea โ˜•. If this password file gets compromised, an attacker gets immediate access to documents on the server using that realm ๐Ÿ˜ฑ. Unlike, say, a standard UNIX password file, this info doesn't need to be decrypted to access documents in the server realm associated with the file. Decryption, or more likely a brute-force attack, would be needed to get the user's actual password. That's the reason the realm is part of the digested data. If one Digest Authentication password file is compromised, it does not automatically compromise others with the same username and password (though it does expose them to brute-force attack) ๐Ÿ’….

There are two important security consequences of this. First, the password file must be protected as if it contained unencrypted passwords, because for the purpose of accessing documents in its realm, it effectively does ๐Ÿ”’.

Second, the realm string SHOULD be unique among all realms that any single user is likely to use. In particular, a realm string SHOULD include the name of the host doing the authentication ๐Ÿ . The inability of the client to authenticate the server is a weakness of Digest Authentication ๐Ÿฅ€.


5.3. Authentication of Clients Using Digest Authentication ๐Ÿชช

Digest Authentication does not provide a strong authentication mechanism when compared to public-key-based mechanisms, for example ๐Ÿ”‘.

Still, it's significantly stronger than, e.g., CRAM-MD5, which has been proposed for use with Lightweight Directory Access Protocol (LDAP) [RFC4513] and IMAP/POP (see [RFC2195]) ๐Ÿ’ช. It was intended to replace the much weaker and even more dangerous Basic mechanism ๐Ÿ™…โ€โ™€๏ธ.

Digest Authentication offers no confidentiality protection beyond protecting the actual username and password. All of the rest of the request and response is available to an eavesdropper ๐Ÿ‘€.

It also offers only limited integrity protection for the messages in either direction. If the qop=auth-int mechanism is used, those parts of the message used in the calculation of the WWW-Authenticate and Authorization header field response parameter values (see Section 3.2 above) are protected ๐Ÿ›ก๏ธ. Most header fields and their values could still be modified as part of a man-in-the-middle attack ๐Ÿ˜ฌ.

Many needs for secure HTTP transactions cannot be met by Digest Authentication. For those needs, TLS is a more appropriate protocol ๐ŸŽ€. In particular, Digest Authentication cannot be used for any transaction requiring confidentiality protection. Nevertheless, plenty of functions remain for which Digest Authentication is both useful and appropriate ๐ŸŒธ.


5.4. Limited-Use Nonce Values โณ

The Digest scheme uses a server-specified nonce to seed the generation of the response value (as specified in Section 3.4.1 above) ๐ŸŒฑ. As shown in the example nonce in Section 3.3, the server is free to construct the nonce so that it MAY only be used from a particular client, for a particular resource, for a limited period of time or number of uses, or under any other restrictions ๐ŸŽฏ. Doing so strengthens the protection provided against, for example, replay attacks (see Section 5.5) ๐Ÿ’ช.

However, it should be noted that the method chosen for generating and checking the nonce also has performance and resource implications โš–๏ธ. For example, a server MAY choose to allow each nonce value to be used only once, by keeping a record of whether or not each recently issued nonce has been returned and sending a next-nonce parameter in the Authentication-Info header field of every response. This protects against even an immediate replay attack, but it has a high cost due to checking nonce values. Perhaps more important, it will cause authentication failures for any pipelined requests (presumably returning a stale nonce indication) ๐Ÿ˜ฉ.

Similarly, incorporating a request-specific element such as the ETag value for a resource limits the use of the nonce to that version of the resource, and also defeats pipelining ๐Ÿ™ƒ. Thus, it MAY be useful to do so for methods with side effects, but have unacceptable performance for those that do not ๐Ÿ“.


5.5. Replay Attacks ๐ŸŽฌ

A replay attack against Digest Authentication would usually be pointless for a simple GET request, since an eavesdropper would already have seen the only document he could obtain with a replay ๐Ÿ™„. That's because the URI of the requested document is digested in the client request, and the server will only deliver that document. By contrast, under Basic Authentication, once the eavesdropper has the user's password, any document protected by that password is open to him ๐Ÿšจ.

So for some purposes, it's necessary to protect against replay attacks ๐Ÿง. A good Digest implementation can do this in various ways. The server-created "nonce" value is implementation dependent, but if it contains a digest of the client IP, a timestamp, the resource ETag, and a private server key (as recommended above), then a replay attack is not simple ๐Ÿ”. An attacker must convince the server that the request is coming from a false IP address, and must cause the server to deliver the document to an IP address different from the address to which it believes it is sending the document. An attack can only succeed in the period before the timestamp expires โฐ. Digesting the client IP and timestamp in the nonce permits an implementation that does not maintain state between transactions ๐Ÿง .

For applications where no possibility of replay attack can be tolerated, the server can use one-time nonce values that will not be honored for a second use ๐Ÿšซ. This requires the overhead of the server remembering which nonce values have been used until the nonce timestamp (and hence the digest built with it) has expired, but it effectively protects against replay attacks ๐Ÿ›ก๏ธ.

An implementation must give special attention to the possibility of replay attacks with POST and PUT requests ๐Ÿ“ฎ. Unless the server employs one-time or otherwise limited-use nonces and/or insists on the use of the integrity protection of "qop=auth-int", an attacker could replay valid credentials from a successful request with counterfeit data or other message body ๐Ÿ˜ฑ. Even with the use of integrity protection, most metadata in header fields is not protected. Proper nonce generation and checking provides some protection against replay of previously used valid credentials, but see Section 5.8 ๐Ÿฅน.


5.6. Weakness Created by Multiple Authentication Schemes ๐Ÿงฉ

An HTTP/1.1 server MAY return multiple challenges with a 401 (Authenticate) response, and each challenge MAY use a different auth-scheme ๐ŸŽญ. A user agent MUST choose to use the strongest auth-scheme it understands, and request credentials from the user based upon that challenge ๐Ÿ’–.

When the server offers choices of authentication schemes using the WWW-Authenticate header field, the strength of the resulting authentication is only as good as that of the weakest of the authentication schemes ๐Ÿ“‰. See Section 5.7 below for discussion of particular attack scenarios that exploit multiple authentication schemes ๐Ÿ•ต๏ธ.


5.7. Online Dictionary Attacks ๐Ÿ“–

If the attacker can eavesdrop, then it can test any overheard nonce/response pairs against a list of common words ๐Ÿ‘‚. Such a list is usually much smaller than the total number of possible passwords, and the cost of computing the response for each password on the list is paid once for each challenge ๐Ÿงพ.

The server can mitigate this attack by not allowing users to select passwords that are in a dictionary ๐Ÿ™….


5.8. Man-in-the-Middle Attacks ๐Ÿ•ณ๏ธ

Digest Authentication is vulnerable to man-in-the-middle (MITM) attacks, for example from a hostile or compromised proxy ๐Ÿ‘ป. Clearly, this would present all the problems of eavesdropping, but it also offers some additional opportunities to the attacker ๐Ÿ˜ค.

A possible MITM attack would be to add a weak authentication scheme to the set of choices, hoping that the client will use one that exposes the user's credentials (e.g., password) ๐Ÿชค. For this reason, the client SHOULD always use the strongest scheme that it understands from the choices offered ๐Ÿ’ช.

An even better MITM attack would be to remove all offered choices, replacing them with a challenge that requests only Basic authentication, then use the cleartext credentials from the Basic authentication to authenticate to the origin server using the stronger scheme it requested ๐Ÿ’€. A particularly insidious way to mount such an attack would be to offer a "free" proxy caching service to gullible users ๐Ÿ™ˆ.

User agents should consider measures such as presenting a visual indication, at the time of the credentials request, of what authentication scheme is to be used, or remembering the strongest authentication scheme ever requested by a server and producing a warning message before using a weaker one ๐Ÿšฆ. It might also be a good idea for the user agent to be configured to demand Digest authentication in general, or from specific sites ๐ŸŒˆ.

Or, a hostile proxy might spoof the client into making a request the attacker wanted rather than one the client wanted. Of course, this is still much harder than a comparable attack against Basic Authentication ๐Ÿฅด.


5.9. Chosen Plaintext Attacks ๐Ÿ”ฌ

With Digest Authentication, a MITM or a malicious server can arbitrarily choose the nonce that the client will use to compute the response ๐Ÿ˜ˆ. This is called a "chosen plaintext" attack, and the ability to choose the nonce is known to make cryptanalysis much easier ๐Ÿงช.

However, a method to analyze the one-way functions used by Digest using chosen plaintext is not currently known ๐Ÿคž.

The countermeasure against this attack is for clients to use the cnonce parameter. This allows the client to vary the input to the hash in a way not chosen by the attacker ๐Ÿ›ก๏ธโœจ.

5.10. Precomputed Dictionary Attacks

Okay bestie, this one is giving precomputation ๐Ÿงš With Digest Authentication, if the attacker can run a chosen plaintext attack, they can precompute the response for lots of common words against a nonce they picked, and store a dictionary of response/password pairs ๐Ÿ“–. That precomputation can often happen in parallel across tons of machines ๐Ÿ’ป. Then they run the chosen plaintext attack to get the response for that challenge and just look the password up in their dictionary ๐Ÿ‘€. Even if most passwords aren't in the dictionary, some might be ๐Ÿ’€. Since the attacker gets to pick the challenge, the cost of computing each password's response can be spread out across finding many passwords ๐Ÿ’…. A dictionary with 100 million password/response pairs would take about 3.2 gigabytes of disk storage ๐Ÿ’พ.

The countermeasure is for clients to use the cnonce parameter ๐Ÿ›ก๏ธ

5.11. Batch Brute-Force Attacks

Ngl this one is a whole vibe ๐Ÿ˜ญ With Digest Authentication, a MITM can run a chosen plaintext attack and gather responses from many users to the same nonce ๐Ÿ•ต๏ธโ€โ™€๏ธ. Then it can find all the passwords within any subset of password space that would generate one of the nonce/response pairs in a single pass over that space ๐Ÿ”. It also cuts the time to find the first password by a factor equal to the number of nonce/response pairs gathered ๐Ÿ“‰. This search of the password space can often be done in parallel on many machines, and even a single machine can search large subsets of the password space very quickly. Reports exist of searching all passwords with six or fewer letters in a few hours โฐ. Iconic, but terrifying ๐Ÿ™ˆ

The countermeasure is for clients to use the cnonce parameter ๐Ÿ›ก๏ธ

5.12. Parameter Randomness

Main character energy for randomness ๐ŸŽฒ The security of this protocol is critically dependent on the randomness of the randomly chosen parameters, like client and server nonces ๐Ÿ”. These should be generated by a strong random or properly seeded pseudorandom source (see [RFC4086]). No shortcuts, bestie ๐Ÿ’–

5.13. Summary

Real talk: by modern cryptographic standards, Digest Authentication is weak ๐Ÿฅ€ But for a large range of purposes, it's valuable as a replacement for Basic Authentication ๐ŸŒธ. It fixes some of Basic Authentication's weaknesses, but not all of them โœจ. Its strength may vary depending on the implementation ๐Ÿงฉ. In particular, the structure of the nonce (which depends on the server implementation) may affect how easy it is to mount a replay attack ๐Ÿ”. A range of server options is appropriate, because for example, some implementations may be willing to take on the server overhead of one-time nonces or digests to kill the possibility of replay ๐Ÿ’…. Others may be satisfied with a nonce like the one recommended above, i.e., restricted to a single IP address and a single ETag, or with a limited lifetime ๐Ÿฆ‹.

The bottom line is that any compliant implementation will be relatively weak by cryptographic standards, but any compliant implementation will be far superior to Basic Authentication ๐Ÿ‘‘


6. IANA Considerations โœจ

6.1. Hash Algorithms for HTTP Digest Authentication

This spec creates a new IANA registry called "Hash Algorithms for HTTP Digest Authentication" under the existing "Hypertext Transfer Protocol (HTTP) Digest Algorithm Values" category ๐Ÿ—‚๏ธ This registry lists the hash algorithms that can be used in HTTP Digest Authentication.

When registering a new hash algorithm, the following information MUST be provided:

  • Hash Algorithm: the textual name of the hash algorithm.
  • Digest Size: the size of the algorithm's output in bits.
  • Reference: a reference to the specification adding the algorithm to this registry.

The update policy for this registry shall be Specification Required [RFC5226] ๐Ÿ“

The initial registry contains the following entries:

+----------------+-------------+-----------+
| Hash Algorithm | Digest Size | Reference |
+----------------+-------------+-----------+
| "MD5"          | 128         | RFC 7616  |
| "SHA-512-256"  | 256         | RFC 7616  |
| "SHA-256"      | 256         | RFC 7616  |
+----------------+-------------+-----------+

Each one of the algorithms in the registry might have a "-sess" variant, e.g., MD5-sess, SHA-256-sess, etc. ๐Ÿง

To clarify the purpose of the existing "HTTP Digest Algorithm Values" registry and avoid confusion between the two registries, IANA has added the following description to that existing registry ๐Ÿ’œ

This registry lists the algorithms that can be used when creating digests of an HTTP message body, as specified in RFC 3230.

6.2. Digest Scheme Registration

This spec updates the existing entry of the Digest scheme in the "Hypertext Transfer Protocol (HTTP) Authentication Scheme Registry" and adds a new reference to this spec ๐ŸŽ€

Authentication Scheme Name: Digest

Pointer to specification text: RFC 7616

7. References ๐Ÿ“š

7.1. Normative References

7.2. Informative References

Appendix A. Changes from RFC 2617 ๐ŸŒˆ

This document introduces the following changes:

  • Adds support for two new algorithms, SHA2-256 as mandatory and SHA2-512/256 as a backup, and defines the proper algorithm negotiation. The document keeps the MD5 algorithm support but only for backward compatibility. ๐Ÿ”ฅ
  • Introduces the username hashing capability and the parameter associated with that, mainly for privacy reasons. ๐Ÿ™ˆ
  • Adds various internationalization considerations that impact the A1 calculation and username and password encoding. ๐ŸŒธ
  • Introduces a new IANA registry, "Hash Algorithms for HTTP Digest Authentication", that lists the hash algorithms that can be used in HTTP Digest Authentication. ๐Ÿฆ‹
  • Deprecates backward compatibility with RFC 2069. ๐Ÿ’…

Acknowledgments ๐Ÿ™โœจ

Okay bestie, this doc borrows text heavily from [RFC2617] ๐Ÿ’… To give a complete description of the Digest mechanism and how it works, the authors leaned on that spec a LOT. Huge thanks to John Franks, Phillip M. Hallam-Baker, Jeffery L. Hostetler, Scott D. Lawrence, Paul J. Leach, Ari Luotonen, and Lawrence C. Stewart for their work on it ๐Ÿซถ

Special shoutout to Julian Reschke for his many reviews, comments, suggestions, and text across various areas of this doc ๐Ÿ‘‘

The authors also want to thank Stephen Farrell, Yoav Nir, Phillip Hallam-Baker, Manu Sporny, Paul Hoffman, Yaron Sheffer, Sean Turner, Geoff Baskwill, Eric Cooper, Bjoern Hoehrmann, Martin Durst, Peter Saint-Andre, Michael Sweet, Daniel Stenberg, Brett Tate, Paul Leach, Ilari Liusvaara, Gary Mort, Alexey Melnikov, Benjamin Kaduk, Kathleen Moriarty, Francis Dupont, Hilarie Orman, and Ben Campbell for their careful review and comments ๐ŸŒธ

Thanks also to Jonathan Stoke, Nico Williams, Harry Halpin, and Phil Hunt for their mailing list comments while everyone was discussing different parts of this doc ๐Ÿ’ฌ

Paul Kyzivat and Dale Worley get a big thank you for their careful review and feedback on some aspects of the doc ๐ŸŽ€

And Barry Leiba gets a thank you for his help with the registry ๐Ÿฆ‹


Authors' Addresses ๐Ÿ“ฎ

These are the people who wrote it, so here's where to find them ๐Ÿงš

Rifaat Shekh-Yusef (editor) ๐Ÿ‘‘

Rifaat Shekh-Yusef (editor)
Avaya
250 Sidney Street
Belleville, Ontario
Canada

Phone: +1-613-967-5267
Email: rifaat.ietf@gmail.com

David Ahrens ๐ŸŒˆ

David Ahrens
Independent
California
United States

Email: ahrensdc@gmail.com

Sophie Bremer ๐Ÿ’œ

Sophie Bremer
Netzkonform
Germany

Email: sophie.bremer@netzkonform.de

That's the whole RFC, periodt! ๐ŸŽ‰๐Ÿ’–

๐Ÿ“ฆ where this page comes from