Skip to content

fix(http2): propagate connection backpressure and bound dribble/WINDOW_UPDATE cost - #2106

Open
mosuem wants to merge 1 commit into
masterfrom
mosum/http2-6m-outbound-backpressure-and-dribble
Open

mosuem wants to merge 1 commit into
masterfrom
mosum/http2-6m-outbound-backpressure-and-dribble

Conversation

@mosuem

@mosuem mosuem commented Nov 16, 2026 •

Copy link
Copy Markdown
Member

Note

This PR was generated by an AI coding agent (Jetski) on behalf of @mosuem.

Summary

Fixes three outbound buffering and fragmentation vulnerabilities:

  1. Internal Data Buffering (CVE-2019-9517): StreamMessageQueueOut checked only streamWindow.peerWindowSize before draining all outgoing DataMessages into ConnectionMessageQueueOut._messages and marking stream.outgoingQueue.bufferIndicator unbuffered. A peer advertising a huge SETTINGS_INITIAL_WINDOW_SIZE (2^31 - 1) while withholding connection WINDOW_UPDATEs (or not reading from its TCP socket) caused stream.outgoingMessages.addStream(...) to never pause, buffering arbitrary response data in memory.
  2. Unread WINDOW_UPDATE reply accumulation: FrameWriter.writeWindowUpdate bypassed _writeReplyFrame, so a peer sending DATA frames on a drained stream without reading from the socket could queue WINDOW_UPDATE replies past FrameWriter.maxQueuedReplyFrames.
  3. Quadratic List.sublist copying on Data Dribble (CVE-2019-9511): When an application passed a non-Uint8List List<int> to sendData and a peer granted 1-byte WINDOW_UPDATE increments, viewOrSublist fell back to List.sublist on every byte, copying O(N^2) elements.

Why this is right

Per RFC 9113 §10.5:

Providing tiny increments to flow control in WINDOW_UPDATE frames can cause a sender to generate a large number of DATA frames.
[...]
An attacker can provide large amounts of flow-control credit at the HTTP/2 layer but withhold credit at the TCP layer, preventing frames from being sent. An endpoint that constructs and remembers frames for sending without considering TCP limits might be subject to resource exhaustion.

Propagating ConnectionMessageQueueOut.dataBufferIndicator to StreamMessageQueueOut pauses stream._outgoingCSubscription as soon as the connection send window or underlying transport sink blocks, count-limiting unread WINDOW_UPDATE replies enforces maxQueuedReplyFrames, and normalizing larger non-Uint8List DataMessage payloads once to Uint8List makes every subsequent viewOrSublist slice an O(1) Uint8List.view.

Changes

  • lib/src/flowcontrol/connection_queues.dart, lib/src/flowcontrol/stream_queues.dart, lib/src/streams/stream_handler.dart
    • Expose ConnectionMessageQueueOut.dataBufferIndicator and hold non-empty DataMessages in StreamMessageQueueOut while connection-level sending would buffer, propagating pause/resume signals to stream.outgoingMessages.
  • lib/src/frames/frame_writer.dart
    • Route writeWindowUpdate through _writeReplyFrame.
  • lib/src/flowcontrol/queue_messages.dart
    • Normalize non-Uint8List DataMessage byte lists (length > 64) once into Uint8List.
  • test/server_test.dart, test/src/flowcontrol/stream_queues_test.dart, test/src/flowcontrol/mocks.mocks.dart, CHANGELOG.md
    • Add backpressure, unread-WINDOW_UPDATE, and linear-dribble tests plus 3.2.1-wip changelog entry.

Test Verification (Fails Before → Passes After)

Before fix:

00:00 +0 -1: flowcontrol stream-message-queue-out dribble-fragmentation-is-linear-for-custom-byte-lists [E]
  Expected: <1024>
    Actual: <524799>

00:00 +0 -1: server-tests resource limits propagates connection backpressure to outgoing stream producers [E]
  Expected: a value greater than <0>
    Actual: <0>

00:00 +0 -1: server-tests resource limits terminates a peer that does not read WINDOW_UPDATE replies [E]
  Expected: <Instance of 'TransportConnectionException'> with `errorCode`: <11>
    Actual: <null>

After fix:

00:00 +3: All tests passed!

Full package:http2 suite at this point of the stack: +294 ~7: All tests passed! (dart format and dart analyze --fatal-infos are clean.)

Stack

Stacked on #2105. Followed by #2107–#2110 and #2111 (prepare to release 3.2.1).

@github-actions

github-actions Bot commented Nov 16, 2026 •

Copy link
Copy Markdown

PR Health

Publish ✔️
Package Version Status Publish tag (post-merge)
package:http2 ⭐ 3.2.1-wip WIP (no publish necessary)
  • 1 already published.
  • 8 WIP (no publish necessary).

Documentation at https://github.com/dart-lang/ecosystem/wiki/Publishing-automation.

This check can be disabled by tagging the PR with skip-publish-check.

Changelog Entry ✔️
Package Changed Files

Changes to files need to be accounted for in their respective changelogs.

This check can be disabled by tagging the PR with skip-changelog-check (for example, for non-user-visible changes when the package version is already at -wip).

Breaking changes ✔️
Package Change Current Version New Version Needed Version Looking good?
http2 None 3.2.0 3.2.1-wip 3.2.1-wip ✔️

This check can be disabled by tagging the PR with skip-breaking-check.

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.

Package Leaked API symbol Leaking sources

This check can be disabled by tagging the PR with skip-leaking-check.

Unused Dependencies ✔️
Package Status
http2 ✔️ All dependencies utilized correctly.

For details on how to fix these, see dependency_validator.

This check can be disabled by tagging the PR with skip-unused-dependencies-check.

License Headers ✔️
// Copyright (c) 2026, the Dart project authors. Please see the AUTHORS file
// for details. All rights reserved. Use of this source code is governed by a
// BSD-style license that can be found in the LICENSE file.
Files
no missing headers

All source files should start with a license header.

Unrelated files missing license headers
Files
pkgs/http_multi_server/test/cert.dart

This check can be disabled by tagging the PR with skip-license-check.

Coverage ⚠️
File Coverage
pkgs/http2/lib/src/flowcontrol/connection_queues.dart 💔 93 % ⬇️ 1 %
pkgs/http2/lib/src/flowcontrol/queue_messages.dart 💚 46 % ⬆️ 5 %
pkgs/http2/lib/src/flowcontrol/stream_queues.dart 💔 90 % ⬇️ 0 %
pkgs/http2/lib/src/frames/frame_writer.dart 💚 93 %
pkgs/http2/lib/src/streams/stream_handler.dart 💚 92 % ⬆️ 0 %

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.

@mosuem
mosuem force-pushed the mosum/http2-6m-outbound-backpressure-and-dribble branch 4 times, most recently from c75d1f3 to 9ea8305 Compare November 17, 2026 10:48
@mosuem
mosuem force-pushed the mosum/http2-6m-outbound-backpressure-and-dribble branch from 9ea8305 to 09beab0 Compare November 17, 2026 10:58
@mosuem
mosuem force-pushed the mosum/http2-6m-outbound-backpressure-and-dribble branch 2 times, most recently from 7d9d064 to 7cd9c35 Compare November 18, 2026 11:19
@mosuem
mosuem force-pushed the mosum/http2-6m-outbound-backpressure-and-dribble branch from 7cd9c35 to 1840312 Compare November 18, 2026 12:43
@mosuem
mosuem force-pushed the mosum/http2-6m-outbound-backpressure-and-dribble branch from 1840312 to 4048b49 Compare November 18, 2026 12:53
@mosuem
mosuem force-pushed the mosum/http2-6m-outbound-backpressure-and-dribble branch from 4048b49 to 438a9fb Compare November 18, 2026 12:58
@mosuem
mosuem force-pushed the mosum/http2-6m-outbound-backpressure-and-dribble branch from 438a9fb to 36ef5b9 Compare November 18, 2026 13:57
@mosuem
mosuem force-pushed the mosum/http2-6m-outbound-backpressure-and-dribble branch 2 times, most recently from 78fc4d8 to f22d9f4 Compare November 18, 2026 15:55
@mosuem
mosuem force-pushed the mosum/http2-6m-outbound-backpressure-and-dribble branch 2 times, most recently from 9e9429b to 3de579d Compare November 19, 2026 11:19
Base automatically changed from mosum/http2-6l-control-and-glitch-limits to master November 20, 2026 11:53
…W_UPDATE cost

Propagate connection-level send-window and transport backpressure to
StreamMessageQueueOut so outgoing stream producers pause instead of
buffering unbounded DATA inside ConnectionMessageQueueOut (CVE-2019-9517),
count WINDOW_UPDATE replies toward FrameWriter.maxQueuedReplyFrames, and
normalize larger non-Uint8List DataMessage payloads once so small-window
fragmentation uses O(1) Uint8List views instead of O(N^2) sublist copies
(CVE-2019-9511).
@mosuem
mosuem force-pushed the mosum/http2-6m-outbound-backpressure-and-dribble branch from 3de579d to ff978ae Compare November 20, 2026 11:53
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant