Repository navigation
fix http2/3 path header ASCII symbols validation - #67109
Merged
Merged
Conversation
…validation Enforce a check for non-ASCII characters in the :path header for HTTP2/HTTP3. HTTP1 is not impacted ---- #### AI description (iteration 1) #### PR Classification Bug fix to enforce ASCII validation for HTTP/2 and HTTP/3 `:path` header processing. #### PR Summary Adds runtime validation for non-ASCII/control characters in the `:path` segment for HTTP/2 and HTTP/3 streams, aborting the stream with a protocol error instead of relying on `Debug.Assert`. - `src/Servers/Kestrel/Core/src/Internal/Http2/Http2Stream.cs`: Replace `Debug.Assert` with explicit ASCII-range check; reset/abort the stream with `PROTOCOL_ERROR` on invalid characters. - `src/Servers/Kestrel/Core/src/Internal/Http3/Http3Stream.cs`: Replace `Debug.Assert` with explicit ASCII-range check; abort the stream with `ProtocolError` on invalid characters. <!-- GitOpsUserAgent=GitOps.Apps.Server.pullrequestcopilot -->
BrennanConroy
approved these changes
Jun 10, 2026
Contributor
There was a problem hiding this comment.
Pull request overview
This PR tightens HTTP/2 and HTTP/3 :path validation in Kestrel to prevent non-ASCII characters from being incorrectly handled during path decoding/normalization, and adds regression tests to ensure the connection/stream is aborted when invalid :path values are received.
Changes:
- Add runtime validation in HTTP/2 and HTTP/3 stream path parsing to reject characters that don’t safely round-trip into the byte buffer used by the path decoder.
- Add HTTP/2 and HTTP/3 functional tests that construct HPACK/QPACK header blocks containing invalid
:pathvalues and assert the stream is reset/aborted with the expected protocol error.
Reviewed changes
Copilot reviewed 4 out of 4 changed files in this pull request and generated 3 comments.
| File | Description |
|---|---|
| src/Servers/Kestrel/test/InMemory.FunctionalTests/Http3/Http3StreamTests.cs | Adds a regression test for invalid non-ASCII :path values sent via QPACK. |
| src/Servers/Kestrel/test/InMemory.FunctionalTests/Http2/Http2StreamTests.cs | Adds a regression test for invalid non-ASCII :path values sent via HPACK. |
| src/Servers/Kestrel/Core/src/Internal/Http3/Http3Stream.cs | Adds runtime rejection of invalid characters while building the path byte buffer. |
| src/Servers/Kestrel/Core/src/Internal/Http2/Http2Stream.cs | Adds runtime rejection of invalid characters while building the path byte buffer. |
Comment on lines
+444
to
+448
| if (ch > byte.MaxValue) | ||
| { | ||
| ResetAndAbort(new ConnectionAbortedException(CoreStrings.FormatHttp2StreamErrorPathInvalid(RawTarget)), Http2ErrorCode.PROTOCOL_ERROR); | ||
| return false; | ||
| } |
Comment on lines
+1222
to
+1226
| if (ch > byte.MaxValue) | ||
| { | ||
| Abort(new ConnectionAbortedException(CoreStrings.FormatHttp3StreamErrorPathInvalid(RawTarget)), Http3ErrorCode.ProtocolError); | ||
| return false; | ||
| } |
Comment on lines
+259
to
+261
| [InlineData("/\u0161dmin?x=1")] // U+0161 (353), truncates to 0x61 = 'a' → "/admin?x=1" | ||
| [InlineData("/\u0170ser")] // U+0170 (368), truncates to 0x70 = 'p' → "/pser" | ||
| [InlineData("/caf\u0165?q=1")] // U+0165 (357), truncates to 0x65 = 'e' → "/cafe?q=1 |
Member
Author
|
/ba-g unrelated mac failure |
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.
No description provided.