parser: bound datagram body allocation by message size - #343
Open
Mliviu79 wants to merge 1 commit into
Open
Conversation
Owner
|
pls remove comments. It is clear what is issue here. We solved this on streaming, not sure why I missed this. |
The non-stream Parse path took the declared Content-Length straight into make([]byte, bodySize) with only a negative-value guard. On a 64-bit build a small unauthenticated datagram declaring a body of up to the uint32 maximum (~4.29 GB) drove that allocation before the trailing copy could reject the message: a pre-auth memory-amplification DoS on the UDP and WebSocket ingress paths, both of which parse through ParseSIP -> Parse(stream=false). The stream parser already bounds the body against MaxMessageLength; the datagram path now does the same, subtracting rather than adding so the check itself cannot overflow int on a 32-bit build. Pre-existing, not introduced here (unrelated file transport_layer.go): TestTransportLayerClientConnectionReuse and TestTransportLayerClientConnection NoReuse fail under -race with data races in the client connection-reuse pool.
Mliviu79
force-pushed
the
pr/parser-datagram-bound
branch
from
August 9, 2026 10:29
3de3153 to
6a3cacc
Compare
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.
Fixes #342
One check, between the
bodySize == 0early return and themake: