Repository navigation
Ignore Content-Length when sending a chunked request body - #369
Merged
mame merged 1 commit intoNov 26, 2026
Merged
Conversation
Sending both Content-Length and Transfer-Encoding: chunked on a request is a request-smuggling primitive (RFC 9112 6.1): a desync proxy may frame the two differently. When a caller sets both, Net::HTTP now drops Content-Length and sends only the chunked framing (in the body-stream and multipart/form-data chunked paths; the plain-body path already removed Transfer-Encoding). Reported at https://hackerone.com/reports/3777378
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.
Sending both
Content-LengthandTransfer-Encoding: chunkedon a request is a request-smuggling primitive (RFC 9112 §6.1): a desyncing intermediary can frame the two differently.Net::HTTPlets a caller set both, and on the body-stream and chunkedmultipart/form-datapaths it then wrote both headers on the wire.This drops
Content-Lengthwhenever the body is sent chunked, so only the chunk framing is emitted (the plain-body path already removedTransfer-Encoding). This matches the behavior agreed with the net-http maintainer in the report below.Reported via HackerOne #3777378 (Reported-by: Hierax).
Includes a regression test: a chunked request with a caller-set
Content-Lengthmust not putContent-Lengthon the wire (it fails before this change, passes after).