Files
jcoffey-dev b40d4fe999 IMAP and ManageSieve: empty quoted strings count toward the request size
The request size limit counted the bytes of each argument, but an empty
quoted string ("") added a token without counting anything. A client
that sent a command followed by an endless run of "" never reached the
limit, and each pair of quotes added a token to the request held in
memory, about twelve bytes of memory for every byte sent. No sign-in
was needed: the 64 KiB limit before sign-in never tripped, and the idle
timeout doesn't end a connection that keeps sending. One connection to
IMAP (143/993) or ManageSieve (4190) could grow the server's memory
until the whole process was killed.

Now an empty quoted string counts its two quotes, so such a line is
refused with "Request exceeds maximum limit" once it passes the limit,
like any other request.

Found in a security review.

Test: in crates/imap-proto, "a LOGIN " and "CAPABILITY " (the
ManageSieve start state) followed by 100,000 "" with the 64 KiB
pre-sign-in limit buffered 100,000 tokens with no error; now both are
refused at the limit.
2026-11-17 21:36:15 -07:00
..