Skip to content

Limit incoming request body size#21

Merged
jenting merged 2 commits into
mainfrom
fix/limit-request-body
Jun 10, 2026
Merged

Limit incoming request body size#21
jenting merged 2 commits into
mainfrom
fix/limit-request-body

Conversation

@jenting

@jenting jenting commented Jun 10, 2026

Copy link
Copy Markdown
Member

Summary

Wraps the request body with http.MaxBytesReader before reading the AdmissionReview, so an oversized or malicious request cannot exhaust server memory. Oversized bodies return 413 Request Entity Too Large.

The limit defaults to 16 MiB and is configurable via the --max-request-body-bytes flag.

Why

io.ReadAll(r.Body) previously had no upper bound. Grafana dashboard CRs can be large, and an AdmissionReview carries both the old and new object, so the cap needs generous headroom to avoid rejecting legitimate updates — hence a 16 MiB default plus a flag for operators to tune.

Testing

  • go build ./...
  • go test ./... — all pass, including a new TestHandleAdmissionReview_BodyTooLarge

🤖 Generated with Claude Code

jenting and others added 2 commits June 11, 2026 06:11
Wrap r.Body with http.MaxBytesReader (3 MiB cap) before reading the
AdmissionReview, so an oversized or malicious request cannot exhaust
server memory. Oversized bodies now return 413 Request Entity Too Large.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Grafana dashboard CRs can be large, and an AdmissionReview carries both the
old and new object, so a fixed 3 MiB cap risked rejecting legitimate updates.
Raise the default to 16 MiB and expose it via the --max-request-body-bytes
flag so operators can tune it for their dashboards.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
@jenting jenting merged commit 6011f48 into main Jun 10, 2026
6 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant