git/list[1] front-page[2] threads[3] people[4] search[5] about
 

Re: [PATCH] imap-send: increase command size limit

From
Jeff King <peff@peff.net>
Date
Apr 15, 2024, 18:55 UTC
Message-ID
<20240415185530.GB1709228@coredump.intra.peff.net>
In-Reply-To
<7026075c-db4e-4d43-bbd1-d2edb52da9b7@web.de>
On Sun, Apr 14, 2024 at 06:47:52PM +0200, René Scharfe wrote:
Show 5 quoted lines
> While 1KB is plenty for user names, passwords and mailbox names,
> there's no point in limiting our commands like that.  Call xstrvfmt()
> instead of open-coding it and use strbuf to format the command to
> send, as we need its length.  Fail hard if it exceeds INT_MAX, because
> socket_write() can't take more than that.

Hmm. I applaud your attention to detail, but this INT_MAX thing is ugly. ;) Shouldn't socket_write() just use size_t / ssize_t?

In particular, this made me wonder what we would do for larger items. Like, say, the actual message to be uploaded. And indeed, we use a strbuf to read in the messages and pass the whole buffer for each to socket_write(). So we'd possibly quietly truncate such a message.

Fixing it is a little more complicated than switching to size_t, because the underlying SSL_write() uses an int. So we'd probably need some looping, similar to xwrite().

In practice I doubt this is ever an issue. 2GB emails are not likely to be usable in general. And I kind of doubt that this is a reasonable vector for attacks, since the inputs to imap-send would generally come from the user themselves (and certainly truncating the attack message is probably not that interesting, though I imagine one could convince write_in_full() to do an out-of-bounds read as a size_t becomes a negative int which becomes a large size_t again).

So I am happy enough with this (especially given my general opinions of imap-send in the first place).

-Peff
Previous: René ScharfeNext: René Scharfe
Message 6 of 8 in “imap-send: increase command size limit”
  1. imap-send: increase command size limitRené Scharfe, Apr 14, 2024
  2. brian m. carlsonApr 14, 2024
  3. Junio C HamanoApr 15, 2024
  4. Jeff KingApr 15, 2024
  5. René ScharfeApr 16, 2024
  6. Jeff KingApr 15, 2024
  7. René ScharfeApr 16, 2024
  8. Jeff KingApr 17, 2024

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.