fix http/2 header payload padding parsing#65729
Open
DeagleGross wants to merge 2 commits intodotnet:mainfrom
Open
fix http/2 header payload padding parsing#65729DeagleGross wants to merge 2 commits intodotnet:mainfrom
DeagleGross wants to merge 2 commits intodotnet:mainfrom
Conversation
Contributor
There was a problem hiding this comment.
Pull request overview
Fixes HTTP/2 HEADERS frame padding validation in Kestrel so frames with both PADDED and PRIORITY flags correctly account for the extra 5 priority bytes when determining whether padding exceeds the available payload.
Changes:
- Update HEADERS padding-length validation to subtract the correct “extended fields” length (padding + optional priority) before comparing against
PadLength. - Expose
HeadersPayloadOffsetonHttp2Frameto support the updated validation logic. - Add a functional test covering the specific invalid HEADERS payload scenario (PADDED + PRIORITY where padding exceeds remaining payload).
Reviewed changes
Copilot reviewed 3 out of 3 changed files in this pull request and generated 2 comments.
| File | Description |
|---|---|
src/Shared/ServerInfrastructure/Http2/Http2Frame.Headers.cs |
Exposes the computed HEADERS extended-fields offset used for payload/padding calculations. |
src/Servers/Kestrel/Core/src/Internal/Http2/Http2Connection.cs |
Fixes HEADERS padding validation by subtracting the correct offset when PRIORITY is present. |
src/Servers/Kestrel/test/InMemory.FunctionalTests/Http2/Http2ConnectionTests.cs |
Adds regression coverage for invalid PADDED+PRIORITY HEADERS frame padding. |
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.
The padding length check for HTTP/2 HEADERS frames did not account for the extra 5 bytes consumed by the PRIORITY flag (4-byte stream dependency + 1-byte weight).
Kestrel was throwing an exception later instead of validating the bytes properly and rejecting immediately: