| 1 |
<pre>Network Working Group J. Klensin |
| 2 |
Request for Comments: 2195 R. Catoe |
| 3 |
Category: Standards Track P. Krumviede |
| 4 |
Obsoletes: <a href="./rfc2095">2095</a> MCI |
| 5 |
September 1997 |
| 6 |
|
| 7 |
|
| 8 |
<span class="h1">IMAP/POP AUTHorize Extension for Simple Challenge/Response</span> |
| 9 |
|
| 10 |
Status of this Memo |
| 11 |
|
| 12 |
This document specifies an Internet standards track protocol for the |
| 13 |
Internet community, and requests discussion and suggestions for |
| 14 |
improvements. Please refer to the current edition of the "Internet |
| 15 |
Official Protocol Standards" (STD 1) for the standardization state |
| 16 |
and status of this protocol. Distribution of this memo is unlimited. |
| 17 |
|
| 18 |
Abstract |
| 19 |
|
| 20 |
While IMAP4 supports a number of strong authentication mechanisms as |
| 21 |
described in <a href="./rfc1731">RFC 1731</a>, it lacks any mechanism that neither passes |
| 22 |
cleartext, reusable passwords across the network nor requires either |
| 23 |
a significant security infrastructure or that the mail server update |
| 24 |
a mail-system-wide user authentication file on each mail access. |
| 25 |
This specification provides a simple challenge-response |
| 26 |
authentication protocol that is suitable for use with IMAP4. Since |
| 27 |
it utilizes Keyed-MD5 digests and does not require that the secret be |
| 28 |
stored in the clear on the server, it may also constitute an |
| 29 |
improvement on APOP for POP3 use as specified in <a href="./rfc1734">RFC 1734</a>. |
| 30 |
|
| 31 |
<span class="h2"><a class="selflink" id="section-1" href="#section-1">1</a>. Introduction</span> |
| 32 |
|
| 33 |
Existing Proposed Standards specify an AUTHENTICATE mechanism for the |
| 34 |
IMAP4 protocol [<a href="#ref-IMAP" title=""Internet Message Access Protocol - Version 4rev1"">IMAP</a>, <a href="#ref-IMAP-AUTH" title=""IMAP4 Authentication Mechanisms"">IMAP-AUTH</a>] and a parallel AUTH mechanism for |
| 35 |
the POP3 protocol [<a href="#ref-POP3-AUTH" title=""POP3 AUTHentication command"">POP3-AUTH</a>]. The AUTHENTICATE mechanism is |
| 36 |
intended to be extensible; the four methods specified in [<a href="#ref-IMAP-AUTH" title=""IMAP4 Authentication Mechanisms"">IMAP-AUTH</a>] |
| 37 |
are all fairly powerful and require some security infrastructure to |
| 38 |
support. The base POP3 specification [<a href="#ref-POP3" title=""Post Office Protocol - Version 3"">POP3</a>] also contains a |
| 39 |
lightweight challenge-response mechanism called APOP. APOP is |
| 40 |
associated with most of the risks associated with such protocols: in |
| 41 |
particular, it requires that both the client and server machines have |
| 42 |
access to the shared secret in cleartext form. CRAM offers a method |
| 43 |
for avoiding such cleartext storage while retaining the algorithmic |
| 44 |
simplicity of APOP in using only MD5, though in a "keyed" method. |
| 45 |
|
| 46 |
|
| 47 |
|
| 48 |
|
| 49 |
|
| 50 |
|
| 51 |
|
| 52 |
<span class="grey">Klensin, Catoe & Krumviede Standards Track [Page 1]</span></pre> |
| 53 |
<hr class='noprint'/><!--NewPage--><pre class='newpage'><span id="page-2" ></span> |
| 54 |
<span class="grey"><a href="./rfc2195">RFC 2195</a> IMAP/POP AUTHorize Extension September 1997</span> |
| 55 |
|
| 56 |
|
| 57 |
At present, IMAP [<a href="#ref-IMAP" title=""Internet Message Access Protocol - Version 4rev1"">IMAP</a>] lacks any facility corresponding to APOP. |
| 58 |
The only alternative to the strong mechanisms identified in [IMAP- |
| 59 |
AUTH] is a presumably cleartext username and password, supported |
| 60 |
through the LOGIN command in [<a href="#ref-IMAP" title=""Internet Message Access Protocol - Version 4rev1"">IMAP</a>]. This document describes a |
| 61 |
simple challenge-response mechanism, similar to APOP and PPP CHAP |
| 62 |
[PPP], that can be used with IMAP (and, in principle, with POP3). |
| 63 |
|
| 64 |
This mechanism also has the advantage over some possible alternatives |
| 65 |
of not requiring that the server maintain information about email |
| 66 |
"logins" on a per-login basis. While mechanisms that do require such |
| 67 |
per-login history records may offer enhanced security, protocols such |
| 68 |
as IMAP, which may have several connections between a given client |
| 69 |
and server open more or less simultaneous, may make their |
| 70 |
implementation particularly challenging. |
| 71 |
|
| 72 |
<span class="h2"><a class="selflink" id="section-2" href="#section-2">2</a>. Challenge-Response Authentication Mechanism (CRAM)</span> |
| 73 |
|
| 74 |
The authentication type associated with CRAM is "CRAM-MD5". |
| 75 |
|
| 76 |
The data encoded in the first ready response contains an |
| 77 |
presumptively arbitrary string of random digits, a timestamp, and the |
| 78 |
fully-qualified primary host name of the server. The syntax of the |
| 79 |
unencoded form must correspond to that of an <a href="./rfc822">RFC 822</a> 'msg-id' |
| 80 |
[<a href="./rfc822">RFC822</a>] as described in [<a href="#ref-POP3" title=""Post Office Protocol - Version 3"">POP3</a>]. |
| 81 |
|
| 82 |
The client makes note of the data and then responds with a string |
| 83 |
consisting of the user name, a space, and a 'digest'. The latter is |
| 84 |
computed by applying the keyed MD5 algorithm from [<a href="#ref-KEYED-MD5" title=""HMAC: Keyed-Hashing for Message Authentication"">KEYED-MD5</a>] where |
| 85 |
the key is a shared secret and the digested text is the timestamp |
| 86 |
(including angle-brackets). |
| 87 |
|
| 88 |
This shared secret is a string known only to the client and server. |
| 89 |
The `digest' parameter itself is a 16-octet value which is sent in |
| 90 |
hexadecimal format, using lower-case ASCII characters. |
| 91 |
|
| 92 |
When the server receives this client response, it verifies the digest |
| 93 |
provided. If the digest is correct, the server should consider the |
| 94 |
client authenticated and respond appropriately. |
| 95 |
|
| 96 |
Keyed MD5 is chosen for this application because of the greater |
| 97 |
security imparted to authentication of short messages. In addition, |
| 98 |
the use of the techniques described in [<a href="#ref-KEYED-MD5" title=""HMAC: Keyed-Hashing for Message Authentication"">KEYED-MD5</a>] for precomputation |
| 99 |
of intermediate results make it possible to avoid explicit cleartext |
| 100 |
storage of the shared secret on the server system by instead storing |
| 101 |
the intermediate results which are known as "contexts". |
| 102 |
|
| 103 |
|
| 104 |
|
| 105 |
|
| 106 |
|
| 107 |
|
| 108 |
<span class="grey">Klensin, Catoe & Krumviede Standards Track [Page 2]</span></pre> |
| 109 |
<hr class='noprint'/><!--NewPage--><pre class='newpage'><span id="page-3" ></span> |
| 110 |
<span class="grey"><a href="./rfc2195">RFC 2195</a> IMAP/POP AUTHorize Extension September 1997</span> |
| 111 |
|
| 112 |
|
| 113 |
CRAM does not support a protection mechanism. |
| 114 |
|
| 115 |
Example: |
| 116 |
|
| 117 |
The examples in this document show the use of the CRAM mechanism with |
| 118 |
the IMAP4 AUTHENTICATE command [<a href="#ref-IMAP-AUTH" title=""IMAP4 Authentication Mechanisms"">IMAP-AUTH</a>]. The base64 encoding of |
| 119 |
the challenges and responses is part of the IMAP4 AUTHENTICATE |
| 120 |
command, not part of the CRAM specification itself. |
| 121 |
|
| 122 |
S: * OK IMAP4 Server |
| 123 |
C: A0001 AUTHENTICATE CRAM-MD5 |
| 124 |
S: + PDE4OTYuNjk3MTcwOTUyQHBvc3RvZmZpY2UucmVzdG9uLm1jaS5uZXQ+ |
| 125 |
C: dGltIGI5MTNhNjAyYzdlZGE3YTQ5NWI0ZTZlNzMzNGQzODkw |
| 126 |
S: A0001 OK CRAM authentication successful |
| 127 |
|
| 128 |
In this example, the shared secret is the string |
| 129 |
'tanstaaftanstaaf'. Hence, the Keyed MD5 digest is produced by |
| 130 |
calculating |
| 131 |
|
| 132 |
MD5((tanstaaftanstaaf XOR opad), |
| 133 |
MD5((tanstaaftanstaaf XOR ipad), |
| 134 |
<[email protected]>)) |
| 135 |
|
| 136 |
where ipad and opad are as defined in the keyed-MD5 Work in |
| 137 |
Progress [<a href="#ref-KEYED-MD5" title=""HMAC: Keyed-Hashing for Message Authentication"">KEYED-MD5</a>] and the string shown in the challenge is the |
| 138 |
base64 encoding of <[email protected]>. The |
| 139 |
shared secret is null-padded to a length of 64 bytes. If the |
| 140 |
shared secret is longer than 64 bytes, the MD5 digest of the |
| 141 |
shared secret is used as a 16 byte input to the keyed MD5 |
| 142 |
calculation. |
| 143 |
|
| 144 |
This produces a digest value (in hexadecimal) of |
| 145 |
|
| 146 |
b913a602c7eda7a495b4e6e7334d3890 |
| 147 |
|
| 148 |
The user name is then prepended to it, forming |
| 149 |
|
| 150 |
tim b913a602c7eda7a495b4e6e7334d3890 |
| 151 |
|
| 152 |
Which is then base64 encoded to meet the requirements of the IMAP4 |
| 153 |
AUTHENTICATE command (or the similar POP3 AUTH command), yielding |
| 154 |
|
| 155 |
dGltIGI5MTNhNjAyYzdlZGE3YTQ5NWI0ZTZlNzMzNGQzODkw |
| 156 |
|
| 157 |
|
| 158 |
|
| 159 |
|
| 160 |
|
| 161 |
|
| 162 |
|
| 163 |
|
| 164 |
<span class="grey">Klensin, Catoe & Krumviede Standards Track [Page 3]</span></pre> |
| 165 |
<hr class='noprint'/><!--NewPage--><pre class='newpage'><span id="page-4" ></span> |
| 166 |
<span class="grey"><a href="./rfc2195">RFC 2195</a> IMAP/POP AUTHorize Extension September 1997</span> |
| 167 |
|
| 168 |
|
| 169 |
<span class="h2"><a class="selflink" id="section-3" href="#section-3">3</a>. References</span> |
| 170 |
|
| 171 |
[<a id="ref-CHAP">CHAP</a>] Lloyd, B., and W. Simpson, "PPP Authentication Protocols", |
| 172 |
<a href="./rfc1334">RFC 1334</a>, October 1992. |
| 173 |
|
| 174 |
[<a id="ref-IMAP">IMAP</a>] Crispin, M., "Internet Message Access Protocol - Version |
| 175 |
4rev1", <a href="./rfc2060">RFC 2060</a>, University of Washington, December 1996. |
| 176 |
|
| 177 |
[<a id="ref-IMAP-AUTH">IMAP-AUTH</a>] Myers, J., "IMAP4 Authentication Mechanisms", |
| 178 |
<a href="./rfc1731">RFC 1731</a>, Carnegie Mellon, December 1994. |
| 179 |
|
| 180 |
[<a id="ref-KEYED-MD5">KEYED-MD5</a>] Krawczyk, Bellare, Canetti, "HMAC: Keyed-Hashing for |
| 181 |
Message Authentication", <a href="./rfc2104">RFC 2104</a>, February 1997. |
| 182 |
|
| 183 |
[<a id="ref-MD5">MD5</a>] Rivest, R., "The MD5 Message Digest Algorithm", |
| 184 |
<a href="./rfc1321">RFC 1321</a>, MIT Laboratory for Computer Science, April 1992. |
| 185 |
|
| 186 |
[<a id="ref-POP3">POP3</a>] Myers, J., and M. Rose, "Post Office Protocol - Version 3", |
| 187 |
STD 53, <a href="./rfc1939">RFC 1939</a>, Carnegie Mellon, May 1996. |
| 188 |
|
| 189 |
[<a id="ref-POP3-AUTH">POP3-AUTH</a>] Myers, J., "POP3 AUTHentication command", <a href="./rfc1734">RFC 1734</a>, |
| 190 |
Carnegie Mellon, December, 1994. |
| 191 |
|
| 192 |
<span class="h2"><a class="selflink" id="section-4" href="#section-4">4</a>. Security Considerations</span> |
| 193 |
|
| 194 |
It is conjectured that use of the CRAM authentication mechanism |
| 195 |
provides origin identification and replay protection for a session. |
| 196 |
Accordingly, a server that implements both a cleartext password |
| 197 |
command and this authentication type should not allow both methods of |
| 198 |
access for a given user. |
| 199 |
|
| 200 |
While the saving, on the server, of "contexts" (see <a href="#section-2">section 2</a>) is |
| 201 |
marginally better than saving the shared secrets in cleartext as is |
| 202 |
required by CHAP [<a href="#ref-CHAP" title=""PPP Authentication Protocols"">CHAP</a>] and APOP [<a href="#ref-POP3" title=""Post Office Protocol - Version 3"">POP3</a>], it is not sufficient to |
| 203 |
protect the secrets if the server itself is compromised. |
| 204 |
Consequently, servers that store the secrets or contexts must both be |
| 205 |
protected to a level appropriate to the potential information value |
| 206 |
in user mailboxes and identities. |
| 207 |
|
| 208 |
As the length of the shared secret increases, so does the difficulty |
| 209 |
of deriving it. |
| 210 |
|
| 211 |
While there are now suggestions in the literature that the use of MD5 |
| 212 |
and keyed MD5 in authentication procedures probably has a limited |
| 213 |
effective lifetime, the technique is now widely deployed and widely |
| 214 |
understood. It is believed that this general understanding may |
| 215 |
assist with the rapid replacement, by CRAM-MD5, of the current uses |
| 216 |
of permanent cleartext passwords in IMAP. This document has been |
| 217 |
|
| 218 |
|
| 219 |
|
| 220 |
<span class="grey">Klensin, Catoe & Krumviede Standards Track [Page 4]</span></pre> |
| 221 |
<hr class='noprint'/><!--NewPage--><pre class='newpage'><span id="page-5" ></span> |
| 222 |
<span class="grey"><a href="./rfc2195">RFC 2195</a> IMAP/POP AUTHorize Extension September 1997</span> |
| 223 |
|
| 224 |
|
| 225 |
deliberately written to permit easy upgrading to use SHA (or whatever |
| 226 |
alternatives emerge) when they are considered to be widely available |
| 227 |
and adequately safe. |
| 228 |
|
| 229 |
Even with the use of CRAM, users are still vulnerable to active |
| 230 |
attacks. An example of an increasingly common active attack is 'TCP |
| 231 |
Session Hijacking' as described in CERT Advisory CA-95:01 [CERT95]. |
| 232 |
|
| 233 |
See <a href="#section-1">section 1</a> above for additional discussion. |
| 234 |
|
| 235 |
<span class="h2"><a class="selflink" id="section-5" href="#section-5">5</a>. Acknowledgements</span> |
| 236 |
|
| 237 |
This memo borrows ideas and some text liberally from [<a href="#ref-POP3" title=""Post Office Protocol - Version 3"">POP3</a>] and |
| 238 |
[<a href="./rfc1731">RFC-1731</a>] and thanks are due the authors of those documents. Ran |
| 239 |
Atkinson made a number of valuable technical and editorial |
| 240 |
contributions to the document. |
| 241 |
|
| 242 |
<span class="h2"><a class="selflink" id="section-6" href="#section-6">6</a>. Authors' Addresses</span> |
| 243 |
|
| 244 |
John C. Klensin |
| 245 |
MCI Telecommunications |
| 246 |
800 Boylston St, 7th floor |
| 247 |
Boston, MA 02199 |
| 248 |
USA |
| 249 |
|
| 250 |
EMail: [email protected] |
| 251 |
Phone: +1 617 960 1011 |
| 252 |
|
| 253 |
Randy Catoe |
| 254 |
MCI Telecommunications |
| 255 |
2100 Reston Parkway |
| 256 |
Reston, VA 22091 |
| 257 |
USA |
| 258 |
|
| 259 |
EMail: [email protected] |
| 260 |
Phone: +1 703 715 7366 |
| 261 |
|
| 262 |
Paul Krumviede |
| 263 |
MCI Telecommunications |
| 264 |
2100 Reston Parkway |
| 265 |
Reston, VA 22091 |
| 266 |
USA |
| 267 |
|
| 268 |
EMail: [email protected] |
| 269 |
Phone: +1 703 715 7251 |
| 270 |
|
| 271 |
|
| 272 |
|
| 273 |
|
| 274 |
|
| 275 |
|
| 276 |
Klensin, Catoe & Krumviede Standards Track [Page 5] |
| 277 |
</pre> |