Repository navigation
Answer 400 to a bare LF in a chunk-size line - #1965
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
RFC 9112 7.1 ends every chunk line in CRLF. consumeHexNumber took a bare LF as the line end after the size and after an unquoted extension, and kept it as extension text inside quotes, so a parser that ends the line only on CRLF, or on any LF, can disagree with uWS on where the chunk data starts.
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.
A chunk-size line is accepted when it ends in a bare LF, but RFC 9112 7.1 ends every chunk line in CRLF. consumeHexNumber has three spots:
5\nhello\r\n5;a=b\nhello\r\n5;a="x\ny"\r\nhello\r\nA parser that ends the line only on CRLF, or on any LF, then disagrees with uWS on where the chunk data starts (RFC 9112 11.2). With
25;a=b\n, 37x, then\r\n0\r\n\r\nGET /admin HTTP/1.1\r\nHost: a\r\n\r\n\r\n0\r\n\r\n, a CRLF-only parser sees one POST with the GET inside the chunk data, and uWS dispatches the GET as a second request.Now only the LF after a CR ends the line, and the two LF branches this leaves dead are removed. The chunk data CRLF and the trailer section (#1950) already answer 400 to a bare LF.
The new test in tests/HttpParser.cpp sends the three forms, a bare LF after the last chunk and two valid extensions, each followed by a pipelined GET. It fails without the fix. The rest of tests/, h1spec, the smoke test and the Http fuzzer pass.