Repository navigation
fix(http2): harden Http2Client request/response validation and unread body backpressure - #2108
Conversation
89b043d to
fa273c1
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
|
| File | Coverage |
|---|---|
| pkgs/http2/lib/src/connection.dart | 💚 88 % ⬆️ 0 % |
| pkgs/http2/lib/src/http2_client.dart | 💔 86 % ⬇️ 3 % |
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 skip-coverage-check.
9ab395a to
60b9a13
Compare
acb7cd6 to
28d2a01
Compare
185389e to
cb11393
Compare
cb11393 to
6cf77bf
Compare
6cf77bf to
4e75e5e
Compare
c3907ff to
b23e2dc
Compare
05cce28 to
0b4df9c
Compare
… body backpressure Validate outbound request URLs, methods, and headers before dialing and bracket IPv6 literals in :authority (RFC 9113 §8.3.1, RFC 3986 §3.2.2); require a valid :status response header, ignore 1xx and trailer headers when building StreamedResponse.headers, reject DATA before :status, and pause unread response bodies until listened to; and keep full pooled connections alive across single-stream resets.
0b4df9c to
24f2332
Compare
Note
This PR was generated by an AI coding agent (Jetski) on behalf of @mosuem.
Summary
Hardens
Http2Client(package:http2/client.dart) across four areas::authoritybracketing: Validates URL authority, HTTP method token, and request header names/values before dialing (rejecting:-prefixed pseudo-header injection, CR/LF/NUL/CTLs, andtevalues other thantrailers, and stripping fields nominated byConnection), and encloses IPv6 literals in square brackets ([::1]:port) in:authorityand pool keys.:status(100..599, excluding101), ignores1xxinformational headers instead of merging them intoStreamedResponse.headers, ignores trailingHEADERSinstead of mutatingresponseHeaders, rejectsDATAarriving before:status, and resets the stream on protocol errors.response.streamis listened to, preventing an unreadStreamedResponsefrom auto-grantingWINDOW_UPDATEs up to 4 MiB and buffering unboundedDATAinsidebodyController.ClientConnection.isAlive): Distinguishes a dead/finishing connection from one that is merely at itsSETTINGS_MAX_CONCURRENT_STREAMScapacity so a single-streamRST_STREAMon a full connection does not poison and evict the connection fromClientPool.Why this is right
:authorityuses URIhost [ ":" port ]syntax, where IPv6 literals MUST be enclosed in[and](whereasDart'sUri.hostreturns bare::1without brackets).:status;1xxresponses are interim and do not carry final response header fields;DATAframes MUST NOT precede the final response header section.WINDOW_UPDATE) should only advance as the receiver consumes data, and a stream error (RST_STREAM) affects only that stream, not healthy sibling streams on a full connection.Changes
lib/src/http2_client.dart— Outbound header/URL/IPv6 validation, strict response state machine, unread-body subscription pause untilonListen, and!connection.isAlivecheck.lib/src/connection.dart,test/pool_mocks.mocks.dart— AddClientConnection.isAlive.test/http2_client_test.dart,CHANGELOG.md— Add four end-to-end TLS tests and3.2.1-wipchangelog entry.Test Verification (Fails Before → Passes After)
Before fix:
After fix:
Full
package:http2suite at this point of the stack:+303 ~7: All tests passed!(dart formatanddart analyze --fatal-infosare clean.)Stack
Stacked on #2107. Followed by #2109, optional draft #2110, and #2111 (prepare to release 3.2.1).