Debian Codegraph @

rfc7888.html

raw
1 <pre>Internet Engineering Task Force (IETF) A. Melnikov, Ed.
2 Request for Comments: 7888 Isode Ltd
3 Obsoletes: <a href="./rfc2088">2088</a> May 2016
4 Category: Standards Track
5 ISSN: 2070-1721
6
7
8 <span class="h1">IMAP4 Non-synchronizing Literals</span>
9
10 Abstract
11
12 The Internet Message Access Protocol (<a href="./rfc3501">RFC 3501</a>) contains the
13 "literal" syntactic construct for communicating strings. When
14 sending a literal from client to server, IMAP requires the client to
15 wait for the server to send a command continuation request between
16 sending the octet count and the string data. This document specifies
17 an alternate form of literal that does not require this network round
18 trip.
19
20 This document specifies 2 IMAP extensions: LITERAL+ and LITERAL-.
21 LITERAL+ allows the alternate form of literals in all IMAP commands.
22 LITERAL- is the same as LITERAL+, but it disallows the alternate form
23 of literals unless they are 4096 bytes or less.
24
25 This document obsoletes <a href="./rfc2088">RFC 2088</a>.
26
27 Status of This Memo
28
29 This is an Internet Standards Track document.
30
31 This document is a product of the Internet Engineering Task Force
32 (IETF). It represents the consensus of the IETF community. It has
33 received public review and has been approved for publication by the
34 Internet Engineering Steering Group (IESG). Further information on
35 Internet Standards is available in <a href="./rfc5741#section-2">Section&nbsp;2 of RFC 5741</a>.
36
37 Information about the current status of this document, any errata,
38 and how to provide feedback on it may be obtained at
39 <a href="http://www.rfc-editor.org/info/rfc7888">http://www.rfc-editor.org/info/rfc7888</a>.
40
41
42
43
44
45
46
47
48
49
50
51
52 <span class="grey">Melnikov 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="./rfc7888">RFC 7888</a> IMAP4 Non-synchronizing Literals May 2016</span>
55
56
57 Copyright Notice
58
59 Copyright (c) 2016 IETF Trust and the persons identified as the
60 document authors. All rights reserved.
61
62 This document is subject to <a href="https://www.rfc-editor.org/bcp/bcp78">BCP 78</a> and the IETF Trust's Legal
63 Provisions Relating to IETF Documents
64 (<a href="http://trustee.ietf.org/license-info">http://trustee.ietf.org/license-info</a>) in effect on the date of
65 publication of this document. Please review these documents
66 carefully, as they describe your rights and restrictions with respect
67 to this document. Code Components extracted from this document must
68 include Simplified BSD License text as described in Section 4.e of
69 the Trust Legal Provisions and are provided without warranty as
70 described in the Simplified BSD License.
71
72 This document may contain material from IETF Documents or IETF
73 Contributions published or made publicly available before November
74 10, 2008. The person(s) controlling the copyright in some of this
75 material may not have granted the IETF Trust the right to allow
76 modifications of such material outside the IETF Standards Process.
77 Without obtaining an adequate license from the person(s) controlling
78 the copyright in such materials, this document may not be modified
79 outside the IETF Standards Process, and derivative works of it may
80 not be created outside the IETF Standards Process, except to format
81 it for publication as an RFC or to translate it into languages other
82 than English.
83
84 Table of Contents
85
86 <a href="#section-1">1</a>. Introduction . . . . . . . . . . . . . . . . . . . . . . . . <a href="#page-3">3</a>
87 <a href="#section-2">2</a>. Conventions . . . . . . . . . . . . . . . . . . . . . . . . . <a href="#page-3">3</a>
88 <a href="#section-3">3</a>. Specification . . . . . . . . . . . . . . . . . . . . . . . . <a href="#page-3">3</a>
89 4. Considerations on When to Use and Not to Use Synchronizing
90 Literals . . . . . . . . . . . . . . . . . . . . . . . . . . <a href="#page-5">5</a>
91 <a href="#section-5">5</a>. LITERAL- Capability . . . . . . . . . . . . . . . . . . . . . <a href="#page-5">5</a>
92 <a href="#section-6">6</a>. Interaction with BINARY Extension . . . . . . . . . . . . . . <a href="#page-6">6</a>
93 <a href="#section-7">7</a>. Interaction with MULTIAPPEND Extension . . . . . . . . . . . <a href="#page-6">6</a>
94 <a href="#section-8">8</a>. Formal Syntax . . . . . . . . . . . . . . . . . . . . . . . . <a href="#page-6">6</a>
95 <a href="#section-9">9</a>. Security Considerations . . . . . . . . . . . . . . . . . . . <a href="#page-7">7</a>
96 <a href="#section-10">10</a>. IANA Considerations . . . . . . . . . . . . . . . . . . . . . <a href="#page-7">7</a>
97 <a href="#section-11">11</a>. References . . . . . . . . . . . . . . . . . . . . . . . . . <a href="#page-7">7</a>
98 <a href="#section-11.1">11.1</a>. Normative References . . . . . . . . . . . . . . . . . . <a href="#page-7">7</a>
99 <a href="#section-11.2">11.2</a>. Informative References . . . . . . . . . . . . . . . . . <a href="#page-8">8</a>
100 <a href="#appendix-A">Appendix A</a>. Changes since <a href="./rfc2088">RFC 2088</a> . . . . . . . . . . . . . . . <a href="#page-9">9</a>
101 Acknowledgments . . . . . . . . . . . . . . . . . . . . . . . . . <a href="#page-9">9</a>
102 Author's Address . . . . . . . . . . . . . . . . . . . . . . . . <a href="#page-9">9</a>
103
104
105
106
107
108 <span class="grey">Melnikov 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="./rfc7888">RFC 7888</a> IMAP4 Non-synchronizing Literals May 2016</span>
111
112
113 <span class="h2"><a class="selflink" id="section-1" href="#section-1">1</a>. Introduction</span>
114
115 The Internet Message Access Protocol [<a href="./rfc3501" title="&quot;INTERNET MESSAGE ACCESS PROTOCOL - VERSION 4rev1&quot;">RFC3501</a>] contains the "literal"
116 syntactic construct for communicating strings. When sending a
117 literal from client to server, IMAP requires the client to wait for
118 the server to send a command continuation request between sending the
119 octet count and the string data. This document specifies an
120 alternate form of literal that does not require this network round
121 trip.
122
123 This document specifies 2 IMAP extensions: LITERAL+ and LITERAL-.
124 LITERAL+ allows the alternate form of literals (called "non-
125 synchronized literals" below) in all IMAP commands. LITERAL- is the
126 same as LITERAL+, but it disallows the alternate form of literals
127 unless they are 4096 bytes or less.
128
129 <span class="h2"><a class="selflink" id="section-2" href="#section-2">2</a>. Conventions</span>
130
131 The key words "MUST", "MUST NOT", "REQUIRED", "SHALL", "SHALL NOT",
132 "SHOULD", "SHOULD NOT", "RECOMMENDED", "MAY", and "OPTIONAL" in this
133 document are to be interpreted as described in [<a href="./rfc2119" title="&quot;Key words for use in RFCs to Indicate Requirement Levels&quot;">RFC2119</a>].
134
135 In examples, "C:" and "S:" indicate lines sent by the client and
136 server, respectively. If a single "C:" or "S:" label applies to
137 multiple lines, then the line breaks between those lines are for
138 editorial clarity only and are not part of the actual protocol
139 exchange.
140
141 <span class="h2"><a class="selflink" id="section-3" href="#section-3">3</a>. Specification</span>
142
143 The non-synchronizing literal is added as an alternate form of
144 literal, and it may appear in communication from client to server
145 instead of the IMAP [<a href="./rfc3501" title="&quot;INTERNET MESSAGE ACCESS PROTOCOL - VERSION 4rev1&quot;">RFC3501</a>] form of literal. The IMAP form of
146 literal, used in communication from client to server, is referred to
147 as a synchronizing literal. The non-synchronizing literal form MUST
148 NOT be sent from server to client.
149
150 Non-synchronizing literals may be used with any IMAP server
151 implementation that returns "LITERAL+" or "LITERAL-" as one of the
152 supported capabilities to the CAPABILITY command. If the server does
153 not advertise either of the above capabilities, the client can only
154 use synchronizing literals. The difference between LITERAL+ and
155 LITERAL- extensions is explained in <a href="#section-5">Section 5</a>.
156
157 The non-synchronizing literal is distinguished from the original
158 synchronizing literal by having a plus ('+') between the octet count
159 and the closing brace ('}'). The server does not generate a command
160
161
162
163
164 <span class="grey">Melnikov 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="./rfc7888">RFC 7888</a> IMAP4 Non-synchronizing Literals May 2016</span>
167
168
169 continuation request in response to a non-synchronizing literal, and
170 clients are not required to wait before sending the octets of a non-
171 synchronizing literal.
172
173 The protocol receiver of an IMAP server MUST check the end of every
174 received line (a sequence of octets that ends with a CRLF) for an
175 open brace ('{') followed by an octet count, a plus ('+'), and a
176 close brace ('}') immediately preceding the CRLF. This sequence (if
177 found by the receiver) is the octet count of a non-synchronizing
178 literal, and the server MUST treat the specified number of following
179 octets and the following line (as defined in [<a href="./rfc3501" title="&quot;INTERNET MESSAGE ACCESS PROTOCOL - VERSION 4rev1&quot;">RFC3501</a>]) as part of
180 the same command.
181
182 It's important to note that the literal is not delimited by CRLF. It
183 ends after the number of bytes specified by the octet count, and the
184 current command continues from there. There might be a CRLF
185 immediately after; it ends the command. Or, there might be more
186 octets, specifying other command parameters, before the CRLF. If a
187 SP (space) character is needed between parameters, it's important
188 that the SP appear after the literal, in its appropriate place.
189
190 A server MAY still process commands and reject errors on a line-by-
191 line basis, as long as it checks for non-synchronizing literals at
192 the end of each line.
193
194 Example:
195
196 C: A001 LOGIN {11+}
197 C: FRED FOOBAR {7+}
198 C: fat man
199 S: A001 OK LOGIN completed
200
201 This is semantically equivalent to this version that uses quoted
202 strings instead of literals:
203
204 C: A001 LOGIN "FRED FOOBAR" "fat man"
205 S: A001 OK LOGIN completed
206
207 Note that the space after FOOBAR in the first version corresponds
208 to the space between the two quoted strings in the second.
209
210
211
212
213
214
215
216
217
218
219
220 <span class="grey">Melnikov 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="./rfc7888">RFC 7888</a> IMAP4 Non-synchronizing Literals May 2016</span>
223
224
225 <span class="h2"><a class="selflink" id="section-4" href="#section-4">4</a>. Considerations on When to Use and Not to Use Synchronizing Literals</span>
226
227 Understanding of this section is important for both client and server
228 developers of this IMAP extension.
229
230 While non-synchronizing literals have clear advantages for clients,
231 such as simplicity of use, they might be more difficult to handle on
232 the server side. When a client uses a non-synchronizing literal that
233 is too big for the server to accept, a server implementation that is
234 compliant with LITERAL+ has to make a choice between a couple non-
235 optimal choices:
236
237 1. Read the number of bytes specified in the non-synchronizing
238 literal and reject the command that included the literal anyway.
239 (The server is allowed to send the tagged BAD/NO response before
240 reading the whole non-synchronizing literal.) This is quite
241 wasteful of bandwidth if the literal is large.
242
243 2. Send an untagged BYE response explaining the reason for rejecting
244 the literal (possibly accompanied by an ALERT response code in
245 another response) and close the connection. This will force the
246 client to reconnect or report the error to the user. In the
247 latter case, the error is unlikely to be understandable to the
248 user. Additionally, some naive clients are known to blindly
249 reconnect in this case and repeat the operation that caused the
250 problem, introducing an infinite loop.
251
252 The problem described above is most common when using the APPEND
253 command, because most commands don't need to send lots of data from
254 the client to the server. Some server implementations impose limits
255 on literals (both synchronizing and non-synchronizing) accepted from
256 clients in order to defend against denial-of-service attacks.
257 Implementations can generally impose much lower limits on literal
258 sizes for all commands other than APPEND. In order to address
259 literal size issue in APPEND, this document introduces a new
260 extension LITERAL-, described in <a href="#section-5">Section 5</a>.
261
262 The situation can also be improved by implementing support for the
263 APPENDLIMIT extension [<a href="./rfc7889" title="&quot;The IMAP APPENDLIMIT Extension&quot;">RFC7889</a>], which allows a server to advertise
264 its APPEND limit, so that well-behaved clients can check it and avoid
265 uploading big messages in the first place.
266
267 <span class="h2"><a class="selflink" id="section-5" href="#section-5">5</a>. LITERAL- Capability</span>
268
269 The LITERAL- extension is almost identical to LITERAL+, with one
270 exception: when LITERAL- is advertised, non-synchronizing literals
271 used in any command MUST NOT be larger than 4096 bytes. Any literal
272 larger than 4096 bytes MUST be sent as a synchronizing literal as
273
274
275
276 <span class="grey">Melnikov Standards Track [Page 5]</span></pre>
277 <hr class='noprint'/><!--NewPage--><pre class='newpage'><span id="page-6" ></span>
278 <span class="grey"><a href="./rfc7888">RFC 7888</a> IMAP4 Non-synchronizing Literals May 2016</span>
279
280
281 specified in <a href="./rfc3501">RFC 3501</a>. A server that is compliant with LITERAL- and
282 encounters a non-synchronizing literal larger than 4096 bytes
283 proceeds as described in <a href="#section-4">Section 4</a>. If responding to an APPEND
284 command, the tagged BAD response MUST contain the TOOBIG response
285 code [<a href="./rfc4469" title="&quot;Internet Message Access Protocol (IMAP) CATENATE Extension&quot;">RFC4469</a>]. If responding with an untagged BYE response, it
286 SHOULD include the TOOBIG response code. Note that the form of the
287 non-synchronizing literal does not change: it still uses the "+" in
288 the literal itself, even if the applicable extension is LITERAL-.
289
290 Because LITERAL- is a more restricted version of LITERAL+, IMAP
291 servers MUST NOT advertise both of these capabilities at the same
292 time. (A server implementation can choose to have a configuration
293 option to indicate which one to advertise.)
294
295 <span class="h2"><a class="selflink" id="section-6" href="#section-6">6</a>. Interaction with BINARY Extension</span>
296
297 [<a id="ref-RFC4466">RFC4466</a>] updated the non-terminal "literal8" defined in [<a href="./rfc3516" title="&quot;IMAP4 Binary Content Extension&quot;">RFC3516</a>] to
298 allow for non-synchronizing literals if both BINARY [<a href="./rfc3516" title="&quot;IMAP4 Binary Content Extension&quot;">RFC3516</a>] and
299 LITERAL+ extensions are supported by the server.
300
301 This document also allows use of this extended "literal8" syntax when
302 both BINARY [<a href="./rfc3516" title="&quot;IMAP4 Binary Content Extension&quot;">RFC3516</a>] and LITERAL- extensions are supported by the
303 server.
304
305 <span class="h2"><a class="selflink" id="section-7" href="#section-7">7</a>. Interaction with MULTIAPPEND Extension</span>
306
307 [<a id="ref-RFC3502">RFC3502</a>] describes MULTIAPPEND extension and how it can be used with
308 LITERAL+. The LITERAL- extension can be used with the MULTIAPPEND
309 extension in the same way.
310
311 <span class="h2"><a class="selflink" id="section-8" href="#section-8">8</a>. Formal Syntax</span>
312
313 The following syntax specification uses the Augmented Backus-Naur
314 Form (ABNF) notation as specified in [<a href="#ref-ABNF" title="&quot;Augmented BNF for Syntax Specifications: ABNF&quot;">ABNF</a>].
315
316 Non-terminals referenced but not defined below are as defined by
317 [<a href="./rfc3501" title="&quot;INTERNET MESSAGE ACCESS PROTOCOL - VERSION 4rev1&quot;">RFC3501</a>].
318
319 literal = "{" number ["+"] "}" CRLF *CHAR8
320 ; Number represents the number of CHAR8 octets
321
322 CHAR8 = &lt;defined in <a href="./rfc3501">RFC 3501</a>&gt;
323
324 literal8 = &lt;defined in <a href="./rfc4466">RFC 4466</a>&gt;
325
326
327
328
329
330
331
332 <span class="grey">Melnikov Standards Track [Page 6]</span></pre>
333 <hr class='noprint'/><!--NewPage--><pre class='newpage'><span id="page-7" ></span>
334 <span class="grey"><a href="./rfc7888">RFC 7888</a> IMAP4 Non-synchronizing Literals May 2016</span>
335
336
337 <span class="h2"><a class="selflink" id="section-9" href="#section-9">9</a>. Security Considerations</span>
338
339 Use of non-synchronizing literals can consume extra resources (e.g.
340 memory) on IMAP servers and can be used for denial-of-service
341 attacks. The LITERAL- extension partially improved this situation.
342
343 This document doesn't raise any security concerns beyond those raised
344 by [<a href="./rfc3501" title="&quot;INTERNET MESSAGE ACCESS PROTOCOL - VERSION 4rev1&quot;">RFC3501</a>].
345
346 <span class="h2"><a class="selflink" id="section-10" href="#section-10">10</a>. IANA Considerations</span>
347
348 IMAP4 capabilities are registered by publishing a Standards Track or
349 IESG-approved Experimental RFC. The registry is currently located at
350 &lt;<a href="http://www.iana.org/assignments/imap-capabilities">http://www.iana.org/assignments/imap-capabilities</a>&gt;.
351
352 IANA has updated the above registry so that the reference for
353 "LITERAL+" points to this document.
354
355 IANA has added the "LITERAL-" capability to the above registry, with
356 this document as the reference.
357
358 <span class="h2"><a class="selflink" id="section-11" href="#section-11">11</a>. References</span>
359
360 <span class="h3"><a class="selflink" id="section-11.1" href="#section-11.1">11.1</a>. Normative References</span>
361
362 [<a id="ref-ABNF">ABNF</a>] Crocker, D., Ed. and P. Overell, "Augmented BNF for Syntax
363 Specifications: ABNF", STD 68, <a href="./rfc5234">RFC 5234</a>,
364 DOI 10.17487/RFC5234, January 2008,
365 &lt;<a href="http://www.rfc-editor.org/info/rfc5234">http://www.rfc-editor.org/info/rfc5234</a>&gt;.
366
367 [<a id="ref-RFC2119">RFC2119</a>] Bradner, S., "Key words for use in RFCs to Indicate
368 Requirement Levels", <a href="https://www.rfc-editor.org/bcp/bcp14">BCP 14</a>, <a href="./rfc2119">RFC 2119</a>,
369 DOI 10.17487/RFC2119, March 1997,
370 &lt;<a href="http://www.rfc-editor.org/info/rfc2119">http://www.rfc-editor.org/info/rfc2119</a>&gt;.
371
372 [<a id="ref-RFC3501">RFC3501</a>] Crispin, M., "INTERNET MESSAGE ACCESS PROTOCOL - VERSION
373 4rev1", <a href="./rfc3501">RFC 3501</a>, DOI 10.17487/RFC3501, March 2003,
374 &lt;<a href="http://www.rfc-editor.org/info/rfc3501">http://www.rfc-editor.org/info/rfc3501</a>&gt;.
375
376 [<a id="ref-RFC3516">RFC3516</a>] Nerenberg, L., "IMAP4 Binary Content Extension", <a href="./rfc3516">RFC 3516</a>,
377 DOI 10.17487/RFC3516, April 2003,
378 &lt;<a href="http://www.rfc-editor.org/info/rfc3516">http://www.rfc-editor.org/info/rfc3516</a>&gt;.
379
380 [<a id="ref-RFC4466">RFC4466</a>] Melnikov, A. and C. Daboo, "Collected Extensions to IMAP4
381 ABNF", <a href="./rfc4466">RFC 4466</a>, DOI 10.17487/RFC4466, April 2006,
382 &lt;<a href="http://www.rfc-editor.org/info/rfc4466">http://www.rfc-editor.org/info/rfc4466</a>&gt;.
383
384
385
386
387
388 <span class="grey">Melnikov Standards Track [Page 7]</span></pre>
389 <hr class='noprint'/><!--NewPage--><pre class='newpage'><span id="page-8" ></span>
390 <span class="grey"><a href="./rfc7888">RFC 7888</a> IMAP4 Non-synchronizing Literals May 2016</span>
391
392
393 [<a id="ref-RFC4469">RFC4469</a>] Resnick, P., "Internet Message Access Protocol (IMAP)
394 CATENATE Extension", <a href="./rfc4469">RFC 4469</a>, DOI 10.17487/RFC4469, April
395 2006, &lt;<a href="http://www.rfc-editor.org/info/rfc4469">http://www.rfc-editor.org/info/rfc4469</a>&gt;.
396
397 <span class="h3"><a class="selflink" id="section-11.2" href="#section-11.2">11.2</a>. Informative References</span>
398
399 [<a id="ref-RFC3502">RFC3502</a>] Crispin, M., "Internet Message Access Protocol (IMAP) -
400 MULTIAPPEND Extension", <a href="./rfc3502">RFC 3502</a>, DOI 10.17487/RFC3502,
401 March 2003, &lt;<a href="http://www.rfc-editor.org/info/rfc3502">http://www.rfc-editor.org/info/rfc3502</a>&gt;.
402
403 [<a id="ref-RFC7889">RFC7889</a>] SrimushnamBoovaraghamoorthy, J. and N. Bisht, "The IMAP
404 APPENDLIMIT Extension", <a href="./rfc7889">RFC 7889</a>, DOI 10.17487/RFC7889,
405 May 2016, &lt;<a href="http://www.rfc-editor.org/info/rfc7889">http://www.rfc-editor.org/info/rfc7889</a>&gt;.
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444 <span class="grey">Melnikov Standards Track [Page 8]</span></pre>
445 <hr class='noprint'/><!--NewPage--><pre class='newpage'><span id="page-9" ></span>
446 <span class="grey"><a href="./rfc7888">RFC 7888</a> IMAP4 Non-synchronizing Literals May 2016</span>
447
448
449 <span class="h2"><a class="selflink" id="appendix-A" href="#appendix-A">Appendix A</a>. Changes since <a href="./rfc2088">RFC 2088</a></span>
450
451 Added IANA registration.
452
453 Updated references. Also updated considerations about interactions
454 of IMAP extensions.
455
456 Added implementation considerations based on the IMAP mailing list
457 discussions.
458
459 Added description of a new capability: LITERAL-.
460
461 Acknowledgments
462
463 John G. Myers edited the original LITERAL+ extension.
464
465 Valuable comments, both in agreement and in dissent, were received
466 from Dave Cridland, Michael M. Slusarz, Arnt Gulbrandsen, Jayantheesh
467 SrimushnamBoovaraghamoorthy, Jamie Nicolson, Barry Leiba, and SM.
468
469 Author's Address
470
471 Alexey Melnikov (editor)
472 Isode Ltd
473 14 Castle Mews
474 Hampton, Middlesex TW12 2NP
475 United Kingdom
476
477 Email: [email protected]
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500 Melnikov Standards Track [Page 9]
501 </pre>