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

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

Parent Directory Parent Directory | Revision Log Revision Log


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

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

admin@suikawiki.org
ViewVC Help
Powered by ViewVC 1.1.24