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>
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>
openat(root_fd_, path, O_NOFOLLOW) only blocks the kernel from
dereferencing a symlink at the FINAL component of path; an earlier
component that is a symlink pointing outside the jail is still
followed while resolving the rest of the path, so a strict
(follow_symlinks=false) DiskProvider served files outside its
configured root via a symlinked intermediate directory (CWE-61,
MOLO-STATIC-001). Walk the path one component at a time from
root_fd_ instead, applying O_NOFOLLOW at every level, so a symlink
anywhere in the path is rejected when follow_symlinks_ is false. The
follow_symlinks_=true path (realpath containment fallback) is
unchanged.
Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
UpstreamHostAllowed used bare string-prefix tests (host.rfind("10.",0)==0
etc.), so a public DNS name like "10.evil.com" or "127.evil.com" was
misclassified as private/loopback even though it resolves to an
attacker-controlled address (CWE-184). Now the host is parsed with
inet_pton (AF_INET and AF_INET6, including v4-mapped and fe80::/10) and
only a real IP literal is checked against numeric RFC1918/loopback/
link-local ranges; anything that fails to parse as a literal is never
treated as private. Also fixes the latent 172.16.0.0/12 check, which used
ad-hoc digit parsing instead of a real numeric subnet comparison.
audit/MOLO-EXPOSE-001 harness now prints PASS (7/7 cases correct).
Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
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>
ResourceTree::copy inserted into entries_ (a std::map) while range-iterating
that same map. When dst fell inside src (e.g. /dav/a -> /dav/a/b), each
newly inserted entry was discovered by the ongoing iteration and copied
again, so the loop never converged and memory grew without bound
(MOLO-DAV-001, CWE-674/CWE-400). RFC 4918 9.8.3/9.9.3 require servers to
reject this shape before mutating anything, so copy() now checks dst == src
or dst nested under src and fails immediately with no side effects.
move() inherits the fix since it calls copy() first.
As defense in depth, copy() also no longer mutates entries_ while
iterating it: it collects the (target, resource) pairs into a local
vector first, then applies them in a second pass, so the same class of
bug cannot recur even if the containment check is ever bypassed.
Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
HandshakeValidator::validate never read the Origin header, so any
cross-site page could open a WebSocket to the app and ride a victim's
cookies (CWE-1385, the CVE-2024-23898 class). Add HandshakeConfig's
allowed_origins exact-match list and reject the handshake when an
Origin header is present but not allow-listed. Empty/unset
allowed_origins is closed by default (any Origin present is
rejected), matching CorsPolicy's closed-by-default convention.
Requests with no Origin header (non-browser clients) are unaffected.
Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
body_.size() + size could wrap size_t when an attacker-controlled chunk
size (up to 0xFFFFFFFFFFFFFFFF) was added to an already non-empty body,
making the body_cap_ comparison pass when it should reject with 413.
Check the remaining budget instead of the sum: reject if body_ already
exceeds the cap, or if the declared chunk size exceeds what's left.
Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
molo new <name> passed the project name through system("git -C \"" + dir +
"\" init -q"), a real shell; a name containing a double quote broke out of
the quoting and ran arbitrary shell commands (CWE-78). Replace the system()
call with fork+execvp passing argv as an array, so there is no shell to
parse the name. grep confirms this was the only system() call in
scaffolder.cpp.
Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
Table driven REST (509 rows verified against vendor specs by tools/check_spec.py),
WebSockets over the src/google/live client, neutral SpeechSynthesizer /
SpeechRecognizer seam, /ai/audio demo with dry runs, 110 package tests and 5
route tests. PlayHT has no public API; LeMUR is gone from AssemblyAI's spec.
Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
Directory and document cache with caps, parameter and body validation before
traffic, path/query/repeated/regional handling, key-or-OAuth choice, paging,
long-running wait, whole-directory checker script, demo at /google/discovery.
Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
Package molo::perplexity covering all 39 operations of the five published
OpenAPI documents, PerplexityChatModel, demo routes under /ai/perplexity,
check_spec.py, SPEC.md, 46 unit cases and 111 route checks.
Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>