/[suikacvs]/webroot/www/2004/id/draft-ietf-http-authentication-02.txt
Suika

Contents of /webroot/www/2004/id/draft-ietf-http-authentication-02.txt

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1.1 - (hide annotations) (download)
Tue Jun 15 08:04:04 2004 UTC (20 years, 10 months ago) by wakaba
Branch: MAIN
CVS Tags: HEAD
File MIME type: text/plain
New

1 wakaba 1.1
2    
3     HTTP Working Group J. Franks, Northwestern University
4     INTERNET DRAFT P. Hallam-Baker, Verisign, Inc.
5     <draft-ietf-http-authentication-02> J. Hostetler, Spyglass, Inc.
6     S. Lawrence, Agranat, Inc.
7     P. Leach, Microsoft Corporation
8     A. Luotonen, Netscape Communications Corporation
9     L. Stewart, Open Market, Inc.
10     Expires: February 7, 1999 August 7, 1998
11    
12    
13    
14     HTTP Authentication: Basic and Digest Access Authentication
15    
16    
17    
18     Status of this Memo
19    
20     This document is an Internet-Draft. Internet-Drafts are working
21     documents of the Internet Engineering Task Force (IETF), its areas, and
22     its working groups. Note that other groups may also distribute working
23     documents as Internet-Drafts.
24    
25     Internet-Drafts are draft documents valid for a maximum of six months
26     and may be updated, replaced, or made obsolete by other documents at any
27     time. It is inappropriate to use Internet-Drafts as reference material
28     or to cite them other than as "work in progress".
29    
30     To learn the current status of any Internet-Draft, please check the
31     "1id-abstracts.txt" listing contained in the Internet-Drafts Shadow
32     Directories on ftp.is.co.za (Africa), nic.nordu.net (Europe),
33     munnari.oz.au (Pacific Rim), or ftp.isi.edu (US West Coast).
34    
35     Distribution of this document is unlimited. Please send comments to the
36     HTTP working group at <http-wg@hplb.hpl.hp.com>. Discussions of the
37     working group are archived at
38     <URL:http://www.ics.uci.edu/pub/ietf/http/>.
39    
40     Copyright NoticeCopyright (C) The Internet Society (1998). All Rights
41     Reserved. See section 9 for the full copyright notice.
42    
43    
44    
45     Abstract
46    
47     "HTTP/1.0" includes the specification for a Basic Access Authentication
48     scheme. This scheme is not considered to be a secure method of user
49     authentication (unless used in conjunction with some external secure
50     system such as SSL [5]), as the user name and password are passed over
51     the network as cleartext.
52    
53     This document also provides the specification for HTTP's authentication
54     framework, the original Basic authentication scheme and a scheme based
55     on cryptographic hashes, referred to as "Digest Access Authentication".
56     It is therefore also intended to serve as a replacement for RFC 2069
57     [6]. Some optional elements specified by RFC 2069 have been removed
58     from this specification due to problems found since its publication;
59     other new elements have been added -for compatibility, those new
60     elements have been made optional, but are strongly recommended.
61    
62     Like Basic, Digest access authentication verifies that both parties to a
63     communication know a shared secret (a password); unlike Basic, this
64     verification can be done without sending the password in the clear,
65     which is Basic's biggest weakness. As with most other authentication
66     protocols, the greatest sources of risks are usually found not in the
67     core protocol itself but in policies and procedures surrounding its use.
68    
69    
70    
71     INTERNET-DRAFT HTTP AuthenticationFriday 7 August 1998
72    
73     Table of Contents
74    
75    
76     HTTP AUTHENTICATION: BASIC AND DIGEST ACCESS AUTHENTICATION1
77    
78     Status of this Memo........................................1
79    
80     Abstract...................................................1
81    
82     Table of Contents..........................................3
83    
84     1 Access Authentication.................................5
85     1.1 Reliance on the HTTP/1.1 Specification..............5
86     1.2 Access Authentication Framework.....................5
87    
88     2 Basic Authentication Scheme...........................6
89    
90     3 Digest Access Authentication Scheme...................7
91     3.1 Introduction........................................7
92     3.1.1 Purpose..........................................7
93     3.1.2 Overall Operation................................8
94     3.1.3 Representation of digest values..................8
95     3.1.4 Limitations......................................8
96     3.2 Specification of Digest Headers.....................8
97     3.2.1 The WWW-Authenticate Response Header.............8
98     3.2.2 The Authorization Request Header................11
99     3.2.3 The Authentication-Info Header..................15
100     3.3 Digest Operation...................................16
101     3.4 Security Protocol Negotiation......................16
102     3.5 Example............................................17
103     3.6 Proxy-Authentication and Proxy-Authorization.......17
104    
105     4 Security Considerations..............................18
106     4.1 Authentication of Clients using Basic Authentication18
107     4.2 Authentication of Clients using Digest Authentication18
108     4.3 Limited Use Nonce Values...........................19
109     4.4 Comparison of Digest with Basic Authentication.....19
110     4.5 Replay Attacks.....................................20
111     4.6 Weakness Created by Multiple Authentication Schemes20
112     4.7 Online dictionary attacks..........................21
113     4.8 Man in the Middle..................................21
114     4.9 Chosen plaintext attacks...........................22
115     4.10 Precomputed dictionary attacks.....................22
116     4.11 Batch brute force attacks..........................22
117     4.12 Spoofing by Counterfeit Servers....................22
118     4.13 Storing passwords..................................23
119     4.14 Summary............................................23
120    
121     5 Sample implementation................................23
122    
123     6 Acknowledgments......................................27
124    
125     7 References...........................................27
126    
127     8 Authors' Addresses...................................28
128    
129    
130     Franks, et al. [Page 3]
131    
132    
133    
134     INTERNET-DRAFT HTTP AuthenticationFriday 7 August 1998
135    
136    
137     1 Access Authentication
138    
139    
140     1.1 Reliance on the HTTP/1.1 Specification
141    
142     This specification is a companion to the HTTP/1.1 specification [2]. It
143     uses the augmented BNF section 2.1 of that document, and relies on both
144     the non-terminals defined in that document and other aspects of the
145     HTTP/1.1 specification.
146    
147    
148     1.2 Access Authentication Framework
149    
150     HTTP provides a simple challenge-response authentication mechanism that
151     MAY be used by a server to challenge a client request and by a client to
152     provide authentication information. It uses an extensible, case-
153     insensitive token to identify the authentication scheme, followed by a
154     comma-separated list of attribute-value pairs which carry the parameters
155     necessary for achieving authentication via that scheme.
156    
157     auth-scheme = token
158     auth-param = token "=" ( token | quoted-string )
159    
160    
161     The 401 (Unauthorized) response message is used by an origin server to
162     challenge the authorization of a user agent. This response MUST include
163     a WWW-Authenticate header field containing at least one challenge
164     applicable to the requested resource. The 407 (Proxy Authentication
165     Required) response message is used by a proxy to challenge the
166     authorization of a client and MUST include a Proxy-Authenticate header
167     field containing at least one challenge applicable to the proxy for the
168     requested resource.
169    
170     challenge = auth-scheme 1*SP 1#auth-param
171    
172     Note: User agents will need to take special care in parsing the WWW-
173     Authenticate or Proxy-Authenticate header field value if it contains
174     more than one challenge, or if more than one WWW-Authenticate header
175     field is provided, since the contents of a challenge may itself contain
176     a comma-separated list of authentication parameters.
177    
178     The authentication parameter realm is defined for all authentication
179     schemes:
180    
181     realm = "realm" "=" realm-value
182     realm-value = quoted-string
183    
184    
185     The realm directive (case-insensitive) is required for all
186     authentication schemes that issue a challenge. The realm value (case-
187     sensitive), in combination with the canonical root URL (the absoluteURI
188     for the server whose abs_path is empty; see section 5.1.2 of [2]) of the
189     server being accessed, defines the protection space. These realms allow
190     the protected resources on a server to be partitioned into a set of
191     protection spaces, each with its own authentication scheme and/or
192     authorization database. The realm value is a string, generally assigned
193     by the origin server, which may have additional semantics specific to
194     the authentication scheme. Note that there may be multiple challenges
195     with the same auth-scheme but different realms.
196    
197    
198    
199     Franks, et al. [Page 5]
200    
201    
202    
203     INTERNET-DRAFT HTTP AuthenticationFriday 7 August 1998
204    
205     A user agent that wishes to authenticate itself with an origin server--
206     usually, but not necessarily, after receiving a 401 (Unauthorized)--MAY
207     do so by including an Authorization header field with the request. A
208     client that wishes to authenticate itself with a proxy--usually, but not
209     necessarily, after receiving a 407 (Proxy Authentication Required)--MAY
210     do so by including a Proxy-Authorization header field with the request.
211     Both the Authorization field value and the Proxy-Authorization field
212     value consist of credentials containing the authentication information
213     of the client for the realm of the resource being requested. The user
214     agent MUST choose to use one of the challenges with the strongest auth-
215     scheme it understands and request credentials from the user based upon
216     that challenge.
217    
218     credentials = auth-scheme #auth-param
219    
220     Note that many browsers will only recognize Basic and will require
221     that it be the first auth-scheme presented. Servers should only
222     include Basic if it is minimally acceptable.
223    
224     The protection space determines the domain over which credentials can be
225     automatically applied. If a prior request has been authorized, the same
226     credentials MAY be reused for all other requests within that protection
227     space for a period of time determined by the authentication scheme,
228     parameters, and/or user preference. Unless otherwise defined by the
229     authentication scheme, a single protection space cannot extend outside
230     the scope of its server.
231    
232     If the origin server does not wish to accept the credentials sent with a
233     request, it SHOULD return a 401 (Unauthorized) response. The response
234     MUST include a WWW-Authenticate header field containing at least one
235     (possibly new) challenge applicable to the requested resource. If a
236     proxy does not accept the credentials sent with a request, it SHOULD
237     return a 407 (Proxy Authentication Required). The response MUST include
238     a Proxy-Authenticate header field containing a (possibly new) challenge
239     applicable to the proxy for the requested resource.
240    
241     The HTTP protocol does not restrict applications to this simple
242     challenge-response mechanism for access authentication. Additional
243     mechanisms MAY be used, such as encryption at the transport level or via
244     message encapsulation, and with additional header fields specifying
245     authentication information. However, these additional mechanisms are not
246     defined by this specification.
247    
248     Proxies MUST be completely transparent regarding user agent
249     authentication by origin servers. That is, they must forward the WWW-
250     Authenticate and Authorization headers untouched, and follow the rules
251     found in section 14.8 of [2]. Both the Proxy-Authenticate and the Proxy-
252     Authorization header fields are hop-by-hop headers (see section 13.5.1
253     of [2]).
254    
255    
256     2 Basic Authentication Scheme
257    
258     The "basic" authentication scheme is based on the model that the client
259     must authenticate itself with a user-ID and a password for each realm.
260     The realm value should be considered an opaque string which can only be
261     compared for equality with other realms on that server. The server will
262     service the request only if it can validate the user-ID and password for
263     the protection space of the Request-URI. There are no optional
264     authentication parameters.
265    
266     Franks, et al. [Page 6]
267    
268    
269    
270     INTERNET-DRAFT HTTP AuthenticationFriday 7 August 1998
271    
272     For Basic, the framework above is utilized as follows:
273    
274     challenge = "Basic" realm
275     credentials = "Basic" basic-credentials
276    
277    
278     Upon receipt of an unauthorized request for a URI within the protection
279     space, the origin server MAY respond with a challenge like the
280     following:
281    
282     WWW-Authenticate: Basic realm="WallyWorld"
283    
284     where "WallyWorld" is the string assigned by the server to identify the
285     protection space of the Request-URI. A proxy may respond with the same
286     challenge using the Proxy-Authenticate header field.
287    
288     To receive authorization, the client sends the userid and password,
289     separated by a single colon (":") character, within a base64 [7 ] encoded
290     string in the credentials.
291    
292     basic-credentials = base64-user-pass
293     base64-user-pass = <base64 [4] encoding of user-pass,
294     except not limited to 76 char/line>
295     user-pass = userid ":" password
296     userid = *<TEXT excluding ":">
297     password = *TEXT
298    
299     Userids might be case sensitive.
300    
301     If the user agent wishes to send the userid "Aladdin" and password "open
302     sesame", it would use the following header field:
303    
304     Authorization: Basic QWxhZGRpbjpvcGVuIHNlc2FtZQ==
305    
306    
307     A client SHOULD assume that all paths at or deeper than the depth of the
308     last symbolic element in the path field of the Request-URI also are
309     within the protection space specified by the Basic realm value of the
310     current challenge. A client MAY send the corresponding Authorization
311     header with requests for resources in that space without receipt of
312     another challenge from the server.
313    
314     If a client wishes to send the same userid and password to a proxy, it
315     would use the Proxy-Authorization header field. See section 4 for
316     security considerations associated with Basic authentication.
317    
318    
319     3 Digest Access Authentication Scheme
320    
321    
322     3.1 Introduction
323    
324    
325     3.1.1 Purpose
326    
327     The protocol referred to as "HTTP/1.0" includes the specification for a
328     Basic Access Authentication scheme[1]. This scheme is not considered to
329     be a secure method of user authentication, as the user name and password
330     are passed over the network in an unencrypted form. This document
331     provides the specification for such a scheme, which does not send the
332     password in cleartext. It is referred to as "Digest Access
333     Authentication".
334    
335    
336     Franks, et al. [Page 7]
337    
338    
339    
340     INTERNET-DRAFT HTTP AuthenticationFriday 7 August 1998
341    
342     The Digest Access Authentication scheme is not intended to be a complete
343     answer to the need for security in the World Wide Web. This scheme
344     provides no encryption of message content. The intent is simply to
345     create an access authentication method which avoids the most serious
346     flaws of Basic authentication.
347    
348    
349     3.1.2 Overall Operation
350    
351     Like Basic Access Authentication, the Digest scheme is based on a simple
352     challenge-response paradigm. The Digest scheme challenges using a nonce
353     value. A valid response contains a checksum (by default the MD5
354     checksum) of the username, the password, the given nonce value, the HTTP
355     method, and the requested URI. In this way, the password is never sent
356     in the clear. Just as with the Basic scheme, the username and password
357     must be prearranged in some fashion not addressed by this document.
358    
359    
360     3.1.3 Representation of digest values
361    
362     An optional header allows the server to specify the algorithm used to
363     create the checksum or digest. By default the MD5 algorithm is used and
364     that is the only algorithm described in this document.
365    
366     For the purposes of this document, an MD5 digest of 128 bits is
367     represented as 32 ASCII printable characters. The bits in the 128 bit
368     digest are converted from most significant to least significant bit,
369     four bits at a time to their ASCII presentation as follows. Each four
370     bits is represented by its familiar hexadecimal notation from the
371     characters 0123456789abcdef. That is, binary 0000 gets represented by
372     the character '0', 0001, by '1', and so on up to the representation of
373     1111 as 'f'.
374    
375    
376     3.1.4 Limitations
377    
378     The Digest authentication scheme described in this document suffers from
379     many known limitations. It is intended as a replacement for Basic
380     authentication and nothing more. It is a password-based system and (on
381     the server side) suffers from all the same problems of any password
382     system. In particular, no provision is made in this protocol for the
383     initial secure arrangement between user and server to establish the
384     user's password.
385    
386     Users and implementors should be aware that this protocol is not as
387     secure as Kerberos, and not as secure as any client-side private-key
388     scheme. Nevertheless it is better than nothing, better than what is
389     commonly used with telnet and ftp, and better than Basic authentication.
390    
391    
392     3.2 Specification of Digest Headers
393    
394     The Digest Access Authentication scheme is conceptually similar to the
395     Basic scheme. The formats of the modified WWW-Authenticate header line
396     and the Authorization header line are specified below. In addition, a
397     new header, Authentication-Info, is specified.
398    
399    
400     3.2.1 The WWW-Authenticate Response Header
401    
402     If a server receives a request for an access-protected object, and an
403     acceptable Authorization header is not sent, the server responds with a
404     "401 Unauthorized" status code, and a WWW-Authenticate header as per the
405    
406     Franks, et al. [Page 8]
407    
408    
409    
410     INTERNET-DRAFT HTTP AuthenticationFriday 7 August 1998
411    
412     framework defined above, which for the digest scheme is utilized as
413     follows:
414    
415     challenge = "Digest" digest-challenge
416    
417     digest-challenge = 1#( realm | [ domain ] | nonce |
418     [ opaque ] |[ stale ] | [ algorithm ] |
419     [ qop-options ] | [auth-param] )
420    
421    
422     domain = "domain" "=" <"> URI ( 1*SP URI ) <">
423     URI = absoluteURI | abs_path
424     nonce = "nonce" "=" nonce-value
425     nonce-value = quoted-string
426     opaque = "opaque" "=" quoted-string
427     stale = "stale" "=" ( "true" | "false" )
428     algorithm = "algorithm" "=" ( "MD5" | "MD5-sess" |
429     token )
430     qop-options = "qop" "=" <"> 1#qop-value <">
431     qop-value = "auth" | "auth-int" | token
432    
433    
434     The meanings of the values of the parameters used above are as follows:
435    
436     realm
437     A string to be displayed to users so they know which username and
438     password to use. This string should contain at least the name of the
439     host performing the authentication and might additionally indicate
440     the collection of users who might have access. An example might be
441     "registered_users@gotham.news.com".
442    
443     domain
444     A space-separated list of URIs, as specified in RFC XURI [7], that
445     define the protection space. If a URI is an abs_path, it is relative
446     to canonical root URL (see section 1.2 above) of the server being
447     accessed. An absoluteURI in this list may refer to a different server
448     than the one being accessed. The client can use this list to
449     determine the set of URIs for which the same authentication
450     information may be sent: any URI that has a URI in this list as a
451     prefix (after both have been made absolute) may be assumed to be in
452     the same protection space. If this directive is omitted or its value
453     is empty, the client should assume that the protection space consists
454     of all URIs on the responding server. This directive is not
455     meaningful in Proxy-Authenticate headers, for which the protection
456     space is always the entire proxy; if present it should be ignored.
457    
458     nonce
459     A server-specified data string which may be uniquely generated each
460     time a 401 response is made. It is recommended that this string be
461     base64 or hexadecimal data. Specifically, since the string is passed
462     in the header lines as a quoted string, the double-quote character is
463     not allowed.
464    
465     The contents of the nonce are implementation dependent. The quality
466     of the implementation depends on a good choice. A nonce might, for
467     example, be constructed as the base 64 encoding of
468    
469     time-stamp H(time-stamp ":" ETag ":" private-key)
470    
471     Franks, et al. [Page 9]
472    
473    
474    
475     INTERNET-DRAFT HTTP AuthenticationFriday 7 August 1998
476    
477     where time-stamp is a server-generated time or other non-repeating
478     value, ETag is the value of the HTTP ETag header associated with the
479     requested entity, and private-key is data known only to the server.
480     With a nonce of this form a server would recalculate the hash portion
481     after receiving the client authentication header and reject the
482     request if it did not match the nonce from that header or if the
483     time-stamp value is not recent enough. In this way the server can
484     limit the time of the nonce's validity. The inclusion of the ETag
485     prevents a replay request for an updated version of the resource.
486     (Note: including the IP address of the client in the nonce would
487     appear to offer the server the ability to limit the reuse of the
488     nonce to the same client that originally got it. However, that would
489     break proxy farms, where requests from a single user often go through
490     different proxies in the farm. Also, IP address spoofing is not that
491     hard.)
492    
493     An implementation might choose not to accept a previously used nonce
494     or a previously used digest to protect against a replay attack. Or,
495     an implementation might choose to use one-time nonces or digests for
496     POST or PUT requests and a time-stamp for GET requests. For more
497     details on the issues involved see section 4. of this document.
498    
499     The nonce is opaque to the client.
500    
501     opaque
502     A string of data, specified by the server, which should be returned
503     by the client unchanged. It is recommended that this string be base64
504     or hexadecimal data.
505    
506     stale
507     A flag, indicating that the previous request from the client was
508     rejected because the nonce value was stale. If stale is TRUE (case-
509     insensitive), the client may wish to simply retry the request with a
510     new encrypted response, without reprompting the user for a new
511     username and password. The server should only set stale to true if it
512     receives a request for which the nonce is invalid but with a valid
513     digest for that nonce (indicating that the client knows the correct
514     username/password).
515    
516     algorithm
517     A string indicating a pair of algorithms used to produce the digest
518     and a checksum. If this is not present it is assumed to be "MD5". If
519     the algorithm is not understood, the challenge should be ignored (and
520     a different one used, if there is more than one). In this document
521     the string obtained by applying the digest algorithm to the data
522     "data" with secret "secret" will be denoted by KD(secret, data), and
523     the string obtained by applying the checksum algorithm to the data
524     "data" will be denoted H(data). The notation unq(X) means the value
525     of the quoted-string X without the surrounding quotes.
526    
527    
528     For the "MD5" and "MD5-sess" algorithms
529    
530     H(data) = MD5(data)
531    
532     and
533    
534     KD(secret, data) = H(concat(secret, ":", data))
535    
536     i.e., the digest is the MD5 of the secret concatenated with a
537     colon concatenated with the data. The "MD5-sess" algorithm is
538    
539     Franks, et al. [Page 10]
540    
541    
542    
543     INTERNET-DRAFT HTTP AuthenticationFriday 7 August 1998
544    
545     intended to allow efficient 3rd party authentication servers;
546     for the difference in usage, see the description .
547    
548     qop-options
549     This directive is optional, but is made so only for backward
550     compatibility with RFC 2069 [6]; it SHOULD be used by all
551     implementations compliant with this version of the Digest scheme.
552     If present, it is a quoted string of one or more tokens indicating
553     the "quality of protection" values supported by the server. The
554     value "auth" indicates authentication; the value "auth-int" indicates
555     authentication with integrity protection; see the descriptions below
556     for calculating the response directive value for the application of
557     this choice. Unrecognized options MUST be ignored.
558    
559     auth-param
560     This directive allows for future extensions. Any unrecognized
561     directive MUST be ignored.
562    
563    
564     3.2.2 The Authorization Request Header
565    
566     The client is expected to retry the request, passing an
567     Authorization header line, which is defined according to the
568     framework above, utilized as follows.
569    
570     credentials = "Digest" digest-response
571    
572     digest-response = 1#( username | realm | nonce |
573     digest-uri | response | [ algorithm ] |
574     [cnonce] | [opaque] | [message-qop] |
575     [nonce-count] | [auth-param] )
576    
577     username = "username" "=" username-value
578     username-value = quoted-string
579     digest-uri = "uri" "=" digest-uri-value
580     digest-uri-value = request-uri ; As specified by HTTP/1.1
581     message-qop = "qop" "=" qop-value
582     cnonce = "cnonce" "=" cnonce-value
583     cnonce-value = nonce-value
584     nonce-count = "nc" "=" nc-value
585     nc-value = 8LHEX
586     response = "response" "=" request-digest
587     request-digest = <"> 32LHEX <">
588     LHEX = "0" | "1" | "2" | "3" |
589     "4" | "5" | "6" | "7" |
590     "8" | "9" | "a" | "b" |
591     "c" | "d" | "e" | "f"
592    
593    
594     The values of the opaque and algorithm fields must be those
595     supplied in the WWW-Authenticate response header for the entity
596     being requested.
597    
598     response
599     A string of 32 hex digits computed as defined below, which proves
600     that the user knows a password
601    
602     username
603     The user's name in the specified realm.
604    
605    
606     Franks, et al. [Page 11]
607    
608    
609    
610     INTERNET-DRAFT HTTP AuthenticationFriday 7 August 1998
611    
612     digest-uri
613     The URI from Request-URI of the Request-Line; duplicated here because
614     proxies are allowed to change the Request-Line in transit.
615    
616     qop
617     Indicates what "quality of protection" the client has applied to the
618     message. If present, its value MUST be one of the alternatives the
619     server indicated it supports in the WWW-Authenticate header. These
620     values affect the computation of the request-digest. Note that this
621     is a single token, not a quoted list of alternatives as in WWW-
622     Authenticate. This directive is optional in order to preserve
623     backward compatibility with a minimal implementation of RFC 2069 [6],
624     but SHOULD be used if the server indicated that qop is supported by
625     providing a qop directive in the WWW-Authenticate header field.
626    
627     cnonce
628     This MUST be specified if a qop directive is sent (see above), and
629     MUST NOT be specified if the server did not send a qop directive in
630     the WWW-Authenticate header field. The cnonce-value is an opaque
631     quoted string value provided by the client and used by both client
632     and server to avoid chosen plaintext attacks, to provide mutual
633     authentication, and to provide some message integrity protection.
634     See the descriptions below of the calculation of the response-digest
635     and request-digest values.
636    
637     nonce-count
638     This MUST be specified if a qop directive is sent (see above), and
639     MUST NOT be specified if the server did not send a qop directive in
640     the WWW-Authenticate header field. The nc-value is the hexadecimal
641     count of the number of requests (including the current request) that
642     the client has sent with the nonce value in this request. For
643     example, in the first request sent in response to a given nonce
644     value, the client sends "nc=00000001". The purpose of this directive
645     is to allow the server to detect request replays by maintaining its
646     own copy of this count - if the same nc-value is seen twice, then the
647     request is a replay. See the description below of the construction
648     of the request-digest value.
649    
650     auth-param
651     This directive allows for future extensions. Any unrecognized
652     directive MUST be ignored.
653    
654     If a directive or its value is improper, or required directives
655     are missing, the proper response is 400 Bad Request.
656    
657     The definition of request-digest above indicates the encoding for
658     its value. The following definitions show how the value is
659     computed.
660    
661    
662     3.2.2.1 Request-Digest
663    
664     If the "qop" directive is not present (this construction is for
665     compatibility with RFC 2069):
666    
667     request-digest =
668     <"> < KD ( H(A1), unq(nonce-value) ":" H(A2) ) >
669     <">
670    
671     See below for the definitions for A1 and A2.
672    
673     Franks, et al. [Page 12]
674    
675    
676    
677     INTERNET-DRAFT HTTP AuthenticationFriday 7 August 1998
678    
679     If the "qop" value is "auth" or "auth-int":
680    
681     request-digest = <"> < KD ( H(A1), unq(nonce-value)
682     ":" nc-value
683     ":" unq(cnonce-value)
684     ":" unq(qop-value)
685     ":" H(A2)
686     ) <">
687    
688    
689     3.2.2.2 A1
690    
691     If the "algorithm" directive's value is "MD5" or is unspecified, then A1
692     is:
693    
694     A1 = unq(username-value) ":" unq(realm-value) ":" passwd
695    
696     where
697    
698     passwd = < user's password >
699    
700     If the "algorithm" directive's value is "MD5-sess", then A1 is
701     calculated only once - on the first request by the client
702     following receipt of a WWW-Authenticate challenge from the
703     server. It uses the server nonce from that challenge, and the
704     first client nonce value to construct A1 as follows:
705    
706     A1 = H( unq(username-value) ":" unq(realm-value)
707     ":" passwd )
708     ":" unq(nonce-value) ":" unq(cnonce-value)
709    
710     This creates a 'session key' for the authentication of subsequent
711     requests and responses which is different for each session, thus
712     limiting the amount of material hashed with any one key. Because the
713     server need only use the hash of the user credentials in order to create
714     the A1 value, this construction could be used as part of authentication
715     using a third party service so that the web server would not need the
716     actual password value. The specification of such a protocol is beyond
717     the scope of this specification.
718    
719    
720     3.2.2.3 A2
721    
722     If the "qop" directive's value is "auth" or is unspecified, then A2 is:
723    
724     A2 = Method ":" digest-uri-value
725    
726     If the "qop" value is "auth-int", then A2 is:
727    
728     A2 = Method ":" digest-uri-value ":" H(entity-body)
729    
730    
731     3.2.2.4 Directive values and quoted-string
732    
733     Note that the value of many of the directives, such as "username-
734     value", are defined as a "quoted-string". However, the "unq"
735     notation indicates that surrounding quotation marks are removed
736     in forming the string A1. Thus if the Authorization header
737     includes the fields
738    
739     username="Mufasa", realm=myhost@testrealm.com
740    
741    
742     Franks, et al. [Page 13]
743    
744    
745    
746     INTERNET-DRAFT HTTP AuthenticationFriday 7 August 1998
747    
748     and the user Mufasa has password "Circle Of Life" then H(A1)
749     would be H(Mufasa:myhost@testrealm.com:Circle Of Life) with no
750     quotation marks in the digested string.
751    
752     No white space is allowed in any of the strings to which the
753     digest function H() is applied unless that white space exists in
754     the quoted strings or entity body whose contents make up the
755     string to be digested. For example, the string A1 illustrated
756     above must be
757    
758     Mufasa:myhost@testrealm.com:Circle Of Life
759    
760     with no white space on either side of the colons, but with the
761     white space between the words used in the password value.
762     Likewise, the other strings digested by H() must not have white
763     space on either side of the colons which delimit their fields
764     unless that white space was in the quoted strings or entity body
765     being digested.
766    
767     Also note that if integrity protection is applied (qop=auth-int), the
768     H(entity-body) is the hash of the entity body, not the message body - it
769     is computed before any transfer encoding is applied by the sender and
770     after it has been removed by the recipient. Note that this includes
771     multipart boundaries and embedded headers in each part of any multipart
772     content-type.
773    
774    
775     3.2.2.5 Various considerations
776    
777     The "Method" value is the HTTP request method as specified in
778     section 5.1.1 of [2]. The "request-uri" value is the Request-URI
779     from the request line as specified in section 5.1.2 of [2]. This
780     may be "*", an "absoluteURL" or an "abs_path" as specified in
781     section 5.1.2 of [2], but it MUST agree with the Request-URI. In
782     particular, it MUST be an "absoluteURL" if the Request-URI is an
783     "absoluteURL". The "cnonce-value" is an optional client-chosen
784     value whose purpose is to foil chosen plaintext attacks.
785    
786     The authenticating server must assure that the document
787     designated by the "uri" parameter is the same as the document
788     served. The purpose of duplicating information from the request
789     URL in this field is to deal with the possibility that an
790     intermediate proxy may alter the client's request. This altered
791     (but presumably semantically equivalent) request would not result
792     in the same digest as that calculated by the client.
793    
794     Implementers should be aware of how authenticated transactions
795     interact with shared caches. The HTTP/1.1 protocol specifies that
796     when a shared cache (see section 13.7 of [2]) has received a
797     request containing an Authorization header and a response from
798     relaying that request, it MUST NOT return that response as a
799     reply to any other request, unless one of two Cache-Control (see
800     section 14.9 of [2]) directives was present in the response. If
801     the original response included the "must-revalidate" Cache-
802     Control directive, the cache MAY use the entity of that response
803     in replying to a subsequent request, but MUST first revalidate it
804     with the origin server, using the request headers from the new
805     request to allow the origin server to authenticate the new
806     request. Alternatively, if the original response included the
807     "public" Cache-Control directive, the response entity MAY be
808     returned in reply to any subsequent request.
809    
810     Franks, et al. [Page 14]
811    
812    
813    
814     INTERNET-DRAFT HTTP AuthenticationFriday 7 August 1998
815    
816     3.2.3 The Authentication-Info Header
817    
818     The Authentication-Info header is used by the server to
819     communicate some information regarding the successful
820     authentication in the response.
821    
822     AuthenticationInfo = "Authentication-Info" ":" auth-info
823     auth-info = 1#(nextnonce | [ message-qop ]
824     | [ response-auth ] | [ cnonce ]
825     | [nonce-count] )
826     nextnonce = "nextnonce" "=" nonce-value
827     response-auth = "rspauth" "=" response-digest
828     response-digest = <"> *LHEX <">
829    
830     The value of the nextnonce parameter is the nonce the server
831     wishes the client to use for a future authentication response.
832     The server may send the Authentication-Info header with a
833     nextnonce field as a means of implementing one-time or otherwise
834     changing nonces. If the nextnonce field is present the client
835     SHOULD use it when constructing the Authorization header for its
836     next request. Failure of the client to do so may result in a
837     request to re-authenticate from the server with the "stale=TRUE".
838    
839     Server implementations should carefully consider the
840     performance implications of the use of this mechanism;
841     pipelined requests will not be possible if every response
842     includes a nextnonce directive that must be used on the next
843     request received by the server. Consideration should be given
844     to the performance vs. security tradeoffs of allowing an old
845     nonce value to be used for a limited time to permit request
846     pipelining. Use of
847    
848     message-qop
849     Indicates the "quality of protection" options applied to the
850     response by the server. The value "auth" indicates authentication;
851     the value "auth-int" indicates authentication with integrity
852     protection. The server SHOULD use the same value for the message-qop
853     directive in the response as was sent by the client in the
854     corresponding request.
855    
856     The optional response digest in the "response-auth" directive
857     supports mutual authentication -- the server proves that it knows
858     the user's secret, and with qop=auth-int also provides limited
859     integrity protection of the response. The "response-digest" value
860     is calculated as for the "request-digest" in the Authorization
861     header, except that if "qop=auth" or is not specified in the
862     Authorization header for the request, A2 is
863    
864     A2 = ":" digest-uri-value
865    
866     and if "qop=auth-int", then A2 is
867    
868     A2 = ":" digest-uri-value ":" H(entity-body)
869    
870     where "digest-uri-value" is the value of the "uri" directive on the
871     Authorization header in the request. The "cnonce-value" and "nc-value"
872     MUST be the ones for the client request to which this message is the
873     response. The "response-auth", "cnonce", and "nonce-count" directives
874     MUST BE present if "qop=auth" or "qop=auth-int" is specified.
875    
876    
877     Franks, et al. [Page 15]
878    
879    
880    
881     INTERNET-DRAFT HTTP AuthenticationFriday 7 August 1998
882    
883     The Authentication-Info header is allowed in the trailer of an
884     HTTP message transferred via chunked transfer-coding.
885    
886    
887     3.3 Digest Operation
888    
889     Upon receiving the Authorization header, the server may check its
890     validity by looking up its known password which corresponds to
891     the submitted username. Then, the server must perform the same
892     digest operation (e.g., MD5) performed by the client, and compare
893     the result to the given request-digest value.
894    
895     Note that the HTTP server does not actually need to know the
896     user's cleartext password. As long as H(A1) is available to the
897     server, the validity of an Authorization header may be verified.
898    
899     A client may remember the username, password and nonce values, so
900     that future requests within the specified <domain> may include
901     the Authorization header preemptively. The server may choose to
902     accept the old Authorization header information, even though the
903     nonce value included might not be fresh. Alternatively, the
904     server could return a 401 response with a new nonce value,
905     causing the client to retry the request. By specifying stale=TRUE
906     with this response, the server hints to the client that the
907     request should be retried with the new nonce, without reprompting
908     the user for a new username and password.
909    
910     The opaque data is useful for transporting state information. For
911     example, a server could be responsible for authenticating content
912     which actually sits on another server. The first 401 response
913     would include a domain field which includes the URI on the second
914     server, and the opaque field for specifying state information.
915     The client will retry the request, at which time the server may
916     respond with a 301/302 redirection, pointing to the URI on the
917     second server. The client will follow the redirection, and pass
918     the same Authorization header, including the <opaque> data which
919     the second server may require.
920    
921     As with the basic scheme, proxies must be completely transparent
922     in the Digest access authentication scheme. That is, they must
923     forward the WWW-Authenticate, Authentication-Info and
924     Authorization headers untouched. If a proxy wants to authenticate
925     a client before a request is forwarded to the server, it can be
926     done using the Proxy-Authenticate and Proxy-Authorization headers
927     described in section 3.6 below.
928    
929    
930     3.4 Security Protocol Negotiation
931    
932     It is useful for a server to be able to know which security
933     schemes a client is capable of handling.
934    
935     It is possible that a server may want to require Digest as its
936     authentication method, even if the server does not know that the
937     client supports it. A client is encouraged to fail gracefully if
938     the server specifies only authentication schemes it cannot
939     handle.
940    
941    
942    
943    
944    
945     Franks, et al. [Page 16]
946    
947    
948    
949     INTERNET-DRAFT HTTP AuthenticationFriday 7 August 1998
950    
951     3.5 Example
952    
953     The following example assumes that an access-protected document
954     is being requested from the server via a GET request. The URI of
955     the document is "http://www.nowhere.org/dir/index.html". Both
956     client and server know that the username for this document is
957     "Mufasa", and the password is "Circle Of Life" (with one space
958     between each of the three words).
959    
960     The first time the client requests the document, no Authorization
961     header is sent, so the server responds with:
962    
963     HTTP/1.1 401 Unauthorized
964     WWW-Authenticate: Digest
965     realm="testrealm@host.com",
966     qop="auth,auth-int",
967     nonce="dcd98b7102dd2f0e8b11d0f600bfb0c093",
968     opaque="5ccc069c403ebaf9f0171e9517f40e41"
969    
970    
971     The client may prompt the user for the username and password,
972     after which it will respond with a new request, including the
973     following Authorization header:
974    
975     Authorization: Digest username="Mufasa",
976     realm="testrealm@host.com",
977     nonce="dcd98b7102dd2f0e8b11d0f600bfb0c093",
978     uri="/dir/index.html",
979     qop=auth,
980     nc=00000001,
981     cnonce="0a4f113b",
982     response="6629fae49393a05397450978507c4ef1",
983     opaque="5ccc069c403ebaf9f0171e9517f40e41"
984    
985     3.6 Proxy-Authentication and Proxy-Authorization
986    
987     The digest authentication scheme may also be used for
988     authenticating users to proxies, proxies to proxies, or proxies
989     to origin servers by use of the Proxy-Authenticate and Proxy-
990     Authorization headers. These headers are instances of the Proxy-
991     Authenticate and Proxy-Authorization headers specified in
992     sections 10.33 and 10.34 of the HTTP/1.1 specification [2] and
993     their behavior is subject to restrictions described there. The
994     transactions for proxy authentication are very similar to those
995     already described. Upon receiving a request which requires
996     authentication, the proxy/server must issue the "407 Proxy
997     Authentication Required" response with a "Proxy-Authenticate"
998     header. The digest-challenge used in the Proxy-Authenticate
999     header is the same as that for the WWW-Authenticate header as
1000     defined above in section 3.2.1.
1001    
1002     The client/proxy must then re-issue the request with a Proxy-
1003     Authorization header, with directives as specified for the Authorization
1004     header in section 3.2.2 above.
1005    
1006     On subsequent responses, the server sends Proxy-Authentication-Info with
1007     directives the same as those for the Authentication-Info header field.
1008    
1009     Note that in principle a client could be asked to authenticate
1010     itself to both a proxy and an end-server, but never in the same
1011     response.
1012    
1013     Franks, et al. [Page 17]
1014    
1015    
1016    
1017     INTERNET-DRAFT HTTP AuthenticationFriday 7 August 1998
1018    
1019     4 Security Considerations
1020    
1021     4.1 Authentication of Clients using Basic Authentication
1022    
1023     The Basic authentication scheme is not a secure method of user
1024     authentication, nor does it in any way protect the entity, which is
1025     transmitted in cleartext across the physical network used as the
1026     carrier. HTTP does not prevent additional authentication schemes and
1027     encryption mechanisms from being employed to increase security or the
1028     addition of enhancements (such as schemes to use one-time passwords) to
1029     Basic authentication.
1030    
1031     The most serious flaw in Basic authentication is that it results in the
1032     essentially cleartext transmission of the user’s password over the
1033     physical network. It is this problem which Digest Authentication
1034     attempts to address.
1035    
1036     Because Basic authentication involves the cleartext transmission of
1037     passwords it SHOULD NOT be used (without enhancements) to protect
1038     sensitive or valuable information.
1039    
1040     A common use of Basic authentication is for identification purposes --
1041     requiring the user to provide a user name and password as a means of
1042     identification, for example, for purposes of gathering accurate usage
1043     statistics on a server. When used in this way it is tempting to think
1044     that there is no danger in its use if illicit access to the protected
1045     documents is not a major concern. This is only correct if the server
1046     issues both user name and password to the users and in particular does
1047     not allow the user to choose his or her own password. The danger arises
1048     because naive users frequently reuse a single password to avoid the task
1049     of maintaining multiple passwords.
1050    
1051     If a server permits users to select their own passwords, then the threat
1052     is not only illicit access to documents on the server but also illicit
1053     access to the accounts of all users who have chosen to use their account
1054     password. If users are allowed to choose their own password that also
1055     means the server must maintain files containing the (presumably
1056     encrypted) passwords. Many of these may be the account passwords of
1057     users perhaps at distant sites. The owner or administrator of such a
1058     system could conceivably incur liability if this information is not
1059     maintained in a secure fashion.
1060    
1061     Basic Authentication is also vulnerable to spoofing by counterfeit
1062     servers. If a user can be led to believe that he is connecting to a host
1063     containing information protected by Basic authentication when, in fact,
1064     he is connecting to a hostile server or gateway, then the attacker can
1065     request a password, store it for later use, and feign an error. This
1066     type of attack is not possible with Digest Authentication. Server
1067     implementers SHOULD guard against the possibility of this sort of
1068     counterfeiting by gateways or CGI scripts. In particular it is very
1069     dangerous for a server to simply turn over a connection to a gateway.
1070     That gateway can then use the persistent connection mechanism to engage
1071     in multiple transactions with the client while impersonating the
1072     original server in a way that is not detectable by the client.
1073    
1074    
1075     4.2 Authentication of Clients using Digest Authentication
1076    
1077     Digest Authentication does not provide a strong authentication
1078     mechanism, when compared to public key based mechanisms, for
1079     example. However, it is significantly stronger than (e.g.) CRAM-
1080    
1081     Franks, et al. [Page 18]
1082    
1083    
1084    
1085     INTERNET-DRAFT HTTP AuthenticationFriday 7 August 1998
1086    
1087     MD5 which has been proposed for use with LDAP [10], POP and IMAP
1088     (see RFC 2195 [9]). It is intended to replace the much weaker
1089     and even more dangerous Basic mechanism.
1090    
1091     Digest Authentication offers no confidentiality protection beyond
1092     protecting the actual password. All of the rest of the request
1093     and response are available to an eavesdropper.
1094    
1095     Digest Authentication offers only limited integrity protection
1096     for the messages in either direction. If qop=auth-int mechanism
1097     is used, those parts of the message used in the calculation of
1098     the WWW-Authenticate and Authorization header field response
1099     directive values (see section 0) are protected. Most header
1100     fields and their values could be modified as a part of a man-in-
1101     the-middle attack.
1102    
1103     Many needs for secure HTTP transactions cannot be met by Digest
1104     Authentication. For those needs TLS or SHTTP are more appropriate
1105     protocols. In particular Digest authentication cannot be used for
1106     any transaction requiring confidentiality protection.
1107     Nevertheless many functions remain for which Digest
1108     authentication is both useful and appropriate (any service in
1109     present use that uses Basic should be switched to Digest as soon
1110     as practical).
1111    
1112    
1113     4.3 Limited Use Nonce Values
1114    
1115     The Digest scheme uses a server-specified nonce to seed the generation
1116     of the response-digest value (as specified in section 0). As shown in
1117     the example in 0, the server is free to construct the nonce such that it
1118     may only be used from a particular client, for a particular resource,
1119     for a limited period of time or number of uses, or any other
1120     restrictions. Doing so strengthens the protection provided against, for
1121     example, replay attacks (see 4.5). However, it should be noted that the
1122     method chosen for generating and checking the nonce also has performance
1123     and resource implications. For example, a server may choose to allow
1124     each nonce value to be used only once by maintaining a record of whether
1125     or not each recently issued nonce has been returned and sending a next-
1126     nonce directive in the Authentication-Info header field of every
1127     response. This protects against even an immediate replay attack, but has
1128     a high cost checking nonce values, and perhaps more important will cause
1129     authentication failures for any pipelined requests (presumably returning
1130     a stale nonce indication). Similarly, incorporating a request-specific
1131     element such as the Etag value for a resource limits the use of the
1132     nonce to that version of the resource and also defeats pipelining. Thus
1133     it may be useful to do so for methods with side effects but have
1134     unacceptable performance for those that do not.
1135    
1136    
1137     4.4 Comparison of Digest with Basic Authentication
1138    
1139     Both Digest and Basic Authentication are very much on the weak
1140     end of the security strength spectrum. But a comparison between
1141     the two points out the utility, even necessity, of replacing
1142     Basic by Digest.
1143    
1144     The greatest threat to the type of transactions for which these
1145     protocols are used is network snooping. This kind of transaction
1146     might involve, for example, online access to a database whose use
1147     is restricted to paying subscribers. With Basic authentication an
1148    
1149     Franks, et al. [Page 19]
1150    
1151    
1152    
1153     INTERNET-DRAFT HTTP AuthenticationFriday 7 August 1998
1154    
1155     eavesdropper can obtain the password of the user. This not only
1156     permits him to access anything in the database, but, often worse,
1157     will permit access to anything else the user protects with the
1158     same password.
1159    
1160     By contrast, with Digest Authentication the eavesdropper only gets
1161     access to the transaction in question and not to the user's password.
1162     The information gained by the eavesdropper would permit a replay attack,
1163     but only with a request for the same document, and even that may be
1164     limited by the servers choice of nonce.
1165    
1166    
1167     4.5 Replay Attacks
1168    
1169     A replay attack against Digest authentication would usually be
1170     pointless for a simple GET request since an eavesdropper would
1171     already have seen the only document he could obtain with a
1172     replay. This is because the URI of the requested document is
1173     digested in the client request and the server will only deliver
1174     that document. By contrast under Basic Authentication once the
1175     eavesdropper has the user's password, any document protected by
1176     that password is open to him.
1177    
1178     Thus, for some purposes, it is necessary to protect against
1179     replay attacks. A good Digest implementation can do this in
1180     various ways. The server created "nonce" value is implementation
1181     dependent, but if it contains a digest of the client IP, a time-
1182     stamp, the resource ETag, and a private server key (as
1183     recommended above) then a replay attack is not simple. An
1184     attacker must convince the server that the request is coming from
1185     a false IP address and must cause the server to deliver the
1186     document to an IP address different from the address to which it
1187     believes it is sending the document. An attack can only succeed
1188     in the period before the time-stamp expires. Digesting the client
1189     IP and time-stamp in the nonce permits an implementation which
1190     does not maintain state between transactions.
1191    
1192     For applications where no possibility of replay attack can be
1193     tolerated the server can use one-time nonce values which will not
1194     be honored for a second use. This requires the overhead of the
1195     server remembering which nonce values have been used until the
1196     nonce time-stamp (and hence the digest built with it) has
1197     expired, but it effectively protects against replay attacks.
1198    
1199     An implementation must give special attention to the possibility
1200     of replay attacks with POST and PUT requests. Unless the server
1201     employs one-time or otherwise limited-use nonces and/or insists
1202     on the use of the integrity protection of qop=auth-int, an
1203     attacker could replay valid credentials from a successful request
1204     with counterfeit form data or other message body. Even with the
1205     use of integrity protection most metadata in header fields is
1206     not protected. Proper nonce generation and checking provides some
1207     protection against replay of previously used valid credentials,
1208     but see 4.8.
1209    
1210    
1211     4.6 Weakness Created by Multiple Authentication Schemes
1212    
1213     An HTTP/1.1 server may return multiple challenges with a 401
1214     (Authenticate) response, and each challenge may use a different auth-
1215     scheme. A user agent MUST choose to use the strongest auth-scheme it
1216    
1217     Franks, et al. [Page 20]
1218    
1219    
1220    
1221     INTERNET-DRAFT HTTP AuthenticationFriday 7 August 1998
1222    
1223     understands and request credentials from the user based upon that
1224     challenge.
1225    
1226     Note that many browsers will only recognize Basic and will require
1227     that it be the first auth-scheme presented. Servers should only
1228     include Basic if it is minimally acceptable.
1229    
1230     When the server offers choices of authentication schemes using the WWW-
1231     Authenticate header, the strength of the resulting authentication is
1232     only as good as that of the of the weakest of the authentication
1233     schemes. See section 4.8 below for discussion of particular attack
1234     scenarios that exploit multiple authentication schemes.
1235    
1236    
1237     4.7 Online dictionary attacks
1238    
1239     If the attacker can eavesdrop, then it can test any overheard
1240     nonce/response pairs against a list of common words. Such a list is
1241     usually much smaller than the total number of possible passwords. The
1242     cost of computing the response for each password on the list is paid
1243     once for each challenge.
1244    
1245     This attack can be mitigated by checking the password against a
1246     dictionary when a user tries to change it and disallowing passwords that
1247     are in the dictionary.
1248    
1249    
1250     4.8 Man in the Middle
1251    
1252     Both Basic and Digest authentication are vulnerable to "man in the
1253     middle" (MITM) attacks, for example, from a hostile or compromised
1254     proxy. Clearly, this would present all the problems of eavesdropping.
1255     But it also offers some additional opportunities to the attacker.
1256    
1257     A possible man-in-the-middle attack would be to add a weak
1258     authentication scheme to the set of choices, hoping that the client will
1259     use one that exposes the user's credentials (e.g. password). For this
1260     reason, the client should always use the strongest scheme that it
1261     understands from the choices offered.
1262    
1263     An even better MITM attack would be to remove all offered choices,
1264     replacing them with a challenge that requests only Basic authentication,
1265     then uses the cleartext credentials from the Basic authentication to
1266     authenticate to the origin server using the stronger scheme it
1267     requested. A particularly insidious way to mount such a MITM attack
1268     would be to offer a "free" proxy caching service to gullible users.
1269    
1270     User agents should consider measures such as presenting a visual
1271     indication at the time of the credentials request of what authentication
1272     scheme is to be used, or remembering the strongest authentication scheme
1273     ever requested by a server and produce a warning message before using a
1274     weaker one. It might also be a good idea for the user agent to be
1275     configured to demand Digest authentication in general, or from specific
1276     sites.
1277    
1278     Or, a hostile proxy might spoof the client into making a request the
1279     attacker wanted rather than one the client wanted. Of course, this is
1280     still much harder than a comparable attack against Basic Authentication.
1281    
1282    
1283    
1284    
1285    
1286     Franks, et al. [Page 21]
1287    
1288    
1289    
1290     INTERNET-DRAFT HTTP AuthenticationFriday 7 August 1998
1291    
1292     4.9 Chosen plaintext attacks
1293    
1294     With Digest authentication, a MITM or a malicious server can arbitrarily
1295     choose the nonce that the client will use to compute the response. This
1296     is called a "chosen plaintext" attack. The ability to choose the nonce
1297     is known to make cryptanalysis much easier [8].
1298    
1299     However, no way to analyze the MD5 one-way function used by Digest using
1300     chosen plaintext is currently known.
1301    
1302     The countermeasure against this attack is to for clients to be
1303     configured to require the use of the optional "cnonce" directive; this
1304     allows the client to vary the input to the hash in a way not chosen by
1305     the attacker.
1306    
1307    
1308     4.10 Precomputed dictionary attacks
1309    
1310     With Digest authentication, if the attacker can execute a chosen
1311     plaintext attack, the attacker can precompute the response for many
1312     common words to a nonce of its choice, and store a dictionary of
1313     (response, password) pairs. Such precomputation can often be done in
1314     parallel on many machines. It can then use the chosen plaintext attack
1315     to acquire a response corresponding to that challenge, and just look up
1316     the password in the dictionary. Even if most passwords are not in the
1317     dictionary, some might be. Since the attacker gets to pick the
1318     challenge, the cost of computing the response for each password on the
1319     list can be amortized over finding many passwords. A dictionary with 100
1320     million password/response pairs would take about 3.2 gigabytes of disk
1321     storage.
1322    
1323     The countermeasure against this attack is to for clients to be
1324     configured to require the use of the optional "cnonce" directive.
1325    
1326    
1327     4.11 Batch brute force attacks
1328    
1329     With Digest authentication, a MITM can execute a chosen plaintext
1330     attack, and can gather responses from many users to the same nonce. It
1331     can then find all the passwords within any subset of password space that
1332     would generate one of the nonce/response pairs in a single pass over
1333     that space. It also reduces the time to find the first password by a
1334     factor equal to the number of nonce/response pairs gathered. This search
1335     of the password space can often be done in parallel on many machines,
1336     and even a single machine can search large subsets of the password space
1337     very quickly – reports exist of searching all passwords with six or
1338     fewer letters in a few hours.
1339    
1340     The countermeasure against this attack is to for clients to be
1341     configured to require the use of the optional "cnonce" directive.
1342    
1343    
1344     4.12 Spoofing by Counterfeit Servers
1345    
1346     Basic Authentication is vulnerable to spoofing by counterfeit servers.
1347     If a user can be led to believe that she is connecting to a host
1348     containing information protected by a password she knows, when in fact
1349     she is connecting to a hostile server, then the hostile server can
1350     request a password, store it away for later use, and feign an error.
1351     This type of attack is more difficult with Digest Authentication -- but
1352     the client must know to demand that Digest authentication be used,
1353     perhaps using some of the techniques described above to counter "man-in-
1354    
1355     Franks, et al. [Page 22]
1356    
1357    
1358    
1359     INTERNET-DRAFT HTTP AuthenticationFriday 7 August 1998
1360    
1361     the-middle" attacks. Again, the user can be helped in detecting this
1362     attack by a visual indication of the authentication mechanism in use
1363     with appropriate guidance in interpreting the implications of each
1364     scheme.
1365    
1366    
1367     4.13 Storing passwords
1368    
1369     Digest authentication requires that the authenticating agent (usually
1370     the server) store some data derived from the user's name and password in
1371     a "password file" associated with a given realm. Normally this might
1372     contain pairs consisting of username and H(A1), where H(A1) is the
1373     digested value of the username, realm, and password as described above.
1374    
1375     The security implications of this are that if this password file is
1376     compromised, then an attacker gains immediate access to documents on the
1377     server using this realm. Unlike, say a standard UNIX password file, this
1378     information need not be decrypted in order to access documents in the
1379     server realm associated with this file. On the other hand, decryption,
1380     or more likely a brute force attack, would be necessary to obtain the
1381     user's password. This is the reason that the realm is part of the
1382     digested data stored in the password file. It means that if one Digest
1383     authentication password file is compromised, it does not automatically
1384     compromise others with the same username and password (though it does
1385     expose them to brute force attack).
1386    
1387     There are two important security consequences of this. First the
1388     password file must be protected as if it contained unencrypted
1389     passwords, because for the purpose of accessing documents in its realm,
1390     it effectively does.
1391    
1392     A second consequence of this is that the realm string should be unique
1393     among all realms which any single user is likely to use. In particular a
1394     realm string should include the name of the host doing the
1395     authentication. The inability of the client to authenticate the server
1396     is a weakness of Digest Authentication.
1397    
1398    
1399     4.14 Summary
1400    
1401     By modern cryptographic standards Digest Authentication is weak. But for
1402     a large range of purposes it is valuable as a replacement for Basic
1403     Authentication. It remedies some, but not all, weaknesses of Basic
1404     Authentication. Its strength may vary depending on the implementation.
1405     In particular the structure of the nonce (which is dependent on the
1406     server implementation) may affect the ease of mounting a replay attack.
1407     A range of server options is appropriate since, for example, some
1408     implementations may be willing to accept the server overhead of one-time
1409     nonces or digests to eliminate the possibility of replay. Others may
1410     satisfied with a nonce like the one recommended above restricted to a
1411     single IP address and a single ETag or with a limited lifetime.
1412    
1413     The bottom line is that *any* compliant implementation will be
1414     relatively weak by cryptographic standards, but *any* compliant
1415     implementation will be far superior to Basic Authentication.
1416    
1417    
1418     5 Sample implementation
1419    
1420     The following code implements the calculations of H(A1), H(A2), request-
1421     digest and response-digest, and a test program which computes the values
1422    
1423    
1424     Franks, et al. [Page 23]
1425    
1426    
1427    
1428     INTERNET-DRAFT HTTP AuthenticationFriday 7 August 1998
1429    
1430     used in the example of section 3.5. It uses the MD5 implementation from
1431     RFC 1321.
1432    
1433     File "digcalc.h":
1434    
1435    
1436     #define HASHLEN 16
1437     typedef char HASH[HASHLEN];
1438     #define HASHHEXLEN 32
1439     typedef char HASHHEX[HASHHEXLEN+1];
1440     #define IN
1441     #define OUT
1442    
1443     /* calculate H(A1) as per HTTP Digest spec */
1444     void DigestCalcHA1(
1445     IN char * pszAlg,
1446     IN char * pszUserName,
1447     IN char * pszRealm,
1448     IN char * pszPassword,
1449     IN char * pszNonce,
1450     IN char * pszCNonce,
1451     OUT HASHHEX SessionKey
1452     );
1453    
1454     /* calculate request-digest/response-digest as per HTTP Digest spec */
1455     void DigestCalcResponse(
1456     IN HASHHEX HA1, /* H(A1) */
1457     IN char * pszNonce, /* nonce from server */
1458     IN char * pszNonceCount, /* 8 hex digits */
1459     IN char * pszCNonce, /* client nonce */
1460     IN char * pszQop, /* qop-value: "", "auth", "auth-int" */
1461     IN char * pszMethod, /* method from the request */
1462     IN char * pszDigestUri, /* requested URL */
1463     IN HASHHEX HEntity, /* H(entity body) if qop="auth-int" */
1464     OUT HASHHEX Response /* request-digest or response-digest */
1465     );
1466    
1467     File "digcalc.c":
1468    
1469     #include <global.h>
1470     #include <md5.h>
1471     #include <string.h>
1472     #include "digcalc.h"
1473    
1474     void CvtHex(
1475     IN HASH Bin,
1476     OUT HASHHEX Hex
1477     )
1478     {
1479     unsigned short i;
1480     unsigned char j;
1481    
1482     for (i = 0; i < HASHLEN; i++) {
1483     j = (Bin[i] >> 4) & 0xf;
1484     if (j <= 9)
1485     Hex[i*2] = (j + '0');
1486     else
1487     Hex[i*2] = (j + 'a' - 10);
1488    
1489     Franks, et al. [Page 24]
1490    
1491    
1492    
1493     INTERNET-DRAFT HTTP AuthenticationFriday 7 August 1998
1494    
1495     j = Bin[i] & 0xf;
1496     if (j <= 9)
1497     Hex[i*2+1] = (j + '0');
1498     else
1499     Hex[i*2+1] = (j + 'a' - 10);
1500     };
1501     Hex[HASHHEXLEN] = '\0';
1502     };
1503    
1504     /* calculate H(A1) as per spec */
1505     void DigestCalcHA1(
1506     IN char * pszAlg,
1507     IN char * pszUserName,
1508     IN char * pszRealm,
1509     IN char * pszPassword,
1510     IN char * pszNonce,
1511     IN char * pszCNonce,
1512     OUT HASHHEX SessionKey
1513     )
1514     {
1515     MD5_CTX Md5Ctx;
1516     HASH HA1;
1517    
1518     MD5Init(&Md5Ctx);
1519     MD5Update(&Md5Ctx, pszUserName, strlen(pszUserName));
1520     MD5Update(&Md5Ctx, ":", 1);
1521     MD5Update(&Md5Ctx, pszRealm, strlen(pszRealm));
1522     MD5Update(&Md5Ctx, ":", 1);
1523     MD5Update(&Md5Ctx, pszPassword, strlen(pszPassword));
1524     MD5Final(HA1, &Md5Ctx);
1525     if (stricmp(pszAlg, "md5-sess") == 0) {
1526     MD5Init(&Md5Ctx);
1527     MD5Update(&Md5Ctx, HA1, HASHLEN);
1528     MD5Update(&Md5Ctx, ":", 1);
1529     MD5Update(&Md5Ctx, pszNonce, strlen(pszNonce));
1530     MD5Update(&Md5Ctx, ":", 1);
1531     MD5Update(&Md5Ctx, pszCNonce, strlen(pszCNonce));
1532     MD5Final(HA1, &Md5Ctx);
1533     };
1534     CvtHex(HA1, SessionKey);
1535     };
1536    
1537     /* calculate request-digest/response-digest as per HTTP Digest spec */
1538     void DigestCalcResponse(
1539     IN HASHHEX HA1, /* H(A1) */
1540     IN char * pszNonce, /* nonce from server */
1541     IN char * pszNonceCount, /* 8 hex digits */
1542     IN char * pszCNonce, /* client nonce */
1543     IN char * pszQop, /* qop-value: "", "auth", "auth-int" */
1544     IN char * pszMethod, /* method from the request */
1545     IN char * pszDigestUri, /* requested URL */
1546     IN HASHHEX HEntity, /* H(entity body) if qop="auth-int" */
1547     OUT HASHHEX Response /* request-digest or response-digest */
1548     )
1549     {
1550     MD5_CTX Md5Ctx;
1551     HASH HA2;
1552    
1553     Franks, et al. [Page 25]
1554    
1555    
1556    
1557     INTERNET-DRAFT HTTP AuthenticationFriday 7 August 1998
1558    
1559     HASH RespHash;
1560     HASHHEX HA2Hex;
1561    
1562     // calculate H(A2)
1563     MD5Init(&Md5Ctx);
1564     MD5Update(&Md5Ctx, pszMethod, strlen(pszMethod));
1565     MD5Update(&Md5Ctx, ":", 1);
1566     MD5Update(&Md5Ctx, pszDigestUri, strlen(pszDigestUri));
1567     if (stricmp(pszQop, "auth-int") == 0) {
1568     MD5Update(&Md5Ctx, ":", 1);
1569     MD5Update(&Md5Ctx, HEntity, HASHHEXLEN);
1570     };
1571     MD5Final(HA2, &Md5Ctx);
1572     CvtHex(HA2, HA2Hex);
1573    
1574     // calculate response
1575     MD5Init(&Md5Ctx);
1576     MD5Update(&Md5Ctx, HA1, HASHHEXLEN);
1577     MD5Update(&Md5Ctx, ":", 1);
1578     MD5Update(&Md5Ctx, pszNonce, strlen(pszNonce));
1579     MD5Update(&Md5Ctx, ":", 1);
1580     if (*pszQop) {
1581     MD5Update(&Md5Ctx, pszNonceCount, strlen(pszNonceCount));
1582     MD5Update(&Md5Ctx, ":", 1);
1583     MD5Update(&Md5Ctx, pszCNonce, strlen(pszCNonce));
1584     MD5Update(&Md5Ctx, ":", 1);
1585     MD5Update(&Md5Ctx, pszQop, strlen(pszQop));
1586     MD5Update(&Md5Ctx, ":", 1);
1587     };
1588     MD5Update(&Md5Ctx, HA2Hex, HASHHEXLEN);
1589     MD5Final(RespHash, &Md5Ctx);
1590     CvtHex(RespHash, Response);
1591     };
1592    
1593     File "digtest.c":
1594    
1595    
1596     #include <stdio.h>
1597     #include "digcalc.h"
1598    
1599     void main(int argc, char ** argv) {
1600    
1601     char * pszNonce = "dcd98b7102dd2f0e8b11d0f600bfb0c093";
1602     char * pszCNonce = "0a4f113b";
1603     char * pszUser = "Mufasa";
1604     char * pszRealm = "testrealm@host.com";
1605     char * pszPass = "Circle Of Life";
1606     char * pszAlg = "md5";
1607     char szNonceCount[9] = "00000001";
1608     char * pszMethod = "GET";
1609     char * pszQop = "auth";
1610     char * pszURI = "/dir/index.html";
1611     HASHHEX HA1;
1612     HASHHEX HA2 = "";
1613     HASHHEX Response;
1614    
1615    
1616    
1617     Franks, et al. [Page 26]
1618    
1619    
1620    
1621     INTERNET-DRAFT HTTP AuthenticationFriday 7 August 1998
1622    
1623     DigestCalcHA1(pszAlg, pszUser, pszRealm, pszPass, pszNonce,
1624     pszCNonce, HA1);
1625     DigestCalcResponse(HA1, pszNonce, szNonceCount, pszCNonce, pszQop,
1626     pszMethod, pszURI, HA2, Response);
1627     printf("Response = %s\n", Response);
1628     };
1629    
1630     6 Acknowledgments
1631    
1632     Eric W. Sink, of AbiSource, Inc., was one of the original authors before
1633     the specification underwent substantial revision.
1634    
1635     In addition to the authors, valuable discussion instrumental in creating
1636     this document has come from Peter J. Churchyard, Ned Freed, and David M.
1637     Kristol.
1638    
1639     Jim Gettys and Larry Masinter edited this document for update.
1640    
1641    
1642     7 References
1643    
1644     [1] Berners-Lee, T., Fielding, R., and H. Frystyk, "Hypertext Transfer
1645     Protocol -- HTTP/1.0", RFC 1945, May 1996.
1646    
1647     [2] Fielding, R., Gettys, J., Mogul, J. C., Frysyk, H., Masinter, L.,
1648     Leach, P., Berners-Lee, T., " Hypertext Transfer Protocol --
1649     HTTP/1.1", Work In Progress of the HTTP working group, July, 1998.
1650    
1651     [3] Rivest, R., "The MD5 Message-Digest Algorithm", RFC 1321, April
1652     1992.
1653    
1654     [4] Freed, N., and N. Borenstein. "Multipurpose Internet Mail
1655     Extensions (MIME) Part One: Format of Internet Message Bodies." RFC
1656     2045, Innosoft, First Virtual, November 1996.
1657    
1658     [5] Dierks, T. and C. Allen "The TLS Protocol, Version 1.0," Work In
1659     Progress of the TLS working group, November, 1997.
1660    
1661     [6] Franks, J., Hallam-Baker, P., Hostetler, J., Leach, P., Luotonen,
1662     A., Sink, E., Stewart, L.,"An Extension to HTTP : Digest Access
1663     Authentication." RFC 2069, January, 1997.
1664    
1665     [7] Berners Lee, T, Fielding, R., Masinter, L., "Uniform Resource
1666     Identifiers (URI): Generic Syntax and Semantics," Work in Progress,
1667     November, 1997.
1668    
1669     [8] Kaliski, B.,Robshaw, M., "Message Authentication with MD5",
1670     CryptoBytes, Sping 1995, RSA Inc,
1671     (http://www.rsa.com/rsalabs/pubs/cryptobytes/spring95/md5.htm)
1672    
1673     [9] Klensin, J.,Catoe, R., Krumviede, P., "IMAP/POP AUTHorize Extension
1674     for Simple Challenge/Response", September 1997.
1675    
1676     [10] Morgan, B., Alvestrand, H., Hodges, J., Wahl, M., "Authentication
1677     Methods for LDAP", 07/07/1998. Work in progress, <draft-ietf-ldapext-
1678     authmeth-02.txt>
1679    
1680    
1681    
1682    
1683    
1684    
1685     Franks, et al. [Page 27]
1686    
1687    
1688    
1689     INTERNET-DRAFT HTTP AuthenticationFriday 7 August 1998
1690    
1691     8 Authors' Addresses
1692    
1693     John Franks
1694     Professor of Mathematics
1695     Department of Mathematics
1696     Northwestern University
1697     Evanston, IL 60208-2730, USA
1698    
1699     EMail: john@math.nwu.edu
1700    
1701     Phillip M. Hallam-Baker
1702     Principal Consultant
1703     Verisign Inc.
1704     301 Edgewater Place
1705     Suite 210
1706     Wakefield MA 01880, USA
1707    
1708     EMail: pbaker@verisign.com
1709    
1710     Jeffery L. Hostetler
1711     Software Craftsman
1712     AbiSource, Inc.
1713     6 Dunlap Court
1714     Savoy, IL 61874
1715    
1716     EMail: jeff@AbiSource.com
1717    
1718     Scott D. Lawrence
1719     Agranat Systems, Inc.
1720     1345 Main St.
1721     Waltham, MA 02154, USA
1722    
1723     EMail: lawrence@agranat.com
1724    
1725     Paul J. Leach
1726     Microsoft Corporation
1727     1 Microsoft Way
1728     Redmond, WA 98052, USA
1729    
1730     EMail: paulle@microsoft.com
1731    
1732     Ari Luotonen
1733     Member of Technical Staff
1734     Netscape Communications Corporation
1735     501 East Middlefield Road
1736     Mountain View, CA 94043, USA
1737    
1738     EMail: luotonen@netscape.com
1739    
1740     Lawrence C. Stewart
1741     Open Market, Inc.
1742     215 First Street
1743     Cambridge, MA 02142, USA
1744    
1745     EMail: stewart@OpenMarket.com
1746    
1747    
1748     9 Full Copyright Statement
1749    
1750     Copyright (C) The Internet Society (1998). All Rights Reserved.
1751    
1752     This document and translations of it may be copied and furnished to
1753     others, and derivative works that comment on or otherwise explain it or
1754     assist in its implmentation may be prepared, copied, published and
1755     distributed, in whole or in part, without restriction of any kind,
1756    
1757     Franks, et al. [Page 28]
1758    
1759    
1760    
1761     INTERNET-DRAFT HTTP AuthenticationFriday 7 August 1998
1762    
1763     provided that the above copyright notice and this paragraph are included
1764     on all such copies and derivative works. However, this document itself
1765     may not be modified in any way, such as by removing the copyright notice
1766     or references to the Internet Society or other Internet organizations,
1767     except as needed for the purpose of developing Internet standards in
1768     which case the procedures for copyrights defined in the Internet
1769     Standards process must be followed, or as required to translate it into
1770     languages other than English.
1771    
1772     The limited permissions granted above are perpetual and will not be
1773     revoked by the Internet Society or its successors or assigns.
1774    
1775     This document and the information contained herein is provided on an "AS
1776     IS" basis and THE INTERNET SOCIETY AND THE INTERNET ENGINEERING TASK
1777     FORCE DISCLAIMS ALL WARRANTIES, EXPRESS OR IMPLIED, INCLUDING BUT NOT
1778     LIMITED TO ANY WARRANTY THAT THE USE OF THE INFORMATION HEREIN WILL NOT
1779     INFRINGE ANY RIGHTS OR ANY IMPLIED WARRANTIES OF MERCHANTABILITY OR
1780     FITNESS FOR A PARTICULAR PURPOSE.
1781    
1782    
1783    
1784    
1785    
1786    
1787    
1788    
1789    
1790    
1791    
1792    
1793    
1794    
1795    
1796    
1797    
1798    
1799    
1800    
1801    
1802    
1803    
1804    
1805    
1806    
1807    
1808    
1809    
1810    
1811    
1812    
1813    
1814    
1815    
1816    
1817    
1818    
1819    
1820    
1821    
1822     Franks, et al. [Page 29]

admin@suikawiki.org
ViewVC Help
Powered by ViewVC 1.1.24