Skip to content

fix(middleware): accept gzip bodies exactly at the size limit - #3136

Closed
Shubham-Padkonde wants to merge 1 commit into
labstack:masterfrom
Shubham-Padkonde:fix/decompress-exact-size-limit
Closed

Shubham-Padkonde wants to merge 1 commit into
labstack:masterfrom
Shubham-Padkonde:fix/decompress-exact-size-limit

Conversation

@Shubham-Padkonde

Copy link
Copy Markdown
Contributor

When a gzip body has exactly MaxDecompressedSize bytes, reading once more currently returns HTTP 413 instead of EOF. This can reject a valid body even though it stays within the configured limit.

Probe for one more decompressed byte after reaching the limit. EOF remains successful, while actual excess data returns 413 and subsequent reads retain that error. Empty reads do not consume the probe.

Added regressions using real gzip streams for the exact boundary and repeated reads after exceeding it. The exact-boundary regression fails before the fix.

Validation: go test ./... -count=1 and go vet ./... pass on Windows; go test -race ./... passes on Ubuntu.

@vishr

vishr commented Oct 22, 2026

Copy link
Copy Markdown
Member

Thank you @Shubham-Padkonde. Your decompression boundary correction has been incorporated with attribution into the security fixes merged in 1855061 and backported to v4 in 3fb0ba7. The tests cover exactly-at-limit bodies and persistent overflow errors. Closing this PR as incorporated; the v5.4.1 and v4.16.1 releases are being prepared.

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.

2 participants