Repository navigation
Guard Kestrel method hash against non-ASCII starts - #70301
Merged
Merged
Conversation
hoyosjs
requested review from
BrennanConroy,
SamMonoRT and
halter73
as code owners
November 4, 2026 10:41
Contributor
There was a problem hiding this comment.
🔵 Needs a closer look
The required frozen head/base source bundle and independent guide-worker results were not supplied, leaving full review gates unverified despite local inspection of the changes.
No open issues 🎉
What changed in this PR
Fixes #70300 by guarding Kestrel’s known-method hash lookup against non-ASCII first characters. Malformed methods now reach the existing validation path instead of throwing an indexing exception, with no public API changes.
Changes:
- Require an ASCII first character before hashing eligible method strings.
- Add seven unit cases covering affected lengths and the upper UTF-16 boundary.
- Add HTTP/2 and HTTP/3 regression tests using UTF-8 headers to check normal stream-level rejection.
| File | Description |
|---|---|
src/Servers/Kestrel/test/InMemory.FunctionalTests/Http3/Http3StreamTests.cs |
Tests HTTP/3 rejection of non-ASCII method starts. |
src/Servers/Kestrel/test/InMemory.FunctionalTests/Http2/Http2StreamTests.cs |
Tests HTTP/2 rejection of non-ASCII method starts. |
src/Servers/Kestrel/Core/test/HttpUtilitiesTest.cs |
Verifies non-ASCII starts return HttpMethod.Custom. |
src/Servers/Kestrel/Core/src/Internal/Infrastructure/HttpUtilities.cs |
Adds the ASCII guard before method hashing. |
Review effort: Balanced
BrennanConroy
approved these changes
Nov 9, 2026
hoyosjs
temporarily deployed
to
copilot-pat-pool
November 10, 2026 09:56 — with
GitHub Actions
Inactive
hoyosjs
temporarily deployed
to
copilot-pat-pool
November 10, 2026 09:56 — with
GitHub Actions
Inactive
hoyosjs
temporarily deployed
to
copilot-pat-pool
November 10, 2026 09:57 — with
GitHub Actions
Inactive
hoyosjs
temporarily deployed
to
copilot-pat-pool
November 10, 2026 09:58 — with
GitHub Actions
Inactive
hoyosjs
temporarily deployed
to
copilot-pat-pool
November 10, 2026 09:59 — with
GitHub Actions
Inactive
hoyosjs
temporarily deployed
to
copilot-pat-pool
November 10, 2026 10:00 — with
GitHub Actions
Inactive
Contributor
|
✅ No documentation PR was created. Confidence that documentation is needed: 5% No docs needed. This is an internal bug fix that restores correct handling of malformed HTTP methods, with no documented behavior change. Documentation surfaces considered
|
hoyosjs
temporarily deployed
to
copilot-pat-pool
November 10, 2026 10:00 — with
GitHub Actions
Inactive
This branch was previously 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.
Guard Kestrel's method hash against non-ASCII starts
Skip the known-method hash lookup for non-ASCII first characters.
Description
GetKnownMethod(string)hashes 3-7-character methods before HTTP/2 and HTTP/3 validate token characters. Indexing the 256-entry hash table with a leading U+0100 or higher throwsIndexOutOfRangeException.Check
char.IsAscii(value[0])before hashing so malformed methods reach the existing custom-method validator. No public API changes.Regression coverage checks every affected length and the upper UTF-16 boundary, plus real UTF-8 HPACK/QPACK HEADERS at lengths 3 and 7. All seven unit cases and all four protocol cases fail without the fix in Release and pass with it in Debug and Release.
Fixes #70300
Validation
Parser checks: 200 passed in each configuration. Protocol method checks: 19 passed in each configuration. No failures or skips. Changed-file formatting checks and
git diff --checkpassed.Exact test commands (all passed)
Run from the repository root after
. .\activate.ps1.Validation uses the in-memory HTTP/2 and HTTP/3 protocol boundary, not external network clients. The full Kestrel suite was not run.