Repository navigation
Description
Problem Description
In mitmproxy v12.3.1, a reachable reverse:http3 listener can spend
disproportionate time inspecting one incomplete QUIC ClientHello. For each
additional valid Initial datagram on the same UDP 5-tuple,
ClientQuicLayer appends the datagram to handshake_datagram_buf and calls a
parser that creates a fresh aioquic connection and replays the entire
accumulated history. When the ClientHello remains incomplete, the history
is retained for the next attempt. The resulting work grows approximately
quadratically with the datagram count.
In two isolated, stock mitmdump runs, independent normal HTTP/3 clients
experienced continuous service interruptions of 20.012 s and 40.027 s.
Proposal
Please make ClientHello inspection work bounded per incomplete handshake.
Incremental parsing that does not replay previously processed Initials would
be ideal; a hard per-tuple budget for buffered datagrams/bytes and cumulative
parsing work would also prevent one unfinished handshake from monopolizing
the proxy. A regression test could run an incomplete handshake alongside an
independent, healthy HTTP/3 client.
Alternatives
A simple history-size limit or per-tuple rate limit would reduce the impact,
but a rate limit alone would only delay the same cumulative replay cost. A
history limit would need to allow legitimate fragmented ClientHellos while
still imposing a finite total work budget.
Additional context
The reproducer sent 3,000 valid 1,200-byte Initial datagrams (3.6 MB
total) at 500 datagrams/s, with continuing packet numbers and incomplete
CRYPTO/ClientHello data, on one UDP tuple. A same-packet/same-byte control
rotated the tuple after every ten datagrams. Neither control had a continuous
normal-probe failure. Separate diagnostics counted about 4.50 million
datagram replays in the one-tuple arm versus 16.8K in the control; the
availability result above comes from independent probes.
The relevant source paths on the tested commit are
the append/incomplete branch
and the parser/replay loop.
Tested with mitmproxy v12.3.1 (commit
51c1d6b2d8d3367a773411eb7a3eeccec82b3ea7), aioquic==1.2.0,
Linux Docker, 4 GiB memory / 1 CPU, stock mitmdump without addons. The
isolated test used block_global=false; the condition is that an untrusted
client can reach the reverse-HTTP/3 listener.
Activity
ul0gic commentedon Nov 20, 2026
@mhils this is still the case on current main:
ClientQuicLayerappends each Initial to
handshake_datagram_buf, andquic_parse_client_hello_from_datagramsbuilds a new
QuicConnectionand replays the whole buffer on every datagram.I'd fix it by keeping one parser connection per pending handshake and
feeding each datagram to it once, with a per-handshake byte cap as a
backstop, sized for post-quantum and ECH ClientHellos. If that can't work,
the cap alone bounds the work.
@jlaine I'd like your thoughts on the incremental feeding. Can a
QuicConnectionbe driven one datagram at a time like this and stillhand over the ClientHello as soon as it's complete?
I built the TCP version of this in swift-mitm.
IncrementalClientHelloInspectorframes TLS records as bytes arrive, never re-parses earlier input, parses
the ClientHello once it's complete, and caps the buffer at 64 KiB.
Tests would cover the incomplete-handshake path, which is
currently
pragma: no cover.I can send a PR if you would take this approach, or do you prefer just the cap?