fix: add MaxHeaderBytes and body size limits to HTTP servers (PILOT-107)#6
Merged
Merged
Conversation
ListenAndServe and pebble-serve: add MaxHeaderBytes (1 MB). pebble-serve: add missing IdleTimeout. All json.NewDecoder(r.Body) calls: wrap with http.MaxBytesReader (w, r.Body, 1<<20) to prevent unbounded request body allocation. Fixes: PILOT-107 — Cosift HTTP server has no request body size limit
Codecov Report❌ Patch coverage is
📢 Thoughts on this report? Let us know! |
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.
What
Adds HTTP server hardening to prevent slowloris and large-body DoS vectors in the cosift HTTP server.
Changes
internal/server/http.go(ListenAndServe): AddedMaxHeaderBytes: 1 << 20cmd/cosift/pebble_serve.go(pebbleHTTP): AddedIdleTimeout: 120sandMaxHeaderBytes: 1 << 20json.NewDecoder(r.Body)calls across both files (10 total): wrapped withhttp.MaxBytesReader(w, r.Body, 1<<20)to enforce a 1 MB body size limitBefore/After
Testing
go build ./...— cleango test -timeout 60s ./...— all 9 packages pass (including internal/server and cmd/cosift)Ticket
Closes PILOT-107