Repository navigation
fix(net): limit decompressed webhook response bodies - #2904
Open
pcbeingused33 wants to merge 1 commit into
Open
pcbeingused33 wants to merge 1 commit into
pcbeingused33 wants to merge 1 commit into
Conversation
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.
Limit decoded webhook response bodies to
max_response_size.The dispatcher limits the response stream before creating the gzip reader, then reads the decoded stream without a limit. A highly compressible response can therefore exceed the configured cap in memory and in the response data stored for each delivery attempt.
Apply the same limit when reading the decoded body. This preserves the existing wire-size bound and truncation behavior while also bounding the retained decompressed response.
Testing
Added a regression test using a local HTTP server and the real dispatcher path, with explicit gzip negotiation. It checks identity and gzip responses both below and above a 50 KiB limit. On main, the gzip response expands to 1 MiB and fails the size assertion; with this fix, all four cases pass.
go test ./net -run '^TestDispatcherDoLimitsDecodedResponseBody$' -count=1go test ./net -count=1Compatibility: oversized decoded gzip bodies are now truncated to the configured limit, consistently with identity responses.
AI assistance: this change and regression tests were prepared using Codex.