fix(runtime): cap H2 client RST_STREAM churn against Rapid Reset (CVE-2023-44487)

H2Connection accepted an unbounded number of client-initiated
HEADERS(END_HEADERS|END_STREAM)+RST_STREAM(NO_ERROR) pairs on one
connection: kH2MaxConcurrentStreamsDefault never engages because each
stream is torn down (dispatched and erased) before the next HEADERS
arrives. Add caps::kH2MaxStreamResetsPerConnection (200) and a
per-connection client_resets_ counter in OnRst; once a connection's
lifetime count of client RST_STREAM frames exceeds the cap, close it
with GOAWAY(ENHANCE_YOUR_CALM) via the existing Fatal() path, same as
other protocol-limit violations in this file.

The counter increments unconditionally for every valid RST_STREAM
frame, not only ones matching a still-open stream: this server's
coroutine dispatch runs synchronously inline (lazy Task resumed via
EventLoop::post on the loop thread) for fast handlers, so the matching
stream is frequently already completed and erased by the time the
paired RST_STREAM is parsed, which would otherwise let the attack
bypass a naively-scoped counter.

audit/MOLO-H2-001 (Rapid Reset) now PASSes; audit/MOLO-H2-002
(MadeYouReset) continues to PASS via its separate existing
flow-control-error path, unaffected by this change.

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
This commit is contained in:
2026-10-25 20:25:48 +01:00
co-authored by Claude Sonnet 5
parent 16a0bb0de4
commit 399c5c4dca
3 changed files with 19 additions and 0 deletions
+4
View File
@@ -36,6 +36,10 @@ inline constexpr std::size_t kMaxConnectionsCeiling = 65536;
inline constexpr std::size_t kMaxRequestsPerH1Connection = 1000;
inline constexpr std::size_t kH2MaxConcurrentStreamsDefault = 100;
inline constexpr std::size_t kH2MaxConcurrentStreamsCeiling = 1000;
// Rapid Reset (CVE-2023-44487 class) mitigation: a single connection may not
// open-then-reset more streams than this over its lifetime. Exceeding it is
// a fatal, GOAWAY-closed connection error (see H2Connection::OnRst).
inline constexpr std::size_t kH2MaxStreamResetsPerConnection = 200;
inline constexpr std::size_t kHeaderBlockMax = 65536;
inline constexpr std::size_t kHeaderFieldMax = 100;
inline constexpr std::size_t kHeaderLineMax = 16384;