Harden chunked encoding parsing - #68465
Open
Youssef1313 wants to merge 1 commit into
Open
Conversation
Youssef1313
force-pushed
the
dev/ygerges/chunked-encoding-fix
branch
5 times, most recently
from
August 13, 2026 06:02
e128d12 to
462697e
Compare
Youssef1313
force-pushed
the
dev/ygerges/chunked-encoding-fix
branch
4 times, most recently
from
August 13, 2026 09:42
4615157 to
6be36e9
Compare
Youssef1313
marked this pull request as ready for review
August 13, 2026 09:53
Youssef1313
force-pushed
the
dev/ygerges/chunked-encoding-fix
branch
from
August 13, 2026 09:54
6be36e9 to
92da644
Compare
Contributor
There was a problem hiding this comment.
Pull request overview
This PR hardens Kestrel’s HTTP/1.1 chunked transfer-encoding parsing to strictly reject invalid chunk extensions (notably CR/LF inside chunk-ext, including quoted-string cases) per RFC 9110/9112, and updates tests accordingly. It also removes the legacy insecure chunked parsing AppContext switch from the mainline implementation.
Changes:
- Tighten
Http1ChunkedEncodingMessageBodychunk-size and chunk-extension parsing (including stricter token/quoted-string validation and CRLF handling). - Expand/adjust chunked request test coverage for invalid/valid extension forms and boundary splitting.
- Update existing tests’ chunk-extension strings to avoid now-invalid characters (e.g., spaces in tokens).
Reviewed changes
Copilot reviewed 4 out of 4 changed files in this pull request and generated 2 comments.
| File | Description |
|---|---|
| src/Servers/Kestrel/Core/src/Internal/Http/Http1ChunkedEncodingMessageBody.cs | Reworks chunk-size and chunk-ext parsing to be stricter and RFC-aligned (including quoted-string rules). |
| src/Servers/Kestrel/Core/test/MessageBodyTests.cs | Adds new tests for incomplete chunk-extension/value parsing and max hex digit chunk-size parsing. |
| src/Servers/Kestrel/test/InMemory.FunctionalTests/ChunkedRequestTests.cs | Expands valid/invalid chunk extension theory cases; updates extension examples; adjusts RemoteExecutor options. |
| src/Servers/Kestrel/test/InMemory.FunctionalTests/MaxRequestBodySizeTests.cs | Updates chunk-extension strings in payloads to remain valid under stricter parsing. |
💡 Add a code-review agent skill for context-aware, tailored reviews. Learn more in the docs.
Youssef1313
force-pushed
the
dev/ygerges/chunked-encoding-fix
branch
from
August 13, 2026 11:45
92da644 to
ff7097f
Compare
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.
Fixes #66794