Stream protocol: fix a crash in parse_command/1 on zero-size frames#15703
Merged
michaelklishin merged 2 commits intorabbitmq:mainfrom Mar 11, 2026
Merged
Stream protocol: fix a crash in parse_command/1 on zero-size frames#15703michaelklishin merged 2 commits intorabbitmq:mainfrom
parse_command/1 on zero-size frames#15703michaelklishin merged 2 commits intorabbitmq:mainfrom
Conversation
Collaborator
|
I copied this patch over to an EC2 I have running with rabbitmq_stream enabled and the logs look much cleaner now: Warning logs...We could probably also clean up the logs around invalid transitions, but that could be done separately from this fix. |
the-mikedavis
approved these changes
Mar 11, 2026
A zero-size frame (a 4-byte header with value 0) causes `parse_command/1` to be called with an empty binary `<<>>`, for which no clause matches, crashing the stream connection process. Add a test case that reproduces the crash by sending the exact 8-byte payload observed in production logs from EC2-hosted brokers.
When a client sends a zero-size frame (e.g. a port scanner sending
`<<0,0,0,0,0,0,0,0>>`), `parse_command/1` is called with an empty
binary `<<>>`. No existing clause matches, causing a `function_clause`
crash that terminates the stream connection process.
Add a catch-all clause that returns `{unknown, Data}` for any binary
that is not a valid request or response frame. This is already a valid
`command()` type and is handled gracefully by all three frame handlers
in `rabbit_stream_reader`: pre-auth closes the connection, post-auth
sends a protocol-level close frame, and post-close ignores it.
830092f to
3510476
Compare
michaelklishin
approved these changes
Mar 11, 2026
parse_command/1 on zero-size framesparse_command/1 on zero-size frames
Collaborator
|
@lukebakken @the-mikedavis thank you! |
the-mikedavis
added a commit
that referenced
this pull request
Mar 11, 2026
Stream protocol: fix a crash in `parse_command/1` on zero-size frames (backport #15703)
lukebakken
pushed a commit
to amazon-mq/upstream-to-rabbitmq-server
that referenced
this pull request
Mar 11, 2026
…ro-bytes Stream protocol: fix a crash in `parse_command/1` on zero-size frames (cherry picked from commit 6443b05)
This was referenced Mar 12, 2026
Closed
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.
When a client sends a zero-size frame — for example, a port scanner sending
<<0,0,0,0,0,0,0,0>>to the TLS-enabled stream listeners port,parse_command/1is called with an empty binary<<>>. No existing clause matches, causing afunction_clausecrash that terminates the stream connection process. This has been observed consistently on EC2-hosted brokers.Add a catch-all clause that returns
{unknown, Data}for any binary that is not a valid request or response frame.{unknown, binary()}is already a validcommand()type and is handled gracefully by all three frame handlers inrabbit_stream_reader: pre-auth closes the connection, post-auth sends a protocol-level close frame withRESPONSE_CODE_UNKNOWN_FRAME, and post-close ignores it.The fix is accompanied by a test that reproduces the exact crash using the 8-byte payload observed in production logs.