🥅 Validate non-synchronizing literals support#701
Merged
nevans merged 3 commits intoJun 9, 2026
Conversation
It's bad behavior to send a non-synchronizing literal that's too large. This forces the server to choose between reading but ignoring the bytes or closing the connection. But, for servers that _don't_ support non-synchronizing literals, this could be another CRLF/command injection attack vector. If a server sees the `}\r\n` but can't parse the literal bytesize, it may decide to close the connection, and all is fine. But, a server _might_ respond to any unparseable command line (ending in `CRLF`) with `BAD`, then interpret the literal as the next command. In that case, a CRLF/command injection could succeed. Fortunately, `LITERAL-` is supported by most IMAP servers. So this is not expected to be widely exploitable.
These tests can raise `Errno::ECONNREST, "Connection reset"` in the server thread. I've only seen it in TruffleRuby (semi-reliably) and MacOS (flaky), but probably it's a timing issue and can happen elsewhere too?
97e8d5d to
0ea9eba
Compare
This was referenced Jun 9, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
It's bad behavior to send a non-synchronizing literal that's too large. This forces the server to choose between reading but ignoring the bytes or closing the connection.
But, for servers that don't support non-synchronizing literals, this could be another CRLF/command injection attack vector. If a server sees the
}\r\nbut can't parse the literal bytesize, it may decide to close the connection, and all is fine. But, a server might respond to any unparseable command line (ending inCRLF) withBAD, then interpret the literal as the next command. In that case, a CRLF/command injection could succeed.Fortunately,
LITERAL-is supported by most modern IMAP servers. So this is not expected to be widely exploitable.