Repository navigation
Answer 400 to a Content-Length that reaches the chunked state bits - #1969
Merged
uNetworkingAB merged 1 commit intoNov 19, 2026
Merged
Conversation
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.
A Content-Length of 2^56 or more is accepted, and the body after the first read is then parsed as chunked encoding. HttpParser keeps the Content-Length in remainingStreamingBytes, whose top 8 bits are the chunked state from ChunkedEncoding.h (STATE_IS_CHUNKED, STATE_EXTENSION_* and so on). toUnsignedInteger allows 18 digits, so
Content-Length: 72057594037927936sets STATE_EXTENSION_IN_NAME, and on the next read isParsingChunkedEncoding() is true.Repro: send
POST / HTTP/1.1\r\nHost: a\r\nContent-Length: 72057594037927936\r\n\r\n, then in a second read0\r\n\r\nGET /admin HTTP/1.1\r\nHost: a\r\n\r\n. For a proxy in front this is one POST with a long body, but uWS ends the POST at the0chunk and dispatchesGET /adminas a second request (request smuggling, RFC 9112 11.2).The fix answers 400 to any Content-Length above STATE_SIZE_MASK (2^56 - 1, about 72 PB), which also covers the UINT64_MAX error value. The check is in the Content-Length branch because that is the only place a fixed length goes into remainingStreamingBytes.
The new test in tests/HttpParser.cpp sends the body in a second read for 2^56 - 1, 2^56 and 999999999999999999. It fails without the fix.