http-netty: document and test HTTP/2 header-name validation#3555
Open
bryce-anderson wants to merge 1 commit into
Open
http-netty: document and test HTTP/2 header-name validation#3555bryce-anderson wants to merge 1 commit into
bryce-anderson wants to merge 1 commit into
Conversation
#### Motivation HTTP/2 header-name validation happens across two layers and is easy to misread. `ServiceTalkHttp2Headers` (the `Http2Headers` wrapper) only enforces the HTTP/2 lower-case rule, while the RFC 7230 token grammar is enforced one layer down by the underlying `HttpHeaders` via `HeaderUtils.validateToken`. Both are gated on the same `HttpHeadersFactory.validateNames()` flag. The split is correct but undocumented, so the wrapper looks like it under-validates when it does not. #### Modifications - Comment-only production changes describing the two-layer split on `ServiceTalkHttp2Headers.HTTP2_NAME_VALIDATOR`, the outbound `validateNames=false` opt-out in `h1HeadersToH2Headers`, and the shared-flag wiring in `OptimizedHttp2FrameCodecBuilder`. No logic changed. - Add `ServiceTalkHttp2HeadersTest`: pins which layer rejects what — the wrapper rejects upper-case, the underlying rejects non-token / non-ASCII names, valid lower-case tokens are accepted, and validation is skipped when disabled. - Add `H2PriorKnowledgeFeatureParityTest.h2ServerResetsStreamForInvalidHeaderName`: a raw peer puts invalid field-names on the wire and the server resets the stream with `PROTOCOL_ERROR`. Extract the existing wire harness into a helper. #### Result The two-layer header-name validation is documented and covered end-to-end, so a future change that weakens either layer is caught by tests.
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.
Motivation
HTTP/2 header-name validation happens across two layers and is easy to misread.
ServiceTalkHttp2Headers(theHttp2Headerswrapper) only enforces the HTTP/2 lower-case rule, while the RFC 7230 token grammar is enforced one layer down by the underlyingHttpHeadersviaHeaderUtils.validateToken. Both are gated on the sameHttpHeadersFactory.validateNames()flag. The split is correct but undocumented, so the wrapper looks like it under-validates when it does not.Modifications
ServiceTalkHttp2Headers.HTTP2_NAME_VALIDATOR, the outboundvalidateNames=falseopt-out inh1HeadersToH2Headers, and the shared-flag wiring inOptimizedHttp2FrameCodecBuilder.ServiceTalkHttp2HeadersTest: pins which layer rejects what — the wrapper rejects upper-case, the underlying rejects non-token / non-ASCII names, valid lower-case tokens are accepted, and validation is skipped when disabled.H2PriorKnowledgeFeatureParityTest.h2ServerResetsStreamForInvalidHeaderName: a raw peer puts invalid field-names on the wire and the server resets the stream withPROTOCOL_ERROR. Extract the existing wire harness into a helper.Result
The two-layer header-name validation is documented and covered end-to-end, so a future change that weakens either layer is caught by tests.