Skip to content

Answer 400 to a chunk size that wraps once the CRLF is added - #1970

Open
Shrusti-pk wants to merge 1 commit into
uNetworking:masterfrom
Shrusti-pk:chunk-size-wrap
Open

Shrusti-pk wants to merge 1 commit into
uNetworking:masterfrom
Shrusti-pk:chunk-size-wrap

Conversation

@Shrusti-pk

Copy link
Copy Markdown
Contributor

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 FFFFFFFFFFFFFE therefore becomes a chunk of 0 bytes and FFFFFFFFFFFFFF one 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: with FFFFFFFFFFFFFE\r\n0\r\n\r\nGET /admin HTTP/1.1\r\nHost: a\r\n\r\n as the body, uWS ends the POST at the 0 chunk and dispatches GET /admin as 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 and FFFFFFFFFFFFFD is 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.

This branch has not been deployed

No deployments
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