As per Relevance of the word password, we have this rfc below:











Network Working Group J.
Request for Comments: 2617 Northwestern
Obsoletes: 2069 P. Hallam-
Category: Standards Track Verisign, Inc
J.
AbiSource, Inc
S.
Agranat Systems, Inc
P.
Microsoft
A.
Netscape Communications
L.
Open Market, Inc
June 1999


HTTP Authentication: Basic and Digest Access

Status of this

This document specifies an Internet standards track protocol for
Internet community, and requests discussion and suggestions
improvements. Please refer to the current edition of the "
Official Protocol Standards" (STD 1) for the standardization
and status of this protocol. Distribution of this memo is unlimited

Copyright

Copyright (C) The Internet Society (1999). All Rights Reserved



"HTTP/1.0", includes the specification for a Basic
Authentication scheme. This scheme is not considered to be a
method of user authentication (unless used in conjunction with
external secure system such as SSL [5]), as the user name
password are passed over the network as cleartext

This document also provides the specification for HTTP'
authentication framework, the original Basic authentication
and a scheme based on cryptographic hashes, referred to as "
Access Authentication". It is therefore also intended to serve as
replacement for RFC 2069 [6]. Some optional elements specified
RFC 2069 have been removed from this specification due to
found since its publication; other new elements have been added
compatibility, those new elements have been made optional, but
strongly recommended



Franks, et al. Standards Track [Page 1]

RFC 2617 HTTP Authentication June 1999


Like Basic, Digest access authentication verifies that both
to a communication know a shared secret (a password); unlike Basic
this verification can be done without sending the password in
clear, which is Basic's biggest weakness. As with most
authentication protocols, the greatest sources of risks are
found not in the core protocol itself but in policies and
surrounding its use

Table of

1 Access Authentication................................ 3
1.1 Reliance on the HTTP/1.1 Specification............ 3
1.2 Access Authentication Framework................... 3
2 Basic Authentication Scheme.......................... 5
3 Digest Access Authentication Scheme.................. 6
3.1 Introduction...................................... 6
3.1.1 Purpose......................................... 6
3.1.2 Overall Operation............................... 6
3.1.3 Representation of digest values................. 7
3.1.4 Limitations..................................... 7
3.2 Specification of Digest Headers................... 7
3.2.1 The WWW-Authenticate Response Header............ 8
3.2.2 The Authorization Request Header................ 11
3.2.3 The Authentication-Info Header.................. 15
3.3 Digest Operation.................................. 17
3.4 Security Protocol Negotiation..................... 18
3.5 Example........................................... 18
3.6 Proxy-Authentication and Proxy-Authorization...... 19
4 Security Considerations.............................. 19
4.1 Authentication of Clients using
Authentication.................................... 19
4.2 Authentication of Clients using
Authentication.................................... 20
4.3 Limited Use Nonce Values.......................... 21
4.4 Comparison of Digest with Basic Authentication.... 22
4.5 Replay Attacks.................................... 22
4.6 Weakness Created by Multiple
Schemes........................................... 23
4.7 Online dictionary attacks......................... 23
4.8 Man in the Middle................................. 24
4.9 Chosen plaintext attacks.......................... 24
4.10 Precomputed dictionary attacks.................... 25
4.11 Batch brute force attacks......................... 25
4.12 Spoofing by Counterfeit Servers................... 25
4.13 Storing passwords................................. 26
4.14 Summary........................................... 26
5 Sample implementation................................ 27
6 Acknowledgments...................................... 31



Franks, et al. Standards Track [Page 2]

RFC 2617 HTTP Authentication June 1999


7 References........................................... 31
8 Authors' Addresses................................... 32
9 Full Copyright Statement............................. 34

1 Access

1.1 Reliance on the HTTP/1.1

This specification is a companion to the HTTP/1.1 specification [2].
It uses the augmented BNF section 2.1 of that document, and relies
both the non-terminals defined in that document and other aspects
the HTTP/1.1 specification

1.2 Access Authentication

HTTP provides a simple challenge-response authentication
that MAY be used by a server to challenge a client request and by
client to provide authentication information. It uses an extensible
case-insensitive token to identify the authentication scheme
followed by a comma-separated list of attribute-value pairs
carry the parameters necessary for achieving authentication via
scheme

auth-scheme =
auth-param = token "=" ( token | quoted-string )

The 401 (Unauthorized) response message is used by an origin
to challenge the authorization of a user agent. This response
include a WWW-Authenticate header field containing at least
challenge applicable to the requested resource. The 407 (
Authentication Required) response message is used by a proxy
challenge the authorization of a client and MUST include a Proxy
Authenticate header field containing at least one
applicable to the proxy for the requested resource

challenge = auth-scheme 1*SP 1#auth-

Note: User agents will need to take special care in parsing the WWW
Authenticate or Proxy-Authenticate header field value if it
more than one challenge, or if more than one WWW-Authenticate
field is provided, since the contents of a challenge may
contain a comma-separated list of authentication parameters

The authentication parameter realm is defined for all
schemes

realm = "realm" "=" realm-
realm-value = quoted-



Franks, et al. Standards Track [Page 3]

RFC 2617 HTTP Authentication June 1999


The realm directive (case-insensitive) is required for
authentication schemes that issue a challenge. The realm
(case-sensitive), in combination with the canonical root URL (
absoluteURI for the server whose abs_path is empty; see section 5.1.2
of [2]) of the server being accessed, defines the protection space
These realms allow the protected resources on a server to
partitioned into a set of protection spaces, each with its
authentication scheme and/or authorization database. The realm
is a string, generally assigned by the origin server, which may
additional semantics specific to the authentication scheme. Note
there may be multiple challenges with the same auth-scheme
different realms

A user agent that wishes to authenticate itself with an
server--usually, but not necessarily, after receiving a 401
(Unauthorized)--MAY do so by including an Authorization header
with the request. A client that wishes to authenticate itself with
proxy--usually, but not necessarily, after receiving a 407 (
Authentication Required)--MAY do so by including a Proxy
Authorization header field with the request. Both the
field value and the Proxy-Authorization field value consist
credentials containing the authentication information of the
for the realm of the resource being requested. The user agent
choose to use one of the challenges with the strongest auth-scheme
understands and request credentials from the user based upon
challenge

credentials = auth-scheme #auth-

Note that many browsers will only recognize Basic and will
that it be the first auth-scheme presented. Servers should
include Basic if it is minimally acceptable

The protection space determines the domain over which credentials
be automatically applied. If a prior request has been authorized,
same credentials MAY be reused for all other requests within
protection space for a period of time determined by
authentication scheme, parameters, and/or user preference.
otherwise defined by the authentication scheme, a single
space cannot extend outside the scope of its server

If the origin server does not wish to accept the credentials
with a request, it SHOULD return a 401 (Unauthorized) response.
response MUST include a WWW-Authenticate header field containing
least one (possibly new) challenge applicable to the
resource. If a proxy does not accept the credentials sent with
request, it SHOULD return a 407 (Proxy Authentication Required).
response MUST include a Proxy-Authenticate header field containing



Franks, et al. Standards Track [Page 4]

RFC 2617 HTTP Authentication June 1999


(possibly new) challenge applicable to the proxy for the
resource

The HTTP protocol does not restrict applications to this
challenge-response mechanism for access authentication.
mechanisms MAY be used, such as encryption at the transport level
via message encapsulation, and with additional header
specifying authentication information. However, these
mechanisms are not defined by this specification

Proxies MUST be completely transparent regarding user
authentication by origin servers. That is, they must forward
WWW-Authenticate and Authorization headers untouched, and follow
rules found in section 14.8 of [2]. Both the Proxy-Authenticate
the Proxy-Authorization header fields are hop-by-hop headers (
section 13.5.1 of [2]).

2 Basic Authentication

The "basic" authentication scheme is based on the model that
client must authenticate itself with a user-ID and a password
each realm. The realm value should be considered an opaque
which can only be compared for equality with other realms on
server. The server will service the request only if it can
the user-ID and password for the protection space of the Request-URI
There are no optional authentication parameters

For Basic, the framework above is utilized as follows

challenge = "Basic"
credentials = "Basic" basic-

Upon receipt of an unauthorized request for a URI within
protection space, the origin server MAY respond with a challenge
the following

WWW-Authenticate: Basic realm="WallyWorld

where "WallyWorld" is the string assigned by the server to
the protection space of the Request-URI. A proxy may respond with
same challenge using the Proxy-Authenticate header field

To receive authorization, the client sends the userid and password
separated by a single colon (":") character, within a base64 [7]
encoded string in the credentials

basic-credentials = base64-user-
base64-user-pass = encoding of user-pass



Franks, et al. Standards Track [Page 5]

RFC 2617 HTTP Authentication June 1999


except not limited to 76 char/line
user-pass = userid ":"
userid = *
password = *

Userids might be case sensitive

If the user agent wishes to send the userid "Aladdin" and
"open sesame", it would use the following header field

Authorization: Basic QWxhZGRpbjpvcGVuIHNlc2FtZQ==

A client SHOULD assume that all paths at or deeper than the depth
the last symbolic element in the path field of the Request-URI
are within the protection space specified by the Basic realm value
the current challenge. A client MAY preemptively send
corresponding Authorization header with requests for resources
that space without receipt of another challenge from the server
Similarly, when a client sends a request to a proxy, it may reuse
userid and password in the Proxy-Authorization header field
receiving another challenge from the proxy server. See section 4
security considerations associated with Basic authentication

3 Digest Access Authentication

3.1

3.1.1

The protocol referred to as "HTTP/1.0" includes the specification
a Basic Access Authentication scheme[1]. That scheme is
considered to be a secure method of user authentication, as the
name and password are passed over the network in an unencrypted form
This section provides the specification for a scheme that does
send the password in cleartext, referred to as "Digest
Authentication".

The Digest Access Authentication scheme is not intended to be
complete answer to the need for security in the World Wide Web.
scheme provides no encryption of message content. The intent
simply to create an access authentication method that avoids the
serious flaws of Basic authentication

3.1.2 Overall

Like Basic Access Authentication, the Digest scheme is based on
simple challenge-response paradigm. The Digest scheme
using a nonce value. A valid response contains a checksum (



Franks, et al. Standards Track [Page 6]

RFC 2617 HTTP Authentication June 1999


default, the MD5 checksum) of the username, the password, the
nonce value, the HTTP method, and the requested URI. In this way,
password is never sent in the clear. Just as with the Basic scheme
the username and password must be prearranged in some fashion
addressed by this document

3.1.3 Representation of digest

An optional header allows the server to specify the algorithm used
create the checksum or digest. By default the MD5 algorithm is
and that is the only algorithm described in this document

For the purposes of this document, an MD5 digest of 128 bits
represented as 32 ASCII printable characters. The bits in the 128
digest are converted from most significant to least significant bit
four bits at a time to their ASCII presentation as follows. Each
bits is represented by its familiar hexadecimal notation from
characters 0123456789abcdef. That is, binary 0000 gets represented
the character '0', 0001, by '1', and so on up to the
of 1111 as 'f'.

3.1.4

The Digest authentication scheme described in this document
from many known limitations. It is intended as a replacement
Basic authentication and nothing more. It is a password-based
and (on the server side) suffers from all the same problems of
password system. In particular, no provision is made in this
for the initial secure arrangement between user and server
establish the user's password

Users and implementors should be aware that this protocol is not
secure as Kerberos, and not as secure as any client-side private-
scheme. Nevertheless it is better than nothing, better than what
commonly used with telnet and ftp, and better than
authentication

3.2 Specification of Digest

The Digest Access Authentication scheme is conceptually similar
the Basic scheme. The formats of the modified WWW-Authenticate
line and the Authorization header line are specified below.
addition, a new header, Authentication-Info, is specified








Franks, et al. Standards Track [Page 7]

RFC 2617 HTTP Authentication June 1999


3.2.1 The WWW-Authenticate Response

If a server receives a request for an access-protected object, and
acceptable Authorization header is not sent, the server responds
a "401 Unauthorized" status code, and a WWW-Authenticate header
per the framework defined above, which for the digest scheme
utilized as follows

challenge = "Digest" digest-

digest-challenge = 1#( realm | [ domain ] | nonce |
[ opaque ] |[ stale ] | [ algorithm ] |
[ qop-options ] | [auth-param] )


domain = "domain" "=" <"> URI ( 1*SP URI ) <">
URI = absoluteURI | abs_
nonce = "nonce" "=" nonce-
nonce-value = quoted-
opaque = "opaque" "=" quoted-
stale = "stale" "=" ( "true" | "false" )
algorithm = "algorithm" "=" ( "MD5" | "MD5-sess" |
token )
qop-options = "qop" "=" <"> 1#qop-value <">
qop-value = "auth" | "auth-int" |

The meanings of the values of the directives used above are
follows


A string to be displayed to users so they know which username
password to use. This string should contain at least the name
the host performing the authentication and might
indicate the collection of users who might have access. An
might be "registered_users@gotham.news.com".


A quoted, space-separated list of URIs, as specified in RFC
[7], that define the protection space. If a URI is an abs_path,
is relative to the canonical root URL (see section 1.2 above)
the server being accessed. An absoluteURI in this list may refer
a different server than the one being accessed. The client can
this list to determine the set of URIs for which the
authentication information may be sent: any URI that has a URI
this list as a prefix (after both have been made absolute) may
assumed to be in the same protection space. If this directive
omitted or its value is empty, the client should assume that
protection space consists of all URIs on the responding server



Franks, et al. Standards Track [Page 8]

RFC 2617 HTTP Authentication June 1999


This directive is not meaningful in Proxy-Authenticate headers,
which the protection space is always the entire proxy; if
it should be ignored


A server-specified data string which should be uniquely
each time a 401 response is made. It is recommended that
string be base64 or hexadecimal data. Specifically, since
string is passed in the header lines as a quoted string,
double-quote character is not allowed

The contents of the nonce are implementation dependent. The
of the implementation depends on a good choice. A nonce might,
example, be constructed as the base 64 encoding

time-stamp H(time-stamp ":" ETag ":" private-key

where time-stamp is a server-generated time or other non-
value, ETag is the value of the HTTP ETag header associated
the requested entity, and private-key is data known only to
server. With a nonce of this form a server would recalculate
hash portion after receiving the client authentication header
reject the request if it did not match the nonce from that
or if the time-stamp value is not recent enough. In this way
server can limit the time of the nonce's validity. The inclusion
the ETag prevents a replay request for an updated version of
resource. (Note: including the IP address of the client in
nonce would appear to offer the server the ability to limit
reuse of the nonce to the same client that originally got it
However, that would break proxy farms, where requests from a
user often go through different proxies in the farm. Also,
address spoofing is not that hard.)

An implementation might choose not to accept a previously
nonce or a previously used digest, in order to protect against
replay attack. Or, an implementation might choose to use one-
nonces or digests for POST or PUT requests and a time-stamp for
requests. For more details on the issues involved see section 4.
of this document

The nonce is opaque to the client


A string of data, specified by the server, which should be
by the client unchanged in the Authorization header of
requests with URIs in the same protection space. It is
that this string be base64 or hexadecimal data




Franks, et al. Standards Track [Page 9]

RFC 2617 HTTP Authentication June 1999



A flag, indicating that the previous request from the client
rejected because the nonce value was stale. If stale is
(case-insensitive), the client may wish to simply retry the
with a new encrypted response, without reprompting the user for
new username and password. The server should only set stale to
if it receives a request for which the nonce is invalid but with
valid digest for that nonce (indicating that the client knows
correct username/password). If stale is FALSE, or anything
than TRUE, or the stale directive is not present, the
and/or password are invalid, and new values must be obtained


A string indicating a pair of algorithms used to produce the
and a checksum. If this is not present it is assumed to be "MD5".
If the algorithm is not understood, the challenge should be
(and a different one used, if there is more than one).

In this document the string obtained by applying the
algorithm to the data "data" with secret "secret" will be
by KD(secret, data), and the string obtained by applying
checksum algorithm to the data "data" will be denoted H(data).
notation unq(X) means the value of the quoted-string X without
surrounding quotes

For the "MD5" and "MD5-sess"

H(data) = MD5(data



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

i.e., the digest is the MD5 of the secret concatenated with a
concatenated with the data. The "MD5-sess" algorithm is intended
allow efficient 3rd party authentication servers; for
difference in usage, see the description in section 3.2.2.2.

qop-
This directive is optional, but is made so only for
compatibility with RFC 2069 [6]; it SHOULD be used by
implementations compliant with this version of the Digest scheme
If present, it is a quoted string of one or more tokens
the "quality of protection" values supported by the server.
value "auth" indicates authentication; the value "auth-int
indicates authentication with integrity protection; see





Franks, et al. Standards Track [Page 10]

RFC 2617 HTTP Authentication June 1999


descriptions below for calculating the response directive value
the application of this choice. Unrecognized options MUST
ignored

auth-
This directive allows for future extensions. Any
directive MUST be ignored

3.2.2 The Authorization Request

The client is expected to retry the request, passing an
header line, which is defined according to the framework above
utilized as follows

credentials = "Digest" digest-
digest-response = 1#( username | realm | nonce | digest-
| response | [ algorithm ] | [cnonce] |
[opaque] | [message-qop] |
[nonce-count] | [auth-param] )

username = "username" "=" username-
username-value = quoted-
digest-uri = "uri" "=" digest-uri-
digest-uri-value = request-uri ; As specified by HTTP/1.1
message-qop = "qop" "=" qop-
cnonce = "cnonce" "=" cnonce-
cnonce-value = nonce-
nonce-count = "nc" "=" nc-
nc-value = 8
response = "response" "=" request-
request-digest = <"> 32LHEX <">
LHEX = "0" | "1" | "2" | "3" |
"4" | "5" | "6" | "7" |
"8" | "9" | "a" | "b" |
"c" | "d" | "e" | "f

The values of the opaque and algorithm fields must be those
in the WWW-Authenticate response header for the entity
requested


A string of 32 hex digits computed as defined below, which
that the user knows a


The user's name in the specified realm





Franks, et al. Standards Track [Page 11]

RFC 2617 HTTP Authentication June 1999


digest-
The URI from Request-URI of the Request-Line; duplicated
because proxies are allowed to change the Request-Line in transit


Indicates what "quality of protection" the client has applied
the message. If present, its value MUST be one of the
the server indicated it supports in the WWW-Authenticate header
These values affect the computation of the request-digest.
that this is a single token, not a quoted list of alternatives
in WWW- Authenticate. This directive is optional in order
preserve backward compatibility with a minimal implementation
RFC 2069 [6], but SHOULD be used if the server indicated that
is supported by providing a qop directive in the WWW-
header field


This MUST be specified if a qop directive is sent (see above),
MUST NOT be specified if the server did not send a qop directive
the WWW-Authenticate header field. The cnonce-value is an
quoted string value provided by the client and used by both
and server to avoid chosen plaintext attacks, to provide
authentication, and to provide some message integrity protection
See the descriptions below of the calculation of the response
digest and request-digest values

nonce-
This MUST be specified if a qop directive is sent (see above),
MUST NOT be specified if the server did not send a qop directive
the WWW-Authenticate header field. The nc-value is the
count of the number of requests (including the current request
that the client has sent with the nonce value in this request.
example, in the first request sent in response to a given
value, the client sends "nc=00000001". The purpose of
directive is to allow the server to detect request replays
maintaining its own copy of this count - if the same nc-value
seen twice, then the request is a replay. See the
below of the construction of the request-digest value

auth-
This directive allows for future extensions. Any
directive MUST be ignored

If a directive or its value is improper, or required directives
missing, the proper response is 400 Bad Request. If the request
digest is invalid, then a login failure should be logged,
repeated login failures from a single client may indicate an
attempting to guess passwords



Franks, et al. Standards Track [Page 12]

RFC 2617 HTTP Authentication June 1999


The definition of request-digest above indicates the encoding for
value. The following definitions show how the value is computed

3.2.2.1 Request-

If the "qop" value is "auth" or "auth-int":

request-digest = <"> < KD ( H(A1), unq(nonce-value
":" nc-
":" unq(cnonce-value
":" unq(qop-value
":" H(A2)
) <">

If the "qop" directive is not present (this construction is
compatibility with RFC 2069):

request-digest =
<"> < KD ( H(A1), unq(nonce-value) ":" H(A2) ) >
<">

See below for the definitions for A1 and A2.

3.2.2.2 A

If the "algorithm" directive's value is "MD5" or is unspecified,
A1 is

A1 = unq(username-value) ":" unq(realm-value) ":"



passwd = < user's password >

If the "algorithm" directive's value is "MD5-sess", then A1
calculated only once - on the first request by the client
receipt of a WWW-Authenticate challenge from the server. It uses
server nonce from that challenge, and the first client nonce value
construct A1 as follows

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

This creates a 'session key' for the authentication of
requests and responses which is different for each "
session", thus limiting the amount of material hashed with any
key. (Note: see further discussion of the authentication session



Franks, et al. Standards Track [Page 13]

RFC 2617 HTTP Authentication June 1999


section 3.3.) Because the server need only use the hash of the
credentials in order to create the A1 value, this construction
be used in conjunction with a third party authentication service
that the web server would not need the actual password value.
specification of such a protocol is beyond the scope of
specification

3.2.2.3 A

If the "qop" directive's value is "auth" or is unspecified, then A
is

A2 = Method ":" digest-uri-

If the "qop" value is "auth-int", then A2 is

A2 = Method ":" digest-uri-value ":" H(entity-body

3.2.2.4 Directive values and quoted-

Note that the value of many of the directives, such as "username
value", are defined as a "quoted-string". However, the "unq"
indicates that surrounding quotation marks are removed in forming
string A1. Thus if the Authorization header includes the

username="Mufasa", realm=myhost@testrealm.

and the user Mufasa has password "Circle Of Life" then H(A1) would
H(Mufasa:myhost@testrealm.com:Circle Of Life) with no quotation
in the digested string

No white space is allowed in any of the strings to which the
function H() is applied unless that white space exists in the
strings or entity body whose contents make up the string to
digested. For example, the string A1 illustrated above must

Mufasa:myhost@testrealm.com:Circle Of

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

Also note that if integrity protection is applied (qop=auth-int),
H(entity-body) is the hash of the entity body, not the message body -
it is computed before any transfer encoding is applied by the




Franks, et al. Standards Track [Page 14]

RFC 2617 HTTP Authentication June 1999


and after it has been removed by the recipient. Note that
includes multipart boundaries and embedded headers in each part
any multipart content-type

3.2.2.5 Various

The "Method" value is the HTTP request method as specified in
5.1.1 of [2]. The "request-uri" value is the Request-URI from
request line as specified in section 5.1.2 of [2]. This may be "*",
an "absoluteURL" or an "abs_path" as specified in section 5.1.2
[2], but it MUST agree with the Request-URI. In particular, it
be an "absoluteURL" if the Request-URI is an "absoluteURL".
"cnonce-value" is an optional client-chosen value whose purpose
to foil chosen plaintext attacks

The authenticating server must assure that the resource designated
the "uri" directive is the same as the resource specified in
Request-Line; if they are not, the server SHOULD return a 400
Request error. (Since this may be a symptom of an attack,
implementers may want to consider logging such errors.) The
of duplicating information from the request URL in this field is
deal with the possibility that an intermediate proxy may alter
client's Request-Line. This altered (but presumably
equivalent) request would not result in the same digest as
calculated by the client

Implementers should be aware of how authenticated
interact with shared caches. The HTTP/1.1 protocol specifies
when a shared cache (see section 13.7 of [2]) has received a
containing an Authorization header and a response from relaying
request, it MUST NOT return that response as a reply to any
request, unless one of two Cache-Control (see section 14.9 of [2])
directives was present in the response. If the original
included the "must-revalidate" Cache-Control directive, the cache
use the entity of that response in replying to a subsequent request
but MUST first revalidate it with the origin server, using
request headers from the new request to allow the origin server
authenticate the new request. Alternatively, if the original
included the "public" Cache-Control directive, the response
MAY be returned in reply to any subsequent request

3.2.3 The Authentication-Info

The Authentication-Info header is used by the server to
some information regarding the successful authentication in
response





Franks, et al. Standards Track [Page 15]

RFC 2617 HTTP Authentication June 1999


AuthenticationInfo = "Authentication-Info" ":" auth-
auth-info = 1#(nextnonce | [ message-qop ]
| [ response-auth ] | [ cnonce ]
| [nonce-count] )
nextnonce = "nextnonce" "=" nonce-
response-auth = "rspauth" "=" response-
response-digest = <"> *LHEX <">

The value of the nextnonce directive is the nonce the server
the client to use for a future authentication response. The
may send the Authentication-Info header with a nextnonce field as
means of implementing one-time or otherwise changing nonces. If
nextnonce field is present the client SHOULD use it when
the Authorization header for its next request. Failure of the
to do so may result in a request to re-authenticate from the
with the "stale=TRUE".

Server implementations should carefully consider the
implications of the use of this mechanism; pipelined requests
not be possible if every response includes a nextnonce
that must be used on the next request received by the server
Consideration should be given to the performance vs.
tradeoffs of allowing an old nonce value to be used for a
time to permit request pipelining. Use of the nonce-count
retain most of the security advantages of a new server
without the deleterious affects on pipelining

message-
Indicates the "quality of protection" options applied to
response by the server. The value "auth" indicates authentication
the value "auth-int" indicates authentication with
protection. The server SHOULD use the same value for the message
qop directive in the response as was sent by the client in
corresponding request

The optional response digest in the "response-auth"
supports mutual authentication -- the server proves that it knows
user's secret, and with qop=auth-int also provides limited
protection of the response. The "response-digest" value is
as for the "request-digest" in the Authorization header, except
if "qop=auth" or is not specified in the Authorization header for
request, A2

A2 = ":" digest-uri-

and if "qop=auth-int", then A2

A2 = ":" digest-uri-value ":" H(entity-body



Franks, et al. Standards Track [Page 16]

RFC 2617 HTTP Authentication June 1999


where "digest-uri-value" is the value of the "uri" directive on
Authorization header in the request. The "cnonce-value" and "nc
value" MUST be the ones for the client request to which this
is the response. The "response-auth", "cnonce", and "nonce-count
directives MUST BE present if "qop=auth" or "qop=auth-int"
specified

The Authentication-Info header is allowed in the trailer of an
message transferred via chunked transfer-coding

3.3 Digest

Upon receiving the Authorization header, the server may check
validity by looking up the password that corresponds to the
username. Then, the server must perform the same digest
(e.g., MD5) performed by the client, and compare the result to
given request-digest value

Note that the HTTP server does not actually need to know the user'
cleartext password. As long as H(A1) is available to the server,
validity of an Authorization header may be verified

The client response to a WWW-Authenticate challenge for a
space starts an authentication session with that protection space
The authentication session lasts until the client receives
WWW-Authenticate challenge from any server in the protection space.
client should remember the username, password, nonce, nonce count
opaque values associated with an authentication session to use
construct the Authorization header in future requests within
protection space. The Authorization header may be
preemptively; doing so improves server efficiency and avoids
round trips for authentication challenges. The server may choose
accept the old Authorization header information, even though
nonce value included might not be fresh. Alternatively, the
may return a 401 response with a new nonce value, causing the
to retry the request; by specifying stale=TRUE with this response
the server tells the client to retry with the new nonce, but
prompting for a new username and password

Because the client is required to return the value of the
directive given to it by the server for the duration of a session
the opaque data may be used to transport authentication session
information. (Note that any such use can also be accomplished
easily and safely by including the state in the nonce.) For example
a server could be responsible for authenticating content
actually sits on another server. It would achieve this by having
first 401 response include a domain directive whose value includes
URI on the second server, and an opaque directive whose



Franks, et al. Standards Track [Page 17]

RFC 2617 HTTP Authentication June 1999


contains the state information. The client will retry the request,
which time the server might respond with a 301/302 redirection
pointing to the URI on the second server. The client will follow
redirection, and pass an Authorization header , including
data

As with the basic scheme, proxies must be completely transparent
the Digest access authentication scheme. That is, they must
the WWW-Authenticate, Authentication-Info and Authorization
untouched. If a proxy wants to authenticate a client before a
is forwarded to the server, it can be done using the Proxy
Authenticate and Proxy-Authorization headers described in section 3.6
below

3.4 Security Protocol

It is useful for a server to be able to know which security schemes
client is capable of handling

It is possible that a server may want to require Digest as
authentication method, even if the server does not know that
client supports it. A client is encouraged to fail gracefully if
server specifies only authentication schemes it cannot handle

3.5

The following example assumes that an access-protected document
being requested from the server via a GET request. The URI of
document is "http://www.nowhere.org/dir/index.html". Both client
server know that the username for this document is "Mufasa", and
password is "Circle Of Life" (with one space between each of
three words).

The first time the client requests the document, no
header is sent, so the server responds with

HTTP/1.1 401
WWW-Authenticate:
realm="testrealm@host.com",
qop="auth,auth-int",
nonce="dcd98b7102dd2f0e8b11d0f600bfb0c093",
opaque="5ccc069c403ebaf9f0171e9517f40e41"

The client may prompt the user for the username and password,
which it will respond with a new request, including the
Authorization header





Franks, et al. Standards Track [Page 18]

RFC 2617 HTTP Authentication June 1999


Authorization: Digest username="Mufasa",
realm="testrealm@host.com",
nonce="dcd98b7102dd2f0e8b11d0f600bfb0c093",
uri="/dir/index.html",
qop=auth
nc=00000001,
cnonce="0a4f113b",
response="6629fae49393a05397450978507c4ef1",
opaque="5ccc069c403ebaf9f0171e9517f40e41"

3.6 Proxy-Authentication and Proxy-

The digest authentication scheme may also be used for
users to proxies, proxies to proxies, or proxies to origin servers
use of the Proxy-Authenticate and Proxy-Authorization headers.
headers are instances of the Proxy-Authenticate and Proxy
Authorization headers specified in sections 10.33 and 10.34 of
HTTP/1.1 specification [2] and their behavior is subject
restrictions described there. The transactions for
authentication are very similar to those already described.
receiving a request which requires authentication, the proxy/
must issue the "407 Proxy Authentication Required" response with
"Proxy-Authenticate" header. The digest-challenge used in
Proxy-Authenticate header is the same as that for the WWW
Authenticate header as defined above in section 3.2.1.

The client/proxy must then re-issue the request with a Proxy
Authorization header, with directives as specified for
Authorization header in section 3.2.2 above

On subsequent responses, the server sends Proxy-Authentication-
with directives the same as those for the Authentication-Info
field

Note that in principle a client could be asked to authenticate
to both a proxy and an end-server, but never in the same response

4 Security

4.1 Authentication of Clients using Basic

The Basic authentication scheme is not a secure method of
authentication, nor does it in any way protect the entity, which
transmitted in cleartext across the physical network used as
carrier. HTTP does not prevent additional authentication schemes
encryption mechanisms from being employed to increase security or
addition of enhancements (such as schemes to use one-time passwords
to Basic authentication



Franks, et al. Standards Track [Page 19]

RFC 2617 HTTP Authentication June 1999


The most serious flaw in Basic authentication is that it results
the essentially cleartext transmission of the user's password
the physical network. It is this problem which Digest
attempts to address

Because Basic authentication involves the cleartext transmission
passwords it SHOULD NOT be used (without enhancements) to
sensitive or valuable information

A common use of Basic authentication is for identification
-- requiring the user to provide a user name and password as a
of identification, for example, for purposes of gathering
usage statistics on a server. When used in this way it is tempting
think that there is no danger in its use if illicit access to
protected documents is not a major concern. This is only correct
the server issues both user name and password to the users and
particular does not allow the user to choose his or her own password
The danger arises because naive users frequently reuse a
password to avoid the task of maintaining multiple passwords

If a server permits users to select their own passwords, then
threat is not only unauthorized access to documents on the server
also unauthorized access to any other resources on other systems
the user protects with the same password. Furthermore, in
server's password database, many of the passwords may also be users
passwords for other sites. The owner or administrator of such
system could therefore expose all users of the system to the risk
unauthorized access to all those sites if this information is
maintained in a secure fashion

Basic Authentication is also vulnerable to spoofing by
servers. If a user can be led to believe that he is connecting to
host containing information protected by Basic authentication when
in fact, he is connecting to a hostile server or gateway, then
attacker can request a password, store it for later use, and feign
error. This type of attack is not possible with
Authentication. Server implementers SHOULD guard against
possibility of this sort of counterfeiting by gateways or
scripts. In particular it is very dangerous for a server to
turn over a connection to a gateway. That gateway can then use
persistent connection mechanism to engage in multiple
with the client while impersonating the original server in a way
is not detectable by the client

4.2 Authentication of Clients using Digest

Digest Authentication does not provide a strong
mechanism, when compared to public key based mechanisms, for example



Franks, et al. Standards Track [Page 20]

RFC 2617 HTTP Authentication June 1999


However, it is significantly stronger than (e.g.) CRAM-MD5, which
been proposed for use with LDAP [10], POP and IMAP (see RFC 2195
[9]). It is intended to replace the much weaker and even
dangerous Basic mechanism

Digest Authentication offers no confidentiality protection
protecting the actual password. All of the rest of the request
response are available to an eavesdropper

Digest Authentication offers only limited integrity protection
the messages in either direction. If qop=auth-int mechanism is used
those parts of the message used in the calculation of the WWW
Authenticate and Authorization header field response directive
(see section 3.2 above) are protected. Most header fields and
values could be modified as a part of a man-in-the-middle attack

Many needs for secure HTTP transactions cannot be met by
Authentication. For those needs TLS or SHTTP are more
protocols. In particular Digest authentication cannot be used for
transaction requiring confidentiality protection. Nevertheless
functions remain for which Digest authentication is both useful
appropriate. Any service in present use that uses Basic should
switched to Digest as soon as practical

4.3 Limited Use Nonce

The Digest scheme uses a server-specified nonce to seed
generation of the request-digest value (as specified in
3.2.2.1 above). As shown in the example nonce in section 3.2.1,
server is free to construct the nonce such that it may only be
from a particular client, for a particular resource, for a
period of time or number of uses, or any other restrictions.
so strengthens the protection provided against, for example,
attacks (see 4.5). However, it should be noted that the
chosen for generating and checking the nonce also has performance
resource implications. For example, a server may choose to
each nonce value to be used only once by maintaining a record
whether or not each recently issued nonce has been returned
sending a next-nonce directive in the Authentication-Info
field of every response. This protects against even an
replay attack, but has a high cost checking nonce values, and
more important will cause authentication failures for any
requests (presumably returning a stale nonce indication). Similarly
incorporating a request-specific element such as the Etag value for
resource limits the use of the nonce to that version of the
and also defeats pipelining. Thus it may be useful to do so
methods with side effects but have unacceptable performance for
that do not



Franks, et al. Standards Track [Page 21]

RFC 2617 HTTP Authentication June 1999


4.4 Comparison of Digest with Basic

Both Digest and Basic Authentication are very much on the weak end
the security strength spectrum. But a comparison between the
points out the utility, even necessity, of replacing Basic by Digest

The greatest threat to the type of transactions for which
protocols are used is network snooping. This kind of
might involve, for example, online access to a database whose use
restricted to paying subscribers. With Basic authentication
eavesdropper can obtain the password of the user. This not
permits him to access anything in the database, but, often worse
will permit access to anything else the user protects with the
password

By contrast, with Digest Authentication the eavesdropper only
access to the transaction in question and not to the user's password
The information gained by the eavesdropper would permit a
attack, but only with a request for the same document, and even
may be limited by the server's choice of nonce

4.5 Replay

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

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

For applications where no possibility of replay attack can
tolerated the server can use one-time nonce values which will not
honored for a second use. This requires the overhead of the



Franks, et al. Standards Track [Page 22]

RFC 2617 HTTP Authentication June 1999


remembering which nonce values have been used until the nonce time
stamp (and hence the digest built with it) has expired, but
effectively protects against replay attacks

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

4.6 Weakness Created by Multiple Authentication

An HTTP/1.1 server may return multiple challenges with a 401
(Authenticate) response, and each challenge may use a
auth-scheme. A user agent MUST choose to use the strongest auth
scheme it understands and request credentials from the user
upon that challenge

Note that many browsers will only recognize Basic and will
that it be the first auth-scheme presented. Servers should
include Basic if it is minimally acceptable

When the server offers choices of authentication schemes using
WWW-Authenticate header, the strength of the resulting
is only as good as that of the of the weakest of the
schemes. See section 4.8 below for discussion of particular
scenarios that exploit multiple authentication schemes

4.7 Online dictionary

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

The server can mitigate this attack by not allowing users to
passwords that are in a dictionary









Franks, et al. Standards Track [Page 23]

RFC 2617 HTTP Authentication June 1999


4.8 Man in the

Both Basic and Digest authentication are vulnerable to "man in
middle" (MITM) attacks, for example, from a hostile or
proxy. Clearly, this would present all the problems of eavesdropping
But it also offers some additional opportunities to the attacker

A possible man-in-the-middle attack would be to add a
authentication scheme to the set of choices, hoping that the
will use one that exposes the user's credentials (e.g. password).
this reason, the client should always use the strongest scheme
it understands from the choices offered

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

User agents should consider measures such as presenting a
indication at the time of the credentials request of
authentication scheme is to be used, or remembering the
authentication scheme ever requested by a server and produce
warning message before using a weaker one. It might also be a
idea for the user agent to be configured to demand
authentication in general, or from specific sites

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

4.9 Chosen plaintext

With Digest authentication, a MITM or a malicious server
arbitrarily choose the nonce that the client will use to compute
response. This is called a "chosen plaintext" attack. The ability
choose the nonce is known to make cryptanalysis much easier [8].

However, no way to analyze the MD5 one-way function used by
using chosen plaintext is currently known

The countermeasure against this attack is for clients to
configured to require the use of the optional "cnonce" directive
this allows the client to vary the input to the hash in a way
chosen by the attacker



Franks, et al. Standards Track [Page 24]

RFC 2617 HTTP Authentication June 1999


4.10 Precomputed dictionary

With Digest authentication, if the attacker can execute a
plaintext attack, the attacker can precompute the response for
common words to a nonce of its choice, and store a dictionary
(response, password) pairs. Such precomputation can often be done
parallel on many machines. It can then use the chosen
attack to acquire a response corresponding to that challenge,
just look up the password in the dictionary. Even if most
are not in the dictionary, some might be. Since the attacker gets
pick the challenge, the cost of computing the response for
password on the list can be amortized over finding many passwords.
dictionary with 100 million password/response pairs would take
3.2 gigabytes of disk storage

The countermeasure against this attack is to for clients to
configured to require the use of the optional "cnonce" directive

4.11 Batch brute force

With Digest authentication, a MITM can execute a chosen
attack, and can gather responses from many users to the same nonce
It can then find all the passwords within any subset of
space that would generate one of the nonce/response pairs in a
pass over that space. It also reduces the time to find the
password by a factor equal to the number of nonce/response
gathered. This search of the password space can often be done
parallel on many machines, and even a single machine can search
subsets of the password space very quickly -- reports exist
searching all passwords with six or fewer letters in a few hours

The countermeasure against this attack is to for clients to
configured to require the use of the optional "cnonce" directive

4.12 Spoofing by Counterfeit

Basic Authentication is vulnerable to spoofing by
servers. If a user can be led to believe that she is connecting to
host containing information protected by a password she knows,
in fact she is connecting to a hostile server, then the
server can request a password, store it away for later use, and
an error. This type of attack is more difficult with
Authentication -- but the client must know to demand that
authentication be used, perhaps using some of the
described above to counter "man-in-the-middle" attacks. Again,
user can be helped in detecting this attack by a visual indication
the authentication mechanism in use with appropriate guidance
interpreting the implications of each scheme



Franks, et al. Standards Track [Page 25]

RFC 2617 HTTP Authentication June 1999


4.13 Storing

Digest authentication requires that the authenticating agent (
the server) store some data derived from the user's name and
in a "password file" associated with a given realm. Normally
might contain pairs consisting of username and H(A1), where H(A1)
the digested value of the username, realm, and password as
above

The security implications of this are that if this password file
compromised, then an attacker gains immediate access to documents
the server using this realm. Unlike, say a standard UNIX
file, this information need not be decrypted in order to
documents in the server realm associated with this file. On the
hand, decryption, or more likely a brute force attack, would
necessary to obtain the user's password. This is the reason that
realm is part of the digested data stored in the password file.
means that if one Digest authentication password file is compromised
it does not automatically compromise others with the same
and password (though it does expose them to brute force attack).

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

A second consequence of this is that the realm string should
unique among all realms which any single user is likely to use.
particular a realm string should include the name of the host
the authentication. The inability of the client to authenticate
server is a weakness of Digest Authentication

4.14

By modern cryptographic standards Digest Authentication is weak.
for a large range of purposes it is valuable as a replacement
Basic Authentication. It remedies some, but not all, weaknesses
Basic Authentication. Its strength may vary depending on
implementation. In particular the structure of the nonce (which
dependent on the server implementation) may affect the ease
mounting a replay attack. A range of server options is
since, for example, some implementations may be willing to accept
server