Open
Strictly require CRLF when parsing HTTP/1.1 chunked encoding lines#131138
Conversation
|
Azure Pipelines: 16 pipeline(s) were filtered out due to trigger conditions. There may be pipelines that require an authorized user to comment /azp run to run. |
Co-authored-by: MihaZupan <25307628+MihaZupan@users.noreply.github.com>
Co-authored-by: MihaZupan <25307628+MihaZupan@users.noreply.github.com>
Copilot
AI
changed the title
[WIP] Fix parsing of HTTP/1.1 chunked encoding lines
Strictly require CRLF when parsing HTTP/1.1 chunked encoding lines
Jul 21, 2026
Contributor
|
Tagging subscribers to this area: @karelz, @dotnet/ncl |
MihaZupan
reviewed
Jul 21, 2026
Co-authored-by: MihaZupan <25307628+MihaZupan@users.noreply.github.com>
Contributor
Author
Addressed in d3a2545. Updated the Note This comment was created by GitHub Copilot. |
|
Azure Pipelines: Successfully started running 4 pipeline(s). 12 pipeline(s) were filtered out due to trigger conditions. There may be pipelines that require an authorized user to comment /azp run to run. |
MihaZupan
approved these changes
Jul 21, 2026
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.
Per RFC 9112, interpreting a lone
LFasCRLFis only permitted for the status line and headers — chunked encoding data lines must be terminated byCRLF.SocketsHttpHandlerused the same lenient line parsing everywhere, so it accepted loneCRbytes in chunk extensions and a singleLFfor chunk termination.Changes
HttpConnection.TryReadNextChunkedLine: Reworked to strictly requireCRLFfor the chunk size line and chunk terminator. It now locates the firstCR/LFand rejects a bareLF(lone-LF termination) or aCRnot immediately followed byLF(bare CR in size line/extension). TheMaxChunkBytesAllowedlimit and partial-buffer "wait for more data" behavior are unchanged.Strings.resx: Addednet_http_invalid_response_chunk_line_ending, thrown asHttpIOException(InvalidResponse, ...).SocketsHttpHandler_ChunkedEncodingParsing_Testcovering validCRLF(incl. chunk extensions and trailers) and rejection of lone-LF at multiple positions and bare CR in the size line/extension.Scope note
Chunked trailers (after
0\r\n) are parsed by the header parser and remain intentionally lenient per spec; this change only tightens the chunk size line and chunk terminator.Behavioral delta (all valid
CRLFinputs unchanged):4\r\n4\n4;ext\rval\r\n(bare CR in ext)data\nterminator (lone LF)