Skip to content

HTTP 2/3: treat messages containing connection-specific header fields malformed#66669

Merged
DeagleGross merged 4 commits into
dotnet:mainfrom
DeagleGross:dmkorolev/h2/connection-specific-headers
May 15, 2026
Merged

HTTP 2/3: treat messages containing connection-specific header fields malformed#66669
DeagleGross merged 4 commits into
dotnet:mainfrom
DeagleGross:dmkorolev/h2/connection-specific-headers

Conversation

@DeagleGross
Copy link
Copy Markdown
Member

Per RFC 9113 §8.2.2 (HTTP/2) and RFC 9114 §4.2 (HTTP/3), endpoints must treat any message containing connection-specific header fields as malformed. Kestrel's IsConnectionSpecificHeaderField in both Http2Connection and Http3Stream only checked for Connection and TE, missing the other four headers called out by the RFCs.

@DeagleGross DeagleGross self-assigned this May 13, 2026
Copilot AI review requested due to automatic review settings May 13, 2026 11:11
@DeagleGross DeagleGross added the area-networking Includes servers, yarp, json patch, bedrock, websockets, http client factory, and http abstractions label May 13, 2026
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Updates Kestrel’s HTTP/2 and HTTP/3 request header validation to fully enforce RFC 9113 §8.2.2 and RFC 9114 §4.2 by treating messages that include connection-specific header fields as malformed (beyond just connection and invalid te).

Changes:

  • Expanded HTTP/2 and HTTP/3 connection-specific header detection to include transfer-encoding, keep-alive, proxy-connection, and upgrade (while keeping the te: trailers exception).
  • Added functional tests for HTTP/2 and HTTP/3 to validate the new connection-specific header rejection behavior.
Show a summary per file
File Description
src/Servers/Kestrel/test/InMemory.FunctionalTests/Http3/Http3StreamTests.cs Adds theory coverage ensuring HTTP/3 rejects additional connection-specific request headers.
src/Servers/Kestrel/test/InMemory.FunctionalTests/Http2/Http2ConnectionTests.cs Adds theory coverage ensuring HTTP/2 rejects additional connection-specific request headers.
src/Servers/Kestrel/Core/src/Internal/Http3/Http3Stream.cs Extends connection-specific header detection per RFC 9114 §4.2.
src/Servers/Kestrel/Core/src/Internal/Http2/Http2Connection.cs Extends connection-specific header detection per RFC 9113 §8.2.2.

Copilot's findings

  • Files reviewed: 4/4 changed files
  • Comments generated: 0

Comment thread src/Servers/Kestrel/Core/src/Internal/Http2/Http2Connection.cs
@DeagleGross DeagleGross merged commit dda20ca into dotnet:main May 15, 2026
25 checks passed
@DeagleGross DeagleGross deleted the dmkorolev/h2/connection-specific-headers branch May 15, 2026 08:31
@dotnet-policy-service dotnet-policy-service Bot added this to the 11.0-preview5 milestone May 15, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area-networking Includes servers, yarp, json patch, bedrock, websockets, http client factory, and http abstractions

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants