Repository navigation
Answer 400 to a chunk size that wraps once the CRLF is added - #1970
Open
Shrusti-pk wants to merge 1 commit into
Open
Shrusti-pk wants to merge 1 commit into
Shrusti-pk wants to merge 1 commit into
Conversation
This branch has not been deployed
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.
consumeHexNumber stops a chunk size at 14 hex digits through STATE_SIZE_OVERFLOW, so the size can reach STATE_SIZE_MASK (2^56 - 1). The line end then adds 2 for the chunk data CRLF, the carry lands in STATE_EXTENSION_IN_NAME, and the same branch clears that bit right after. A size of
FFFFFFFFFFFFFEtherefore becomes a chunk of 0 bytes andFFFFFFFFFFFFFFone of 1 byte. A front proxy with 64-bit chunk sizes (nginx accepts up to 2^63 - 1) streams everything after that line as chunk data, but uWS reads it as more chunk lines: withFFFFFFFFFFFFFE\r\n0\r\n\r\nGET /admin HTTP/1.1\r\nHost: a\r\n\r\nas the body, uWS ends the POST at the0chunk and dispatchesGET /adminas a second request (request smuggling, RFC 9112 11.2). #1969 caps the Content-Length that goes into the same state word, and this is the chunk-size path, which that change does not reach. The check rejects a size above STATE_SIZE_MASK - 2 where the digits are accumulated, so all three line-end branches are covered andFFFFFFFFFFFFFDis still accepted.The new test in tests/HttpParser.cpp sends FD, FE, FF and FF with an extension, each followed by a pipelined GET. It fails without the fix. The other unit tests in tests/ and the Http fuzzer (with and without UWS_WITH_PROXY) pass.