Validate converted HTTP/2 headers and trailers#2275
Merged
hyperxpro merged 3 commits intoJul 25, 2026
Merged
Conversation
HTTP/2 decoding already validates response header names. Rechecking them while converting to HttpHeaders repeats per-character work for every response and trailer. Use a factory that disables only name validation while preserving value validation, including CR/LF rejection. Cover both properties with focused tests. Codex on behalf of Pavel Ptashyts Co-Authored-By: Codex <codex@openai.com>
hyperxpro
requested changes
Jul 25, 2026
Restore complete HTTP token and value validation when converting decoded HTTP/2 headers. Use Netty's trailer-specific factory so prohibited trailing fields cannot reach handlers. Replace capturing copy lambdas with enhanced loops and cover malformed names, values, empty names, and prohibited trailers. Codex on behalf of Pavel Ptashyts Co-Authored-By: Codex <codex@openai.com>
Contributor
Author
|
Addressed all review feedback in 0411239:
The focused tests and the full JDK 11 ./mvnw clean verify pass. |
hyperxpro
requested changes
Jul 25, 2026
Preserve valid trailing headers when a peer sends fields that are prohibited in trailers. Failing the stream at that point discards the trailer section after the response body has already been delivered. Keep full header name and value validation for both response headers and trailers, and cover the distinct conversion rules. Codex on behalf of Pavel Ptashyts Co-Authored-By: Codex <codex@openai.com>
hyperxpro
approved these changes
Jul 25, 2026
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.
Summary
Motivation
The original implementation assumed the HTTP/2 decoder had already performed complete header-name validation. Netty 4.2.15 validates HTTP/2 casing and pseudo-header rules, but it does not enforce the complete HTTP token syntax, and decoded values are not validated by default. Disabling name validation therefore removed the only complete check before headers reached user code.
This revision keeps Netty's normal header validation on both the response and trailer paths, so names are token-checked and values are CR/LF-checked exactly as they were before.
Trailers additionally drop the fields that cannot be processed after the content, matching HttpObjectDecoder.isPermittedTrailingHeader. Dropping rather than rejecting is deliberate. RFC 9110 section 6.5.1 puts the constraint on the sender, and the only recipient-level requirement in that section concerns merging trailers into the header section, which this code does not do. Rejecting would also fail a response whose body has already been delivered to the AsyncHandler, and would make HTTP/2 behave differently from HTTP/1 for the same server response, since HttpObjectDecoder drops these fields silently.
The shared enhanced-for copy path avoids a capturing lambda allocation for each response and trailer frame.
Validation
./mvnw clean verify: build, tests, Javadocs, signing, and Revapi passedAttribution
Codex on behalf of Pavel Ptashyt