Skip to content

fix(0.3.x): limit excessive amount of small DATA frames (GHSA-q83h-524g-xf6h) - #948

Open
Sruhvx-jpg wants to merge 1 commit into
hyperium:0.3.xfrom
Sruhvx-jpg:fix/backport-data-frame-budget-0.3
Open

fix(0.3.x): limit excessive amount of small DATA frames (GHSA-q83h-524g-xf6h)#948
Sruhvx-jpg wants to merge 1 commit into
hyperium:0.3.xfrom
Sruhvx-jpg:fix/backport-data-frame-budget-0.3

Conversation

@Sruhvx-jpg

Copy link
Copy Markdown

Overview

This is a direct 1:1 backport of @seanmonstar's fix on master across PRs #935, #940, #942, #945, and #946 to the 0.3.x branch to resolve GHSA-q83h-524g-xf6h / RUSTSEC-2026-0258.

No new logic has been invented; this ports the stabilized master implementation (including the EOS exemption, separate empty frame accounting, and auto-scaling connection window budget) directly to 0.3.x to unblock downstream http 0.2 consumers like Actix Web 4 (actix/actix-web#4199).

Changes Backported

  1. Empty non-EOS frames: Discarded immediately after flow-control padding accounting (src/proto/streams/recv.rs). Empty frames are capped separately up to MAX_RECV_EMPTY_DATA_FRAMES (100).
  2. Frame overhead budget: Added Budget tracking to Counts based on DEFAULT_DATA_FRAME_OVERHEAD_THRESHOLD (256B). Small frames consume budget; large frames and consumed frames replenish it.
  3. EOS frames: Final DATA frames carrying END_STREAM do not consume budget as they cannot create unbounded stream overhead.
  4. Auto-scaling budget: Budget scales automatically to (connection_window / 2).max(DEFAULT_DATA_FRAME_BUDGET) and can be configured via Builder::data_frame_budget.
  5. Defense: Exhausting the framing budget terminates the connection with GOAWAY(ENHANCE_YOUR_CALM, "too_many_data_frames").

Validation

  • All unit tests and 0.3.x test suites pass.
  • Added regression tests in tests/h2-tests/tests/stream_states.rs:
    • recv_ignores_empty_data_without_end_stream
    • too_many_empty_data_frames_sends_goaway
    • too_many_padded_empty_data_frames_sends_goaway
    • too_many_small_data_frames_sends_goaway

Problem

HTTP/2 flow control limits DATA payload bytes, but not the framing overhead
from excessive numbers of small frames. A peer could fragment data into many
tiny frames, causing disproportionate memory usage from queued events while
remaining within flow-control windows.

Solution

Backport the framing overhead budget and empty frame handling from master
(hyperium#935, hyperium#940, hyperium#942, hyperium#945, hyperium#946) to the 0.3.x maintenance branch.

Validation

Ran the full test suite and added regression integration tests in stream_states.rs.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant