Skip to content

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

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

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.
@seanmonstar

Copy link
Copy Markdown
Member

Being realistic here, I don't think we will continue to backport fixes. 0.4 came out 3 years ago, and each backport costs us time, besides the exact patch work.

@seanmonstar seanmonstar closed this Sep 8, 2026
@Sruhvx-jpg

Copy link
Copy Markdown
Author

aight np sir

JanZachmann added a commit to omnect/omnect-ui that referenced this pull request Oct 6, 2026
… listener (#129)

## Summary

### UI fixes for Vuetify 4
- `OverlaySpinner`: use `location="center center"` on `v-overlay`. The
spinner (reboot, factory reset, update) is centered again.
- Replace the MD2 typography classes (`text-h4`, `text-h5`, `text-h6`,
`text-subtitle-1/2`, `text-body-1/2`, `text-caption`) with the MD3 names
from the Vuetify upgrade guide (`text-headline-large`,
`text-headline-small`, `text-title-large`, `text-body-large`,
`text-title-small`, `text-body-medium`, `text-body-small`). Two test
selectors that used `.text-h4` are updated.
- `useAsyncAction`: watch success and error messages with `flush:
'sync'`. The reboot and factory reset dialogs now close and stop loading
after the request.

### Rust dependency updates
- All compatible updates (`cargo update`), among them actix-web 4.15,
actix-http 3.18, rustls 0.23.45, tokio 1.53, time 0.3.55.
- Major updates: crux_core / crux_http 0.20, crux_time 0.18, argon2 0.6,
jsonwebtoken 11, serde_valid 3, actix-files 0.7, actix-multipart 0.8,
mockall 0.15, base64 0.23.
- crux_http 0.20: `HttpError::Http.body` is no longer an `Option`; the
error body is read with `HttpError::body()` / `body_json()`. A test
response with a 5xx status can no longer be built as `Ok(Response)`, so
the 503 test is replaced by tests of `map_http_error` with
`crux_http::testing::rejection`.
- argon2 0.6: `hash_password` creates the salt itself (`getrandom`
feature). A new test checks that a hash created by argon2 0.5 still
validates, so stored device passwords keep working after the update.

### HTTPS listener without HTTP/2
- The UI listener is built from `actix-server` +
`actix_http::HttpService::rustls_0_23` instead of
`HttpServer::bind_rustls_0_23`, and actix-web's `rustls-0_23` feature is
removed. The UI is served over HTTP/1.1 only, and `h2` is no longer in
the build. Workers, client disconnect timeout and graceful shutdown
match the previous `HttpServer` setup. A TODO in `main.rs` names the
condition to go back to `bind_rustls_0_23`.

### Version
- Bump to 1.2.6.

## Reason

On a device, starting a factory reset showed the overlay at the bottom
left of the page, the text in plain body size, and the factory reset
dialog stayed open with a loading button behind the overlay.

- Vuetify 4 positions overlay content by the `location` prop (default
`bottom`), so the `align-center justify-center` classes no longer center
it.
- Vuetify 4 removed the MD2 typography classes, so all headers and
labels using them fell back to the default text size.
- The global message watcher in `App.vue` shows the toast and clears the
message. It runs before the watcher in `useAsyncAction`, which then only
saw `null` and never called `onSuccess`/`onError`. A sync watcher sees
the message before it is cleared. The factory reset e2e test now checks
that the dialog closes.

The dependency updates clear RUSTSEC-2026-0285 (rustls) and the yanked
`chacha20` / `spin` versions.

RUSTSEC-2026-0258 (`h2` 0.3.27, DoS via empty DATA frames) cannot be
fixed by an update: it is fixed only in h2 0.4.16+, actix-http 3.x still
depends on h2 0.3, and h2 does not backport fixes to 0.3
(hyperium/h2#948). actix-web's `rustls-0_23` feature always enables
HTTP/2, so the server offered it over ALPN and the advisory applied.
Upstream tracks the h2 0.4 move in actix/actix-web#4199. HTTP/1.1 only
has no real cost for a local device UI; the WebSocket already used
HTTP/1.1.

Not fixed by this PR:
- RUSTSEC-2023-0071 (`rsa`, via `jsonwebtoken`): no fixed version.
- `getrandom` stays at 0.3: crux_http 0.20 still pulls in `rand` 0.9 →
`getrandom` 0.3, which needs our `wasm_js` feature for the WASM build.
- `bincode` / `proc-macro-error` (unmaintained): still pulled in by
crux.

---------

Signed-off-by: Jan Zachmann <[email protected]>
cameronraysmith pushed a commit to cameronraysmith/ic that referenced this pull request Nov 20, 2026
…e (RUSTSEC-2026-0258) (dfinity#12193)

Removes h2 0.3.27 from both lock files by turning off actix-web's
`http2` feature. The daily RustSec job
(`.github/workflows/rust-advisories.yml`, e.g. [run
44535761188](https://github.com/dfinity/ic/actions/runs/44535761188))
reports h2 0.3.27 with RUSTSEC-2026-0258:
- h2 accepts and queues empty DATA frames without limit.
- If a stream is not drained, the peer can make memory grow without
bound, or cause a panic once the length overflows.
- The advisory rates it low severity.

**Why h2 0.3 can't be updated:**
- h2 0.3 has no fixed release; the 0.4 line is fixed from 0.4.16. A 0.3
backport (hyperium/h2#948) was closed unmerged.
- Our other h2 users (hyper, tonic, reqwest, hickory-net) are on 0.4.20.
- h2 0.3 comes only from actix-http's optional `http2` feature, and
actix-http has no release on h2 0.4. actix/actix-web#4199 asks for one,
and moving to h2 0.4 also means moving actix-http from http 0.2 to http
1.

**Who uses actix-web:**
- ICP Rosetta uses it directly.
- rosetta-core, which ICRC Rosetta also uses, pulls it in through
actix-web-prom, which enables only actix-web's `macros` feature.
- Only ICP Rosetta runs an actix-web server. ICRC Rosetta serves with
axum.

# Behaviour change: ICP Rosetta serves HTTP/1.x only

- ICP Rosetta's server listens on plain TCP (`HttpServer::bind`),
without TLS.
- Since actix-web 4.19, a plaintext listener also accepts cleartext
HTTP/2 (h2c) by default when the `http2` feature is on.
- dfinity#12177 moved actix-web from 4.13 (Cargo) and 4.9 (Bazel) to 4.20. So
ICP Rosetta built from master since then accepts h2c, and with it
reaches h2 0.3.
- Without the feature it accepts HTTP/1.x only, as every released ICP
Rosetta did. A client that starts with the HTTP/2 preface now gets a 400
from the HTTP/1 parser.
- The last release, 2.1.10 (2026-07-01), predates dfinity#12177, and Rosetta
images are only published by the manual Rosetta Release workflow. So no
published image ever accepted h2c, and the CHANGELOG needs no entry.
- Released images do link h2 0.3.27, but can't reach it. Image scanners
will keep flagging it until the next ICP Rosetta release.
- No client in the repo talks to ICP Rosetta over HTTP/2. Its clients
use plain reqwest over `http://`, which speaks HTTP/1.1.

FYI @dfinity/defi, who own `rs/rosetta-api`.

# Changes

- `Cargo.toml` and `bazel/rust.MODULE.bazel`: remove `http2` from
actix-web's features.
- **Locks:**
- In both lock sets only h2 0.3.27 goes, and the only dependency edge
removed is actix-http's edge to it.
- hyper, tonic, reqwest and hickory-net now list plain `h2` instead of
`h2 0.4.20`, since only one h2 is left.

# Verification

- **Advisories:** I ran the workflow's pinned tools on this branch,
cargo-deny 0.21.0 on `Cargo.lock` and cargo-audit 0.23.0 on
`Cargo.Bazel.toml.lock`. Neither reports RUSTSEC-2026-0258 any more;
three vulnerabilities remain:
  - libsqlite3-sys, fixed in dfinity#12194;
  - rsa 0.9 and crypto-bigint 0.5, which need upstream releases first.
- **Locks:** in the dev container, `cargo update --workspace` reports
"Locking 0 packages". A second `./bin/bazel-pin.sh` reports "Nothing to
repin.", and `bazel mod deps` leaves `MODULE.bazel.lock` unchanged.
- **Build:** `cargo check --all-targets --all-features -p ic-rosetta-api
-p rosetta-core` passes, and the ICP Rosetta binaries build with Bazel.
The Bazel-built binaries contain no h2 0.3 code.
- **Tests:** these pass locally. They exercise HTTP/1.1; nothing tests
that h2c is refused.
  - `//rs/rosetta-api/common/rosetta_core:rosetta_core_unit_tests`;
  - `//rs/rosetta-api/icp:rosetta-api_test`;
- `//rs/rosetta-api/icp:icp_rosetta_system_tests`, which serves the
Rosetta API over HTTP;
-
`//rs/rosetta-api/icp/tests/integration_tests:rosetta-integration_tests/tests_test`.
- **Lint:** CI's Cargo Lint job, which runs `./ci/scripts/rust-lint.sh`,
passes.
- **CI:** before this PR was stacked on dfinity#12191, CI ran every Bazel
target, long tests included, on 419d088 (the same change on top of
375a6af). All 1,163 tests pass, including `icp_rosetta_system_tests`
and the `rosetta_test_local` and `rosetta_neuron_follow_test_local`
system tests.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-authored-by: Claude Opus 5.5 <[email protected]>
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.

2 participants