Repository navigation
fix(http2): validate Host vs :authority, client PUSH_PROMISE, and closed-stream HEADERS - #2109
Conversation
b5694ba to
efccc5c
Compare
efccc5c to
d47ff97
Compare
PR HealthPublish ✔️
Documentation at https://github.com/dart-lang/ecosystem/wiki/Publishing-automation. This check can be disabled by tagging the PR with Changelog Entry ✔️
Changes to files need to be accounted for in their respective changelogs. This check can be disabled by tagging the PR with Breaking changes ✔️
This check can be disabled by tagging the PR with API leaks ✔️The following packages contain symbols visible in the public API, but not exported by the library. Export these symbols or remove them from your publicly visible API.
This check can be disabled by tagging the PR with Unused Dependencies ✔️
For details on how to fix these, see dependency_validator. This check can be disabled by tagging the PR with License Headers ✔️
All source files should start with a license header. Unrelated files missing license headers
This check can be disabled by tagging the PR with Coverage ✔️
This check for test coverage is informational (issues shown here will not fail the PR). This check can be disabled by tagging the PR with |
c5cc703 to
b4d4025
Compare
b4d4025 to
852498a
Compare
080f7f8 to
f868801
Compare
d9a5e89 to
6c960e6
Compare
6c960e6 to
6a758b1
Compare
db9e194 to
e1def35
Compare
892627c to
6ec35bc
Compare
…sed-stream HEADERS Address three RFC 9113 conformance and security issues uncovered by `httpwg-cli`: - Reject `host` in trailers, duplicate `host` headers, userinfo (`@`) in `host` or `http(s)` `:authority`, and `host` vs. `:authority` mismatches after RFC 3986 §6.2.3 scheme-based normalization (RFC 9113 §8.3.1, `H2.Host` request smuggling). - Reject `PUSH_PROMISE` frames on server connections before header defragmentation so incomplete client `PUSH_PROMISE` frames fail immediately with `GOAWAY(PROTOCOL_ERROR)` (RFC 9113 §8.4). - Track recently opened remote stream IDs so `HEADERS` received on an already-closed stream reports `GOAWAY(STREAM_CLOSED)` (RFC 9113 §5.1) while skipped lower stream IDs continue to report `PROTOCOL_ERROR` (RFC 9113 §5.1.1).
6ec35bc to
b3f1595
Compare
Note
This PR was generated by an AI coding agent (Jetski) on behalf of @mosuem.
Summary
Running
httpwg-cli(bearcove/loona's RFC 9113 conformance suite) againstpackage:http2surfaced three remaining RFC 9113 conformance and security issues not covered byh2spec:Hostvs.:authoritymismatch (H2.Hostsmuggling, RFC 9113 §8.3.1): A request carrying both:authorityand ahostheader identifying a different authority (or duplicatehostheaders, or userinfo@) was accepted instead of rejected withRST_STREAM(PROTOCOL_ERROR), creating a routing/origin mismatch if translated to HTTP/1.1 downstream.PUSH_PROMISEbuffered on servers (RFC 9113 §8.4): When a client sent aPUSH_PROMISEframe withoutEND_HEADERS,Connection._handleFrameImplpassed it intoFrameDefragmenterbefore checking!isClientConnection, buffering fragments untilinboundHeaderBlockTimeoutinstead of immediately terminating withGOAWAY(PROTOCOL_ERROR).HEADERSon an already-closed stream reportedPROTOCOL_ERRORinstead ofSTREAM_CLOSED(RFC 9113 §5.1): Re-sendingHEADERSon a previously opened and closed stream ID (<= lastRemoteStreamId) fell through_registerNewRemoteStreamId's genericPROTOCOL_ERRORcheck instead of returningGOAWAY(STREAM_CLOSED).With this PR,
httpwg-clipasses 106 / 107 RFC 9113 tests (up from 57 / 107 in3.1.0and 102 / 107 on #2108; the single remaining test is unsolicitedPING(ACK), whichPingHandlerintentionally treats asPROTOCOL_ERRORperping_handler_test.dart).Why this is right
HEADERSon a stream that transitioned toclosedis a connection error of typeSTREAM_CLOSED(§5.1).HEADERSon a lower unused stream ID that was implicitly skipped when a higher stream ID opened remains a connection error of typePROTOCOL_ERROR(§5.1.1).Changes
lib/src/streams/http_message_validator.darthostin trailers, duplicatehostheaders, userinfo (@) inhostorhttp(s):authority, and requests where scheme-normalizedhostdisagrees with:authority.lib/src/connection.dartPushPromiseFrameon server connections before_defragmenter.tryDefragmentFrame, and mapConnectionStreamClosedExceptiontoGOAWAY(STREAM_CLOSED).lib/src/sync_errors.dart,lib/src/streams/stream_handler.dartLinkedHashSetof recently opened remote stream IDs soHEADERSon an already-closed stream raisesConnectionStreamClosedException(STREAM_CLOSED) while skipped lower stream IDs continue to raiseProtocolException(PROTOCOL_ERROR).test/server_test.dart,CHANGELOG.md3.2.1-wipchangelog entry.Test Verification (Fails Before → Passes After)
Before fix:
After fix:
package:http2suite:+307 ~7: All tests passed!(dart formatanddart analyze --fatal-infosare clean.)httpwg-cli:Passed 106/107 tests in 0.34 seconds!Stack
Stacked on #2108. Followed by optional draft #2110 and #2111 (prepare to release 3.2.1).