RFC 7888
IMAP4 Non-synchronizing Literals
RFC 7888: IMAP4 Non-synchronizing Literals β¨
Okay bestie, let's do the paperwork first ππ
- Who: A. Melnikov, Ed. from Isode Ltd, published under the Internet Engineering Task Force (IETF) πΈ
- Number and date: RFC 7888, dated May 2016 π¦
- Category: Standards Track, and the ISSN is 2070-1721 π
- Obsoletes: RFC 2088. This is the replacement, so RFC 2088 is out β¨
- Updates: nothing is listed under updates π
Abstract
Okay so the Internet Message Access Protocol (RFC 3501) has this "literal" thing, a syntax construct for sending strings π§ Right now, when a client sends a literal to a server, IMAP makes it sit and wait for the server to send a command continuation request after it sends the octet count and before the string data. Lowkey annoying, right? π This document defines an alternate kind of literal that skips that whole network round trip π
This document specifies 2 IMAP extensions: LITERAL+ and LITERAL- π LITERAL+ lets the alternate literal form show up in all IMAP commands. LITERAL- is basically the same as LITERAL+, except it only allows the alternate form when the literal is 4096 bytes or less π
This document obsoletes RFC 2088.
Status of This Memo
Bestie, this part is giving official π This is an Internet Standards Track document β¨ It's a product of the Internet Engineering Task Force (IETF), it represents the consensus of the IETF community, it got public review, and the Internet Engineering Steering Group (IESG) approved it for publication π«Ά If you want more on Internet Standards, check Section 2 of RFC 5741 π
For the current status, any errata, and how to send feedback, go to http://www.rfc-editor.org/info/rfc7888 π
Copyright Notice
Copyright (c) 2016 IETF Trust and the persons identified as the document authors. All rights reserved π₯
This document is subject to BCP 78 and the IETF Trust's Legal Provisions Relating to IETF Documents (http://trustee.ietf.org/license-info), as they stand on the date this document was published. Please actually read these, because they lay out your rights and restrictions for this document π Code Components pulled out of this document must include the Simplified BSD License text, as described in Section 4.e of the Trust Legal Provisions, and they come without warranty, as described in the Simplified BSD License π
This document may contain material from IETF Documents or IETF Contributions published or made publicly available before November 10, 2008. The people who control the copyright in some of that material may not have given the IETF Trust permission to allow modifications outside the IETF Standards Process. So without an adequate license from those copyright holders, this document may not be modified outside the IETF Standards Process, and derivative works of it may not be created outside the IETF Standards Process π¦ The one exceptions are formatting it for publication as an RFC, or translating it into languages other than English πΈ
Table of Contents
1. Introduction . . . . . . . . . . . . . . . . . . . . . . . . 3
2. Conventions . . . . . . . . . . . . . . . . . . . . . . . . . 3
3. Specification . . . . . . . . . . . . . . . . . . . . . . . . 3
4. Considerations on When to Use and Not to Use Synchronizing
Literals . . . . . . . . . . . . . . . . . . . . . . . . . . 5
5. LITERAL- Capability . . . . . . . . . . . . . . . . . . . . . 5
6. Interaction with BINARY Extension . . . . . . . . . . . . . . 6
7. Interaction with MULTIAPPEND Extension . . . . . . . . . . . 6
8. Formal Syntax . . . . . . . . . . . . . . . . . . . . . . . . 6
9. Security Considerations . . . . . . . . . . . . . . . . . . . 7
10. IANA Considerations . . . . . . . . . . . . . . . . . . . . . 7
11. References . . . . . . . . . . . . . . . . . . . . . . . . . 7
11.1. Normative References . . . . . . . . . . . . . . . . . . 7
11.2. Informative References . . . . . . . . . . . . . . . . . 8
Appendix A. Changes since RFC 2088 . . . . . . . . . . . . . . . 9
Acknowledgments . . . . . . . . . . . . . . . . . . . . . . . . . 9
Author's Address . . . . . . . . . . . . . . . . . . . . . . . . 9
1. Introduction πΈ
The Internet Message Access Protocol [RFC3501] has the "literal" syntactic construct for communicating strings β¨ When a client sends a literal to a server, IMAP requires the client to wait for the server to send a command continuation request between sending the octet count and the string data. This document specifies an alternate form of literal that does not require this network round trip, so no more waiting, bestie π
This document specifies 2 IMAP extensions: LITERAL+ and LITERAL- π LITERAL+ allows the alternate form of literals (called "non-synchronized literals" below) in all IMAP commands. LITERAL- is the same as LITERAL+, but it disallows the alternate form of literals unless they are 4096 bytes or less π§
2. Conventions π
The key words "MUST", "MUST NOT", "REQUIRED", "SHALL", "SHALL NOT", "SHOULD", "SHOULD NOT", "RECOMMENDED", "MAY", and "OPTIONAL" in this document are to be interpreted as described in [RFC2119] π«Ά
In examples, "C:" and "S:" mark lines sent by the client and server, respectively π¦ If a single "C:" or "S:" label covers multiple lines, the line breaks between them are just for editorial clarity and are not part of the actual protocol exchange π
3. Specification β¨
Okay so the non-synchronizing literal is added as an alternate form of literal, and it can show up in communication from client to server in place of the IMAP [RFC3501] form of literal π§ The IMAP form, used from client to server, is called a synchronizing literal π The non-synchronizing literal form MUST NOT be sent from server to client π ββοΈ
Non-synchronizing literals can be used with any IMAP server implementation that returns "LITERAL+" or "LITERAL-" as one of its supported capabilities in response to the CAPABILITY command πΈ If the server doesn't advertise either of those capabilities, the client can only use synchronizing literals π The difference between LITERAL+ and LITERAL- is explained in Section 5 π
The non-synchronizing literal is different from the original synchronizing literal because it has a plus ('+') between the octet count and the closing brace ('}') π The server doesn't generate a command continuation request for a non-synchronizing literal, and clients are not required to wait before sending the octets of one π¦
The protocol receiver of an IMAP server MUST check the end of every received line (a sequence of octets that ends with a CRLF) for an open brace ('{') followed by an octet count, a plus ('+'), and a close brace ('}') immediately before the CRLF π If the receiver finds that sequence, it's the octet count of a non-synchronizing literal, and the server MUST treat the specified number of following octets and the following line (as defined in [RFC3501]) as part of the same command π«Ά
It's really important to note that the literal is not delimited by CRLF π₯ It ends after the number of bytes given by the octet count, and the current command just continues from there. There might be a CRLF right after it, which ends the command. Or there might be more octets specifying other command parameters before the CRLF π If a SP (space) character is needed between parameters, the SP has to go after the literal, in its proper place π
A server MAY still process commands and reject errors on a line-by-line basis, as long as it checks for non-synchronizing literals at the end of each line β¨
Example:
C: A001 LOGIN {11+}
C: FRED FOOBAR {7+}
C: fat man
S: A001 OK LOGIN completed
This is semantically equivalent to this version that uses quoted strings instead of literals:
C: A001 LOGIN "FRED FOOBAR" "fat man"
S: A001 OK LOGIN completed
Note that the space after FOOBAR in the first version corresponds to the space between the two quoted strings in the second π
4. Considerations on When to Use and Not to Use Synchronizing Literals π§
Understanding this section is important for both client and server developers of this IMAP extension, so pay attention, bestie π
Non-synchronizing literals have clear perks for clients, like being simple to use, but they can be trickier to handle on the server side π€ When a client uses a non-synchronizing literal that's too big for the server to accept, a server implementation that complies with LITERAL+ has to pick between a couple of non-optimal choices:
- Read the number of bytes specified in the non-synchronizing literal, and reject the command that included the literal anyway. (The server is allowed to send the tagged BAD/NO response before reading the whole non-synchronizing literal.) This is pretty wasteful of bandwidth if the literal is large π
- Send an untagged BYE response explaining why the literal was rejected (possibly with an ALERT response code in another response), and then close the connection. This forces the client to reconnect or report the error to the user. In the latter case, the error probably won't make sense to the user. Also, some naive clients are known to blindly reconnect in this situation and repeat the operation that caused the problem, which creates an infinite loop π
The problem above is most common with the APPEND command, because most commands don't need to send lots of data from client to server π¦ Some server implementations put limits on literals (both synchronizing and non-synchronizing) accepted from clients to defend against denial-of-service attacks. Implementations can generally set much lower literal size limits for all commands other than APPEND πΈ To fix the literal size issue in APPEND, this document introduces a new extension, LITERAL-, described in Section 5 π
The situation can also get better by supporting the APPENDLIMIT extension [RFC7889]. That lets a server advertise its APPEND limit, so well-behaved clients can check it and avoid uploading big messages in the first place π
5. LITERAL- Capability π
Okay, LITERAL- is almost identical to LITERAL+, with one exception: when LITERAL- is advertised, non-synchronizing literals used in any command MUST NOT be larger than 4096 bytes π
ββοΈ Any literal larger than 4096 bytes MUST be sent as a synchronizing literal, as specified in RFC 3501 π₯ A server that complies with LITERAL- and runs into a non-synchronizing literal larger than 4096 bytes handles it as described in Section 4 π§ If it's responding to an APPEND command, the tagged BAD response MUST contain the TOOBIG response code [RFC4469] π If it's responding with an untagged BYE response, it SHOULD include the TOOBIG response code π«Ά Note that the form of the non-synchronizing literal doesn't change: it still uses the "+" in the literal itself, even if the applicable extension is LITERAL- π
Because LITERAL- is a more restricted version of LITERAL+, IMAP servers MUST NOT advertise both of these capabilities at the same time π (A server implementation can choose to have a configuration option that indicates which one to advertise π)
6. Interaction with BINARY Extension β¨
okay so [RFC4466] tweaked the literal8 non-terminal from [RFC3516] so it can use non-synchronizing literals, but only when the server supports BINARY [RFC3516] AND LITERAL+ π
this doc says the same literal8 upgrade also works when the server supports BINARY [RFC3516] AND LITERAL- π so the two combos are lowkey twins
7. Interaction with MULTIAPPEND Extension π¦
[RFC3502] explains MULTIAPPEND and how it plays with LITERAL+ πΈ good news: LITERAL- works with MULTIAPPEND in exactly the same way, no extra drama π
8. Formal Syntax π
the grammar below is written in ABNF [ABNF] notation, so that's the language we're speaking π§
anything that gets referenced but isn't defined here comes from [RFC3501], no need to reinvent the wheel bestie π
literal = "{" number ["+"] "}" CRLF *CHAR8
; Number represents the number of CHAR8 octets
CHAR8 = <defined in RFC 3501>
literal8 = <defined in RFC 4466>
9. Security Considerations π
okay this part is serious, so listen up π«Ά non-synchronizing literals eat up extra resources on IMAP servers, like memory, and attackers can totally use them for denial-of-service attacks π LITERAL- made that situation better, but only partially π
the good news is this document doesn't add any new security worries on top of what [RFC3501] already covers π₯
10. IANA Considerations π
so IMAP4 capabilities get registered by publishing a Standards Track or IESG-approved Experimental RFC π the registry lives at <http://www.iana.org/assignments/imap-capabilities> β¨
IANA already updated the registry so the "LITERAL+" entry points to this document π
and IANA added a brand new "LITERAL-" capability to that registry, with this document as its reference π
11. References π¦
11.1. Normative References π
[ABNF] Crocker, D., Ed. and P. Overell, "Augmented BNF for Syntax
Specifications: ABNF", STD 68, RFC 5234,
DOI 10.17487/RFC5234, January 2008,
<http://www.rfc-editor.org/info/rfc5234>.
[RFC2119] Bradner, S., "Key words for use in RFCs to Indicate
Requirement Levels", BCP 14, RFC 2119,
DOI 10.17487/RFC2119, March 1997,
<http://www.rfc-editor.org/info/rfc2119>.
[RFC3501] Crispin, M., "INTERNET MESSAGE ACCESS PROTOCOL - VERSION
4rev1", RFC 3501, DOI 10.17487/RFC3501, March 2003,
<http://www.rfc-editor.org/info/rfc3501>.
[RFC3516] Nerenberg, L., "IMAP4 Binary Content Extension", RFC 3516,
DOI 10.17487/RFC3516, April 2003,
<http://www.rfc-editor.org/info/rfc3516>.
[RFC4466] Melnikov, A. and C. Daboo, "Collected Extensions to IMAP4
ABNF", RFC 4466, DOI 10.17487/RFC4466, April 2006,
<http://www.rfc-editor.org/info/rfc4466>.
[RFC4469] Resnick, P., "Internet Message Access Protocol (IMAP)
CATENATE Extension", RFC 4469, DOI 10.17487/RFC4469, April
2006, <http://www.rfc-editor.org/info/rfc4469>.
11.2. Informative References πΈ
[RFC3502] Crispin, M., "Internet Message Access Protocol (IMAP) -
MULTIAPPEND Extension", RFC 3502, DOI 10.17487/RFC3502,
March 2003, <http://www.rfc-editor.org/info/rfc3502>.
[RFC7889] SrimushnamBoovaraghamoorthy, J. and N. Bisht, "The IMAP
APPENDLIMIT Extension", RFC 7889, DOI 10.17487/RFC7889,
May 2016, <http://www.rfc-editor.org/info/rfc7889>.
Appendix A. Changes since RFC 2088 π§
here's the tea on what changed β
- added IANA registration π
- updated references, and also refreshed the stuff about how IMAP extensions interact π
- added implementation considerations based on the IMAP mailing list discussions π¬
- added a description of a brand new capability: LITERAL- π
Acknowledgments π«Ά
John G. Myers edited the original LITERAL+ extension, so big thanks to him π
valuable comments came in from Dave Cridland, Michael M. Slusarz, Arnt Gulbrandsen, Jayantheesh SrimushnamBoovaraghamoorthy, Jamie Nicolson, Barry Leiba, and SM, both the "yes, love it" and the "hmm, not so sure" kind, and that's what makes a spec good π
Author's Address π
Alexey Melnikov (editor)
Isode Ltd
14 Castle Mews
Hampton, Middlesex TW12 2NP
United Kingdom
Email: Alexey.Melnikov@isode.com
π¦ where this page comes from
- ietf: rfc7888 2016-05
- π girlified by claude-haiku-5-5 on : a language model's rewrite of the original, under its terms