fix: Limit HTTP error response body reads to prevent OOM#4191
Open
evilgensec wants to merge 1 commit intogoogle:masterfrom
Open
fix: Limit HTTP error response body reads to prevent OOM#4191evilgensec wants to merge 1 commit intogoogle:masterfrom
evilgensec wants to merge 1 commit intogoogle:masterfrom
Conversation
alexandear
reviewed
May 7, 2026
alexandear
reviewed
May 7, 2026
CheckResponse and the AcceptedError handler in bareDo both read HTTP error response bodies with no size limit: data, err := io.ReadAll(r.Body) // CheckResponse b, readErr := io.ReadAll(resp.Body) // AcceptedError A server returning a very large error body causes the client to exhaust memory. Wrap both reads with io.LimitReader capped at 1 MiB — sufficient for any real GitHub API error JSON. The webhook payload path already applies a 25 MiB limit in messages.go; this brings the error-response paths into alignment.
192b849 to
499cf82
Compare
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## master #4191 +/- ##
=======================================
Coverage 93.71% 93.71%
=======================================
Files 209 209
Lines 19770 19770
=======================================
Hits 18527 18527
Misses 1046 1046
Partials 197 197 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
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.
Problem
Two paths in
github.goread HTTP error response bodies with no size limit:A server returning a very large error body causes the client process to exhaust memory. The webhook payload path already applies a 25 MiB limit via
io.LimitReaderinmessages.go; the error-response paths had no equivalent guard.Fix
Wrap both reads with
io.LimitReadercapped atmaxErrorBodySize(1 MiB):All existing tests pass.