Repository navigation
fix(mux-h2): answer stream-scoped errors with RST_STREAM instead of GOAWAY - #1753
Merged
Merged
Conversation
…OAWAY Several errors RFC 9113 scopes to one stream closed the connection and every in-flight stream on it. Reset only the offending stream, and still minimally process its frame (HPACK decoded, DATA credited to the connection window): - DATA or HEADERS on a half-closed (remote) stream: STREAM_CLOSED (§5.1). - HEADERS without END_STREAM in the body phase: PROTOCOL_ERROR (§8.1.1). - PRIORITY frame of length other than 5: FRAME_SIZE_ERROR (§6.3). - Frames on a stream we reset are ignored (§5.1), for the last 256 retired reset streams, kept by H2StreamTable since rst_sent is evicted with the stream. - A self-dependent PRIORITY (RFC 7540 §5.3.1) on an idle stream is dropped: RST_STREAM must not name an idle stream (§6.4). RST_STREAMs still feed the emitted-RST flood accounting and dropped frames count as glitches; thresholds are unchanged. Signed-off-by: Florentin Dubois <[email protected]>
RST_STREAM must not name an idle stream (RFC 9113 §6.4), so the connection error stays the only reply to RFC 7540 §5.3.1 there; h2spec 2.6.0 case 5.3.1/2 expects it. Check rst_sent alone for streams still in the wire map; the bounded ring of retired reset ids is only scanned for closed streams. Document that a dropped HEADERS without END_HEADERS also covers the HEADERS that triggers a stream error, and update the h2spec case count to the 146 cases of h2spec 2.6.0. Signed-off-by: Florentin Dubois <[email protected]>
FlorentinDUBOIS
force-pushed
the
fix/h2-stream-errors-rst
branch
from
October 1, 2026 19:49
8bd24de to
11ac564
Compare
Signed-off-by: Florentin Dubois <[email protected]>
Signed-off-by: Florentin Dubois <[email protected]>
Signed-off-by: Florentin Dubois <[email protected]>
FlorentinDUBOIS
added a commit
that referenced
this pull request
Oct 2, 2026
Resolve the overlap with #1753 in the closed-stream arms of ConnectionH2::handle_frame. Main's HEADERS arm for a stream this endpoint reset (discard the payload, continue) is kept as is. On the DATA arm, the RST_STREAM(STREAM_CLOSED) sent for a stream not reset locally takes this branch's third enqueue_rst argument, RstOrigin::Local: that DATA is already counted as a glitch just above, which bounds it, and charging it to the provoked-RST cap too would count it twice. The old comment's other reason, that such DATA is usually the tail of a stream sozu reset, no longer applies: main now ignores that case before this call. doc/configure.md keeps this branch's flood-threshold rows and main's h2_initial_connection_window default; doc/h2_mux_internals.md citations are re-anchored to the merged code. Signed-off-by: Florentin Dubois <[email protected]>
FlorentinDUBOIS
added a commit
that referenced
this pull request
Oct 2, 2026
Reconcile with #1753, which also ignores frames on a stream this endpoint reset. One path remains: a single read-side branch of handle_header_state, keyed on was_reset_locally (rst_sent or #1753's ring of 256 retired streams, now indexed by a set), ignores DATA and HEADERS on a tracked or retired reset stream through #1753's discard_frame_payload, with this branch's glitch allowances (two header blocks, the stream's receive window of DATA). #1753's live-stream rst_sent check and closed-stream arms, and this branch's handle_data_frame check, are folded into it. discard_field_block keeps the CONTINUATION handling, so a dropped block without END_HEADERS on a reset stream, a stream reset for a stream error or a refused stream is discarded whole. Signed-off-by: Florentin Dubois <[email protected]>
FlorentinDUBOIS
added a commit
that referenced
this pull request
Oct 2, 2026
…andling On a stream Sozu reset, in-flight frames no longer count a flood glitch, and a dropped header block without END_HEADERS is discarded with its CONTINUATION frames instead of ending the connection. Refs #1783 Signed-off-by: Florentin Dubois <[email protected]>
FlorentinDUBOIS
added a commit
that referenced
this pull request
Oct 2, 2026
…UATION of dropped blocks (#1784) Builds on #1753, which made Sōzu ignore frames on a stream it reset (RFC 9113 §5.1). Two problems remained in that handling, and this PR fixes them. - Every ignored frame counted a flood glitch, so a backend connection cancelling a few dozen streams a second, each with DATA in flight, tripped GOAWAY(ENHANCE_YOUR_CALM). What the peer may have had in flight now counts none: two header blocks per reset stream (a trailer section, or an interim and a final response) and DATA within the stream's initial receive window. Each further block, and each DATA frame beyond the window, counts one, so repeated blocks still end the connection; an empty DATA frame without END_STREAM counts toward the empty-DATA flood limit as on a live stream (CVE-2019-9518). The allowances are held for at most 512 reset streams. - A dropped header block without END_HEADERS left its CONTINUATION to be taken for a standalone frame and answered GOAWAY(PROTOCOL_ERROR). This hit blocks on a reset stream, blocks on a stream reset for a stream error, and refused blocks. The CONTINUATION frames are now discarded with the block, which is decoded whole for HPACK (§4.3, §6.10), and its first fragment counts toward `max_header_list_size`. There is one code path for these frames: a single branch of `handle_header_state`, keyed on `H2StreamTable::was_reset_locally`. That covers `rst_sent` plus #1753's ring of 256 retired reset streams, now indexed by a set. The branch discards through #1753's `discard_frame_payload`. #1753's separate live-stream and closed-stream arms are folded into it. Tests (`h2.rs`), each seen failing before its fix: - `frames_on_a_backend_stream_sozu_reset_are_ignored` (trailer in one HEADERS frame or split over CONTINUATION, then a second stream using the dynamic-table entry it added) - `frames_on_a_client_stream_sozu_reset_are_ignored` - `data_on_a_reset_backend_stream_counts_a_glitch_beyond_its_window_only` - `data_on_a_tracked_backend_stream_sozu_reset_is_ignored` - `header_blocks_on_a_reset_backend_stream_beyond_two_count_glitches` - `a_continuation_of_a_refused_header_block_is_discarded_with_it` - `a_refused_header_block_counts_its_first_fragment_toward_its_size` - `empty_data_frames_on_a_reset_backend_stream_count_toward_the_flood_limit` - `reset_stream_allowances_stay_bounded` (`h2_stream_table.rs`) #1753's four e2e tests still pass. Documented in `lib/src/protocol/mux/LIFECYCLE.md`, `doc/h2_mux_internals.md` and `CHANGELOG.md`. Fixes #1783 Signed-off-by: Florentin Dubois <[email protected]>
FlorentinDUBOIS
added a commit
that referenced
this pull request
Oct 2, 2026
…TA is ignored (#1807) The CHANGELOG entry and `lib/src/protocol/mux/LIFECYCLE.md` §8.4 from #1775 said that a trailer HEADERS frame a backend sends after the PROTOCOL_ERROR reset of a 204 or a 304 answers GOAWAY(STREAM_CLOSED) for the whole backend connection "until #1784 lands". #1784 is merged, so this PR checks that claim and rewrites the text. What the test shows: - On `2ce07244` (#1775's head before #1784), a trailer in **one HEADERS frame** was already ignored. The reset-stream branches from #1753 cover it, so the GOAWAY(STREAM_CLOSED) described there did not happen. - What did fail before #1784 was a trailer block **split over a CONTINUATION frame**: the CONTINUATION was taken for a standalone frame and answered GOAWAY(PROTOCOL_ERROR), ending every stream of the backend connection. - On `main`, both are ignored (RFC 9113 §5.1) and the backend connection stays up. Test: `a_trailer_after_the_reset_of_a_204_carrying_data_is_ignored` (`lib/src/protocol/mux/h2.rs`). It sends a 204 without END_STREAM, then DATA without END_STREAM, which is reset with PROTOCOL_ERROR. Then it sends the trailer block, once in one frame and once split over a CONTINUATION frame. For both, it asserts no GOAWAY, no RST_STREAM, and that the backend connection is still in `H2State::Header`. - Red on `2ce07244`: `split=true: ... got [(7, 0, 0, [0, 0, 0, 0, 0, 0, 0, 1])]`. The unsplit row passes there. - Red on this branch with the `pending_discarded_block` store in `ConnectionH2::handle_read` removed, with the same failure. - Green on this branch. Docs: the CHANGELOG entry for #1772 and `LIFECYCLE.md` §8.4 now describe the current behaviour and what changed with #1784, in place of the "until #1784 lands" known limitation. No production code changes. Commands run: - `cargo build --locked --all-features`: ok - `cargo clippy --all-features`: ok - `cargo test --locked --all-features -p sozu-lib --lib`: 1547 passed - `python3 .github/scripts/check_doc_citations.py --root .`: ok, also with `--base origin/main` - `cargo +nightly fmt --all -- --check`: ok `cargo clippy -p sozu-lib --all-targets --all-features -- -D warnings` fails only on the existing `chunks_exact(13)` in `h2.rs` tests, which is already on `main` (`chunks_exact_to_as_chunks`, local clippy 1.99). This PR doesn't touch it. Signed-off-by: Florentin Dubois <[email protected]>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes #1751
Stream-scoped errors in the H2 mux now reset only the offending stream; other streams on the connection carry on.
rst_sent;H2StreamTablealso keeps the last 256 retired reset stream ids, sincerst_sentis evicted with the stream. Frames on a stream closed by END_STREAM in both directions keep their current handling.The dropped frame is still minimally processed: its field block updates the HPACK decoder, its DATA payload is credited to the connection window. Each RST_STREAM goes through
reset_stream/enqueue_rstand so feeds the emitted-RST flood accounting; each ignored frame counts as a glitch. Flood thresholds are unchanged.Known limitation, unchanged from refused streams: a dropped HEADERS frame without END_HEADERS is not decoded, so its CONTINUATION is still a connection error. This covers the HEADERS that triggers a stream error (trailers or half-closed HEADERS split across CONTINUATION) as well as late HEADERS on a reset stream.
h2spec 2.6.0: 146 tests, 146 passed, 0 failed. The documented h2spec count is updated from 145 to 146.
Tests: four e2e tests in
e2e/src/tests/h2_security_tests.rs, each checking that another in-flight stream on the same connection completes with no GOAWAY, plus a unit test for the bounded reset memory.