Commit Graph
6 Commits
Author SHA1 Message Date
retoor a9288ff2a9 Merge branch 'worktree-agent-a05bb30b35711bbf4' 2026-10-25 20:28:07 +01:00
retoor 0572e1c14a Merge branch 'worktree-agent-a9652d841d44d83e5' 2026-10-25 20:28:07 +01:00
retoorandClaude Sonnet 5 c20078dd79 fix(runtime): cap H2 control-frame output to stop PING-flood DoS/crash
MOLO-H2-004 (CVE-2019-9511/9512/9515/9518 class): a client that floods
PING frames without draining its socket crashed runtime_interop_server
after ~100-150k frames. Root cause, confirmed with an ASan build, is a
stack overflow, not heap growth: EventLoop::post()/the Task<T>
continuation resume synchronously when work is already buffered, so
H2Connection::ReadLoop's frame loop never returns to
EventLoop::run_once()'s flat dispatch while a burst of already-read
frames remains; each frame nests the native stack one level deeper
(ReadLoop -> Ensure -> ReadLoop -> ...) until it overflows.

ReadLoop now forces a co_await loop().yield() every
caps::kH2FramesPerYield frames, unwinding the stack back to
run_once() regardless of burst size.

Separately, EnqueueControl/EnqueueData/CompleteResponse had no ceiling
on out_queued_bytes_ for H2, unlike the H1 path's out_.size() check in
runtime/http/connection.cpp. Added EnforceWriteCap(), using a new,
tight caps::kH2MaxPendingControlBytes for control output (PING/SETTINGS
acks, RST, WINDOW_UPDATE, GOAWAY) and the existing kWriteBufferCeiling
for DATA/response output, same as H1. Because the kernel's own TCP send
buffer keeps draining small control frames even while the peer never
reads, out_queued_bytes_ alone can stay near zero through a flood, so
also added a monotonic caps::kH2MaxControlFramesPerConnection rate cap
in EnqueueControl as the mechanism that actually bounds this class of
abuse; exceeding either cap drops the connection via Fatal().

audit/MOLO-H2-004 now PASSes repeatably: the connection is cut well
before all 300k PINGs are accepted, and the server stays up with
bounded RSS. All 134 runtime unit tests (including the H2 suite)
still pass.

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
2026-10-25 20:27:04 +01:00
retoorandClaude Sonnet 5 399c5c4dca 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>
2026-10-25 20:25:48 +01:00
retoorandClaude Sonnet 5 11ae3ce4a5 fix(runtime): cap CONTINUATION frame count per header block (MOLO-H2-003)
kH2HeaderListMax only bounded accumulated header bytes across HEADERS plus
CONTINUATION frames, so an attacker could flood zero-length CONTINUATION
frames on an open header block (CVE-2024-27316 class) forever without
tripping the byte cap, each still costing a 9-byte frame parse. Add an
independent kH2MaxContinuationFramesPerHeaderBlock cap in caps.h and
enforce it in H2Connection::OnContinuation, closing the connection via the
same Fatal(kCompressionError) GOAWAY path already used for the byte cap.

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
2026-10-25 20:06:37 +01:00
retoor 3c4334cec9 feat: implement MoloApp plans 01-15 with integration
Full C++23 framework tree: runtime, observability, security,
data, app, realtime, supervisor, clients, CLI, example plus
enterprise tenancy, audit, operability, governance,
supplychain. Postgres via docker compose for tests.
2026-10-23 18:20:04 +02:00