Security record: HTTP/3 — frames, the connection and its UDP carrier
The record of HTTP/3 past QPACK: nish/net/http3-frame (the frames,
stream types, settings and error codes of RFC 9114), nish/net/http3 (the
server side of a connection, on the streams of a QuicConnection) and
nish/net/http3-server (the connection over one UDP socket, with ALPN h3,
in a pool of slots).
It says what each refuses and with what, what it caps and
where the cap is set, what it keeps in memory and for how long, and the test
that pins each property. QPACK itself is nish/net/qpack (#464), the header
model nish/net/http-fields (http2.md), and the transport
nish/net/quic (quic.md); what each of those costs this lane is
named where it does. It is written with the code rather than after an audit,
so that the audit of the protocol stack starts from evidence.
Result. Every connection error RFC 9114 and RFC 9204 name is made with the code they name, as an application CONNECTION_CLOSE, and every stream error resets the one request both ways; none is a panic, and a panic is only ever the program's own mistake (a window outside its buffer, a cap out of range). Every cap is a number the program fixes at start-up and is checked against the buffer it bounds.
A warm connection serving request after request allocates nothing, and neither does anything a connection does after its handshake, connection after connection through one slot; a datagram an established connection reads, and every datagram it sends, allocates nothing in the carrier; nor does a handshake through a reused slot, from the first Initial to the close, nor a datagram no slot owns, whatever the listener answers it with. No finding is open: H3-5, no clock at the HTTP/3 layer, is closed by the server's idle and head timeouts.
H3-1, what a handshake kept per connection, and H3-3, what a datagram no slot owns cost the listener, are closed: the first by keeping QUIC's handshake state in the slot and signing in scratch, the second by the listener reading a window and answering into scratch. H3-2, the copies of a field section, is bounded and closed here; H3-4 is accepted. H3-6 and H3-7, two ways a slot could wait for the client before sending what it had, are closed in the carrier. H3-9, request resets the connection never counted (rapid reset and MadeYouReset), is fixed with a reset budget.
Scope
| File | Functions |
|---|---|
std/net/http3-frame.ts |
h3ReadFrameHeader, h3ReadSettings and Http3Settings (take, unknown), h3ReadIdPayload, h3ReadVarint, the writers (h3PutVarint, h3PutFrameHeader, h3PutSettings, h3PutIdFrame), h3ReservedHttp2Frame, h3Greased |
std/net/http3.ts |
Http3Connection: next, step, open, start, ownStream, uniStep, typed, controlStep, controlFrame, requestStep, requestFrame, fieldSection, copyFields, copyOf, ended, abandon, streamError, answerTooLarge, writable, drain, arm, writeHead, respond, writeTrailers, writeData, reset, goaway, restart |
std/net/http3-server.ts |
Http3Server (receive, datagram, unowned, worthListening, takeAnswer, serve, refile, flush, release, tick, timeout, stop), Http3CidIndex, Http3Wheel |
std/net/quic-listener.ts |
QuicListener.handleWindow and what it answers with (versionNegotiation, retry, retryTag, tokenMac, tokenValid, invalidToken, opens, statelessReset, randomByte, refill), QuicListenerAnswer: for H3-3 only; the listener's rules are QUIC-4 and QUIC-5's in docs/security/quic.md |
Out of scope: QPACK's decoder and encoder (nish/net/qpack), the field model
(nish/net/http-fields), QUIC and the listener's rules (docs/security/quic.md,
whose QUIC-1 to QUIC-7 this lane inherits), TLS (docs/security/tls.md,
TLS-3 above all) and nish:net. Extended CONNECT, HTTP datagrams and
WebTransport are R2's. The external suites — the quic-interop-runner's http3
case, curl --http3, Chrome — run in S2's interop job, not here; aioquic 1.3's
HTTP/3 client was pointed at net_http3_server's serve mode by hand while
this lane was written (a GET, a 300,000-byte paced response checked byte for
byte, a 150,000-byte upload, twenty requests at once, a clean close), which
is evidence, not a test.
Threat model
The attacker is the client: every byte after the QUIC handshake is theirs, on any stream they may open, split anywhere, and they may open streams, reset them, stop reading them, send frames in any order or on the wrong stream, close or reset the critical streams, and hold the connection open. Before the handshake, anyone may send the carrier datagrams from any address.
A win is a panic, memory or time a client can make the server spend without bound, a request the program sees that RFC 9114 calls malformed, a frame accepted that a rule forbids, a stream whose state outlives it, a cap a peer can outgrow, or QPACK state that drifts from the peer's. The program driving the connection is trusted; its mistakes panic, and what it writes is checked so that its strings cannot become fields or frames it did not mean.
Findings
| Id | Severity | Where | Description | Disposition |
|---|---|---|---|---|
| H3-1 | Low | std/net/http3-server.ts (unowned, serve), through std/net/quic.ts and std/net/tls.ts |
Each new connection's handshake leaves memory in the arena. The slot is built on the first Initial accepted into it (build, from unowned), kept, and reset for the next client, and nothing HTTP/3 does after the handshake allocates (this sentence and the one on lazy slots below are at 0fcab5c, #779). Slots are built lazily: start-up costs about 232 bytes a slot in the fixed tables (the connection-ID index 184, the timer wheel 20, the other per-slot tables 28), 17,501,520 arena bytes for 65,536 slots with the receive buffer and scratch (net_http3_server, startup.ts, under HTTP3_SERVER_START_BYTES), and each slot built costs 110,912 bytes once (120 of them #474's ECN state) (net_http3_server, startup.ts, "building one Http3Server slot takes exactly HTTP3_SERVER_SLOT_BYTES"), where a client taking a slot released and kept costs none (net_http3_server, loopback.ts, the server's calls metered across chunks: "the first Initial into a slot never built keeps the slot in the arena", "a client taking the slot released keeps 0 bytes in the arena: the re-accept builds nothing"); so the pool's full footprint is reached at run time, one slot per accepted Initial a released slot does not take, and is still bounded by size times the per-slot cost; but the QUIC handshake kept 89,288 bytes of server calls a connection under this lane's test configuration, measured after #467 with NqMeter, which reads only the chunk a call ends in; read across every chunk, about 100 KB (#489: 100,216 to 103,768 bytes a connection over loopback). A client that connects in a loop drives it. N9's QUIC stage moved the QUIC handshake's state into the slot (QUIC-3's remainder in quic.md): one TlsServer a slot, restarted; every level's keys derived in place into key slots the connection made once; the Initial secrets, reset tokens and connection IDs computed in arena blocks; the transport parameters encoded and parsed in place. Through one QuicConnection slot a connection now keeps 0 bytes where it kept 87,328 to 127,312 (net_quic_memory), TlsServer's copy of the client's transport parameters included. What remained after it (net_http3_server, loopback.ts, every server call metered across chunks, five connections through a one-slot carrier with real entropy) was 10,912 to 11,040 bytes a handshake, none of it the QUIC connection's: (1) the CertificateVerify signature serve made with tlsSignEcdsaP256, 9,248 to 9,376 bytes as its DER length is 70 to 72, since p256SignSha256 stores what it allocates and the compiler refuses an arena block around it (NL2424); and (2) the carrier's copy of the client's first Initial and the listener's parse of it (H3-3). The signature is gone: serve signs in the server's TlsP256Signer, which signs with p256SignSha256Into over a P256SignScratch the server made once and keeps nothing. That left 1,600 bytes a handshake, all of it (2), and over loopback 1,600 bytes a whole HTTP/3 or WebTransport connection, Initial to close, with 3,072 more in some as the listener answered what arrived around the close. (2) is gone with H3-3: the carrier hands the listener the first Initial where it lies in the receive buffer, the listener parses it in place and answers into the carrier's one QuicListenerAnswer, and the slot reads the same window. What remains: nothing. From the second connection through a slot on, a handshake keeps 0 bytes from the first Initial to the close (net_http3_server, five connections through a one-slot carrier with real entropy, "each handshake through the listener into the slot keeps 0 bytes"), and over loopback every HTTP/3 and WebTransport connection kept 0 bytes, Initial to close, in each of 20 runs of three connections a carrier (net_loopback, lbHandshakeBand). |
Closed. About 100 KB a connection, then 1,600 bytes, now 0. The first connection into a slot builds it and fills what it made once; nothing grows after it. |
| H3-2 | Low | std/net/http3.ts (copyFields, copyOf) |
A field section is copied, and the copies are kept. nish/net/http-fields reads a section as one u8[] per name and value, and nish/net/qpack answers windows into one buffer, so each decoded name and value is copied into an array the connection keeps and reuses. Kept one per line, a client could grow every line's array in turn, request by request, to the section cap — about 16 MiB a connection at the default 16,384 — though no single request was large. They are kept by size class instead: class j holds arrays made with room for 2^j bytes, for strings at least half that long, and a section takes each class's arrays in order. A class grows only when one section needs more of its size than any before it, and since a section is at most maxFieldSectionSize bytes counting 32 per field (§4.2.2), the most it can ever hold is about 44 times the cap: 720 KiB at the default, reached only by a client that sends section after section shaped to fill each class. Seven sections, each with a 3,000-byte field on a different line, keep 0 bytes after the first (net_http3). |
Closed (bounded). A decoder that wrote into storage the connection owns, and a field model that read windows, would remove the copies; neither module is this lane's. |
| H3-3 | Low | std/net/http3-server.ts (unowned, worthListening, takeAnswer), through std/net/quic-listener.ts (QuicListener.handleWindow) |
What a datagram no slot owns could cost. QuicListener.handle took a whole u8[] and allocated as it parsed and answered, so the carrier copied such a datagram and the listener kept memory for it: 3,128 bytes for one answered with a stateless reset, 1,720 for a Version Negotiation, 456 for one it parsed and dropped, and an Initial that took a free slot or was answered with a Retry allocated without a budget. The relay's soak (#488) measured 131 such answers over 2,500 sessions, about 116 bytes a session. Now QuicListener.handleWindow reads the datagram where it lies, (buf, at, len) in the carrier's receive buffer: the header is parsed in place into a QuicHeader the listener made once, the token and IDs are read as windows, and every answer — Version Negotiation, a Retry with its token and integrity tag, a stateless reset with its token, the INVALID_TOKEN close sealed under the Initial keys — is written into a QuicListenerAnswer the carrier made once with room for the largest (QUIC_LISTENER_ANSWER_SIZE, 1,200 bytes), its arrays refilled in that room. Every MAC, key and seal runs in scratch the listener made at start-up (HkdfScratch, two QuicKeysSlots, the Retry key expanded once, the generator's block), and the reset token is quicConnResetTokenInto, the connection's own. The carrier still drops first, with no parse, what the listener would drop unanswered, and holds stateless resets and Version Negotiation to its budget of 16 at once and one per 100 ms, which now bounds CPU, not memory. A window outside its buffer panics, its length checked non-negative first (net_quic_listener_bad_window). |
Closed. A thousand datagrams of each kind — reset-worthy short headers, an unknown version, ones parsed and dropped — leave Arena.mark() unmoved through the carrier, within the budget and past it (net_http3_server, _f64, "a thousand stateless resets…"), and through the listener alone a thousand each of those, Retries, Initials accepted on a valid token and INVALID_TOKEN closes (net_quic_listener, _f64), where a thousand through handle, which makes an answer each time, move it. handleWindow answers byte for byte what handle answers for each kind (net_quic_listener), and every refusal of net_quic_lifecycle holds through it. handle stays, over handleWindow, for callers that keep each answer. |
| H3-4 | Low | std/net/http3.ts (requestFrame, uniStep, controlStep), std/net/http3-server.ts (Http3CidIndex) |
Work that costs only CPU, and the index's hash. Frames of an unknown or reserved type (§9, §7.2.8), empty DATA frames, a unidirectional stream of an unknown type (asked to stop, then read and dropped, §6.2) and a stream that ends before its type each allocate nothing and are read once, so the work is in proportion to the bytes the client sends, which QUIC's flow control already bounds; none is counted. The connection-ID index hashes an ID with eight bytes of the listener's entropy mixed in, by shifts and exclusive-or, not by a keyed PRF: a client that learned the salt could choose original DCIDs that collide, and a probe run is at most every ID of every slot (five a slot). | Accepted. A budget per frame type would refuse conforming clients that grease; the program owns the loop and may close a connection that sends much and asks little. A SipHash over the ID is the follow-up if a measurement shows probe runs growing. |
| H3-5 | Low | std/net/http3.ts (clock, awaitsHead), std/net/http3-server.ts (flushSlot) |
No clock at the HTTP/3 layer. QUIC's idle timeout closes a connection that has gone quiet, but a client that keeps trickling bytes, or only sends PING, kept its slot, and one that opened request streams and never finished their HEADERS kept up to maxStreamsBidi of them, until the program closed it. |
Fixed. Http3Config.idleTimeout (60 s by default) and headTimeout (30 s), each 1 to 2,147,483,647 ms, checked by Http3Connection and again by Http3Server at start-up. Http3Server.flushSlot asks each slot's clock(now) on every flush and files its answer in the timer wheel, so the program writes no timer. The idle clock runs from the slot's last progress: its start, a request head arriving whole, or the last request in hand finishing its head. QUIC traffic, PING and ACK included, is not progress, and a stream reset and opened again does not restart it. A slot with no request open past idleTimeout is closed with H3_NO_ERROR; one with a counted request still short of its head is closed with H3_EXCESSIVE_LOAD past headTimeout from when the connection last completed a head (or, with none since, from when the clock first saw one waiting), or past idleTimeout, whichever is sooner. The head clock is the connection's, not each stream's: a client that completes a new request head more often than every headTimeout keeps another stream's HEADERS incomplete as long as it does so, bounded by maxStreamsBidi streams, each of which is a request the program is serving. A request whose head arrived is the program's to time: a body that trickles after it is not closed by this clock. The clock starts on the first next that finds the handshake chose h3, not when this side's control and QPACK streams open: a client whose MAX_STREAMS lets fewer than three of them open still has its requests served, so it is still timed (test: past both timeouts, the starved trickler is closed with H3_EXCESSIVE_LOAD and the starved idle client with H3_NO_ERROR, which fails gated on those streams: expected "263 256 0", got "-1 -1 2"). A slot the program never calls next on has no clock: one it runs another protocol on (the interop server's hq-interop) is left to QUIC's idle timeout; the clock had closed the interop runner's hq-interop transfer under cross traffic at 60 seconds with H3_NO_ERROR (test: past idleTimeout, the clock of a connection never asked for an event neither closes it nor asks for a look; before: expected "-1 -1 false", got "1010 -1 true"). The state is five fields of the connection, so it costs a built slot 24 bytes and the pool nothing (HTTP3_SERVER_SLOT_BYTES). Tests: between 400 and 900 ms in, the trickler is closed with H3_EXCESSIVE_LOAD and the idle client is not yet, past 1,000 ms, the idle client is closed with H3_NO_ERROR and and the active client keeps its slot, every GET answered in tests/link/net_http3_server (clock.ts) and _f64, which fail with the close removed (before: expected "2 263 -1", got "3 -1 -1"); tests/link/net_http3_server_bad_idle_timeout and _bad_head_timeout. Not changed: a slot whose connection closed is freed once its CONNECTION_CLOSE is out, so a client that missed it is answered with a stateless reset rather than the close again (RFC 9000 §10.2.1's closing state is not kept); memory stays bounded either way. |
| H3-6 | Low | std/net/http3-server.ts (flushSlot) |
A slot the pacer held back was woken long after the pacer's time. quicListenerPaceTime answers an absolute time, now + pacerDelay, but flushSlot took it for a delay and added now again, after narrowing it to an i32. On a clock near 0 that filed the wake about 2 × now away; on a real clock, milliseconds since the epoch past 2^31, the toI32 (a trunc, which wraps and does not panic) left a value with no relation to either, negative about half the time, so the pacer's time was dropped, or else up to 24 days out. Either way the slot slept to its next QUIC deadline, which with everything acknowledged is the idle timeout. A client that acknowledges every packet woke it with each datagram (aioquic), so nothing showed; curl's quiche goes quiet once everything is acknowledged, and a 100 KB GET stalled at 21,875 bytes until the 30 s idle timer closed the connection (found by the interop run, #487). |
Closed. The pacer's time is taken as a time, in i64, and the slot is filed at the earlier of it and quic.deadline(). A client on an epoch-milliseconds clock that only acknowledges what arrives, with time moved only to the server's timeout, gets a 300,000-byte response whole in under a second of the server's clock, and a held-back slot is filed at exactly now + pacerDelay (net_http3_server, _f64, "quiet"). |
| H3-7 | Low | std/net/http3-server.ts (flushSlot), through std/net/quic-stream.ts (QuicStreams.putNextChunk, putResend) |
A flight could come back empty with bytes to send. When every byte of a stream's resend range has been acknowledged since it was queued again, putResend clears the range and answers nothing, and putNextChunk moves on without offering that stream's new bytes; with no other stream to send, the datagram, and so the flight, is empty, and flushSlot filed the slot under its deadline with the bytes unsent until the next datagram from the client. Exposed once H3-6 let the pacer's wakes through: in the carrier's echo, bytes declared lost and queued again were then acknowledged, and the 100,000-byte echo waited on the client. |
Closed in the carrier: an empty flight is asked for once more before the slot is filed, which cannot spin (at most once after each flight sent, inside flushSlot's 64). The carrier's checks pin it: without the second ask the echo stops at 32,969 bytes when the client's acknowledgement leaves nothing in flight (net_http3_server, _f64, "a POST of 100,000 bytes echoed whole"). putNextChunk offering the stream's new bytes after a cleared resend range is the fix at the source, in the QUIC lane's module, which this stage may not edit; the request is recorded in its pull request. Another caller of quicListenerTakeFlight or takeDatagramInto that stops at the first empty answer is exposed the same way until then. |
| H3-8 | Low | std/net/http3-server.ts (clock, serve, flushSlot), through std/net/quic-recovery.ts (fineNow, pacerRefill, pacerDelay) |
A response on a fast path waited for the next millisecond. The pacer counted whole milliseconds: on loopback the smoothed RTT truncated to 0 and was floored at 1 ms, the budget earned nothing until the millisecond changed, and a datagram the pacer held back waited at least one, so one connection's 4 kB GET had a p99 of 1.62 ms against nginx's 232 µs while the server sat 29% busy (measured with bench/h3-latency.mjs, h2load over HTTP/3 against nginx and a byte-identical copy of the server as the noise band). Nothing here is unsafe; it is recorded because the fix lets a peer change how fast the server sends. What a peer controls now. The pacer's rate is 5/4 of the window per pacerRtt, a smoothed RTT in microseconds taken from the same samples as smoothedRtt; a peer that acknowledges within microseconds, or acknowledges optimistically (QUIC-7 in quic.md), raises the rate up to a thousand times past what a 1 ms floor allowed. It does not raise what is sent: the congestion window still bounds the bytes in flight, a burst is still at most the initial window, 12,000 bytes (RFC 9002 §7.7), and the anti-amplification limit still holds before the address is validated. Loss detection and the probe timeout still count milliseconds with kGranularity's 1 ms floor, so a sub-millisecond RTT cannot make the server declare loss or probe sooner than before. A large ACK delay slows only the peer's own connection, and is bounded by max_ack_delay once the handshake is confirmed, as updateRtt bounds it. Overflow. pacerRefill counts at most a minute of microseconds and a window of at most 4 GiB, so its product stays inside an i64. A wrong clock. clock is read only when it falls inside the millisecond now names; one that is stale, never set or from another clock leaves the pacer on now × 1000, as before. A call with a stale micros that follows a fresh one inside the same millisecond steps pacerTime back to now × 1000, and the next fresh call re-earns the span between, under a millisecond's worth; the budget's cap of 12,000 bytes still holds. The flight quantum. A paced flight starts only once the pacer holds a millisecond's earning, from one datagram up to QUIC_LISTENER_FLIGHT_QUANTUM, 4,800 bytes (quicListenerTakeFlight, quicListenerFlightTime, pacerQuantum): a pacer that earns by the microsecond otherwise sent one datagram per GSO send, and c96m10 lost throughput. It only delays: it never lets more out than the per-datagram credit check allows, and since it is at most 4,800 bytes and the budget holds up to 12,000, the credit it waits for always comes. Before the first RTT sample (333 ms) it is one datagram, so handshake flights, probes and sends under the amplification limit pace as they did; after one, it adds less than a millisecond, and only after a send drained the budget. A CONNECTION_CLOSE waits on it as on the pacer before. flushSlot wakes a slot at the flight time, so a slot with something queued is never filed past it ("and the slot is filed at the flight time" in the two net_http3_server goldens). Measured (bench/h3-latency.mjs --runs 9): one connection's 4 kB p99 went from 1.55 ms to 225 µs, against nginx's 157 µs. The server is 99 % busy at c96. c96m10 runs at 15.9k req/s against the base's 15.8k (noise ±1.0 %). |
Closed. The carrier hands the pacer the caller's clock in microseconds (clock, set on every connection before serve and flushSlot call into it). Pinned in link/net_quic_recovery: exits with 0 and stdout matches expected.out and link/net_quic_recovery_f64: exits with 0 and stdout matches expected.out ("20 µs later, inside the same millisecond, it may go", "the pacer still holds the datagram past a burst of the initial window (§7.7)", "so the loss delay still floors at kGranularity, 1 ms (§6.1.2)", "a micros outside the millisecond now names is not read") and in link/net_http3_server: exits with 0 and stdout matches expected.out and link/net_http3_server_f64: exits with 0 and stdout matches expected.out ("the server hands its clock in microseconds to the connection's pacer", "and serve hands it to the pacer before any flush"). The flight quantum is pinned in the two net_quic_recovery goldens ("with credit for two datagrams a fast connection starts no flight", "and waits for the next millisecond", "with credit for four it sends the four together", "before an RTT sample a flight starts on one datagram: 12000 × 5/4 per 333 ms is 45 bytes a millisecond") and in link/net_loopback: exits with 0 and stdout matches expected.out ("http/3: a slot whose pacer has no credit left is woken when it has some, not at its idle deadline"). Anchors are function names. |
| H3-9 | Low | std/net/http3.ts (chargeReset, answered, requestStep, ended, streamError, answerTooLarge) |
Resets were not counted. A client could open a request stream, send its HEADERS and reset it at once, with RESET_STREAM, STOP_SENDING or both, and open the next without limit: the program was handed each request and kept whatever work it started, and QUIC's stream credit, which the connection returns as streams close, bounded only how many were open at a time, not how many came and went. That is rapid reset (CVE-2023-44487) over HTTP/3. Its twin, MadeYouReset (CVE-2025-8671), had the server reset the stream instead: a malformed request, a stream error the client provokes, a field section past the cap (the 431) or a request or body cut short each reset one stream and freed it, with nothing counted. H2-4 closed both for HTTP/2; this connection had no budget at all. CPU and the program's work, not memory: what a request costs the connection is in its slot (H3-2). | Fixed. Http3Config.resetBudget (100 by default, checked at start-up, 0 to 2^31 − 1) is the connection's resetCredit, refilled on restart. Each request the client resets or stops, and each the server resets for a stream error, answers with a 431 or finds incomplete, costs one, once a stream however many of those it draws (chargeReset, H3_FLAG_CHARGED); the one past the budget is the connection error H3_EXCESSIVE_LOAD (RFC 9114 §10.5, 0x107). A response the server ends with a FIN on a request it delivered earns one back, up to the budget (answered), as localEnd does for HTTP/2. What it does not bound is what H2-4 does not: a client that alternates one answered request with one reset keeps its credit, at one whole response of the server's work per reset; and a 431's request is never delivered, so it is never refunded, and a conforming client that draws resetBudget + 1 of them on one connection is closed. Tests in tests/link/net_http3 and _f64 (resets.ts): rapid reset: the third the client resets, past a budget of two, closes the connection with H3_EXCESSIVE_LOAD, RESET_STREAM alone, three times: H3_EXCESSIVE_LOAD, STOP_SENDING alone, three times: H3_EXCESSIVE_LOAD, MadeYouReset: the stream errors the client provokes are charged too, and past the budget close the connection, a 431 is charged, and never earned back: the third closes the connection, and up to the budget two requests the client resets, each with RESET_STREAM and STOP_SENDING, cost one each: the connection still answers and a response the server ends earns the budget back: a budget of one takes a reset after every answer, ten times; tests/link/net_http3_bad_reset_budget refuses a negative budget.With chargeReset never failing, the five past the budget fail and the four within it pass. |
H3-1, the slot a program asks for before a client has taken it.
Http3Server.connection(k), quic(k) and the private slotAt(k) under them
build every slot of the pool that is not built yet, 0 through k, not k
alone. The pool's conns, quics and addresses are dense arrays grown by
push in build, so slot k sits at index k only once the k before it
exist; building k alone would put it at the wrong index, and the accept path
(unowned) relies on the same order, taking slots 0, 1, 2 ... through
slotAt(used) once a released slot, taken first from the free list, is not
available. A program that binds state to each slot's connection up front
gets the connection the slot keeps for the whole run, which is why the call
builds rather than answers null. The cost is the per-slot figure above,
110,912 bytes of arena for each slot built, once: connection(k) on a fresh
pool costs k + 1 of them, and connection(size() - 1) on a 65,536-slot pool
builds every slot, about 7.3 GB, which is why the arena (not a limit of this
class) bounds it. It is bounded by size times the per-slot cost, the same
bound as the H3-1 row, and a slot out of range names slot 0, so a caller cannot make
it build more than the pool holds. The server's own accept path never calls
it with a slot above the next never used one. Recorded here, not changed: the
behaviour is as documented on connection.
Properties verified
Each property below is pinned by a test that fails if it stops holding.
Every frame, both ways (tests/link/net_http3_frame, _f64). RFC 9114
prints no vectors, so each frame is written out by hand from the layouts of
§7.1 and §7.2 — DATA, HEADERS with a two-byte length, CANCEL_PUSH, SETTINGS of
the three pairs this endpoint sends (16,384 as the four-byte varint
80 00 40 00), PUSH_PROMISE, GOAWAY, MAX_PUSH_ID, a reserved type of four
bytes, a length of 2^62 − 1 — read from its bytes and written back to them.
A header cut at any byte is not a header yet; a writer answers -1 for a frame
that does not fit or a value no varint holds, and leaves the buffer alone.
SETTINGS: an identifier twice, or one HTTP/2 used with no HTTP/3 setting (0x00,
0x02 to 0x05), is H3_SETTINGS_ERROR; a payload that ends inside a pair is
H3_FRAME_ERROR; unknown identifiers are kept for an extension, the first eight,
and counted past them without being compared. A one-identifier payload of the
wrong length is -1, H3_FRAME_ERROR's case. The error codes are §8.1's table, in
order. A window outside its buffer panics (net_http3_frame_bad_window).
Every connection error, with its code (tests/link/net_http3_errors,
_f64, 55 checks, each on a fresh connection, each asserting the code of the
CONNECTION_CLOSE the client receives and that the program was told with
H3_ERROR): a second control, encoder or decoder stream, and a push stream from
a client (H3_STREAM_CREATION_ERROR, §6.2.1, §6.2.2); a control stream whose
first frame is not SETTINGS, unknown or not (H3_MISSING_SETTINGS); the client's
control, encoder or decoder stream ended or reset, and STOP_SENDING for any of
the server's three (H3_CLOSED_CRITICAL_STREAM); DATA, HEADERS, a second
SETTINGS, PUSH_PROMISE or an HTTP/2 type on the control stream, and DATA
before HEADERS, PUSH_PROMISE, SETTINGS, GOAWAY, MAX_PUSH_ID, CANCEL_PUSH or an
HTTP/2 type on a request stream, and HEADERS or DATA after trailers
(H3_FRAME_UNEXPECTED); SETTINGS with a reserved or repeated identifier
(H3_SETTINGS_ERROR); a SETTINGS, GOAWAY or MAX_PUSH_ID payload of the wrong
length, and a DATA, HEADERS or unknown frame or a frame header cut short by
its stream's end (H3_FRAME_ERROR, §7.1); a client's GOAWAY push ID that rises,
a MAX_PUSH_ID that falls, a CANCEL_PUSH past the push IDs allowed (H3_ID_ERROR,
§5.2, §7.2.7, §7.2.3); SETTINGS past H3_CONTROL_FRAME_MAX
(H3_EXCESSIVE_LOAD); a Set Dynamic Table Capacity above 0 or an Insert on the
encoder stream (QPACK_ENCODER_STREAM_ERROR), a Section Acknowledgment or an
Insert Count Increment on the decoder stream (QPACK_DECODER_STREAM_ERROR), and
a field section with a Required Insert Count, a static index past 98 or no
prefix (QPACK_DECOMPRESSION_FAILED).
Requests before the client's SETTINGS are served, as §6.2.1 allows.
Every stream error, and the connection lives (tests/link/net_http3,
refusals.ts). A malformed request — no :path, an uppercase name,
connection, transfer-encoding, a pseudo-header after a field, :protocol
without extended CONNECT, :status in a request, a host that disagrees, a
bad content-length, te but trailers, :method twice — is reset both
ways with H3_MESSAGE_ERROR and never reaches the program (§4.1.2, §4.3); a body
shorter or longer than its content-length is H3_MESSAGE_ERROR, which the
program, holding the request, sees as H3_RESET; so are trailers with a
pseudo-header.
A request stream that ends before HEADERS, empty or after an unknown frame, is H3_REQUEST_INCOMPLETE (§4.1.1). Trailers past the field-section cap, in the frame or once decoded, are H3_EXCESSIVE_LOAD. A request on a stream at or past the GOAWAY this side sent is H3_REQUEST_REJECTED both ways, unseen by the program, and only its response is refused when it arrived whole (§5.2). Unknown and reserved frames before HEADERS, between DATA frames and at the end are skipped, and a unidirectional stream of an unknown type is asked to stop with H3_STREAM_CREATION_ERROR (§6.2, §9).
A field section past the cap is answered with a 431 (net_http3): one
whose HEADERS frame is longer than maxFieldSectionSize is skipped unread,
and one that fits its frame but decodes past it (QPACK's own count, §4.2.2),
are each answered with a 431 and the FIN, the rest of the request asked to
stop with H3_NO_ERROR (§4.1.2), and neither reaches the program. The cap is
advertised in SETTINGS, so a conforming client never sends one.
Cancellation (net_http3): a request the client cancels mid-body with
RESET_STREAM and STOP_SENDING reaches the program as H3_RESET with
H3_REQUEST_CANCELLED, and the server's half ends with the same code; RESET_STREAM
alone abandons the response the same way (§4.1.1); STOP_SENDING alone on a
held response is H3_RESET, answered by QUIC's RESET_STREAM.
GOAWAY (net_http3): it names the first stream the client has not opened,
so every request in flight finishes; a second never raises the ID; a request
past it is refused; with every request finished and every response byte
acknowledged the connection is done, and the carrier closes it with
H3_NO_ERROR and frees the slot (net_http3_server). A client's GOAWAY and
MAX_PUSH_ID are checked and otherwise ignored, since this server never pushes.
What the program writes is checked (net_http3, refusals.ts): a status
outside 200 to 599, a field name that is not a lowercase token, a
connection-specific field, names and values that do not pair, a second head,
DATA or trailers before the head, the FIN or trailers inside a DATA frame the
last write did not finish — each H3_INVALID, and nothing is sent; a stream
that is not an open request of the client's, or one already finished or reset,
is H3_CLOSED; a head past the client's SETTINGS_MAX_FIELD_SECTION_SIZE (as
§4.2.2 counts it) or past a stream's buffer is H3_TOO_LARGE.
set-cookie, cookie, authorization and proxy-authorization go as
never-indexed literals (RFC 9204 §7.1.3), and the encoder never inserts.
Back-pressure (net_http3): a 200,000-byte POST in DATA frames of 50,000
bytes reaches the program at most 16,384 bytes at a time while the client
never sends past the credit QUIC gave it, and comes back whole through a
32 KiB send buffer, in DATA frames of at most writeChunk, H3_WRITABLE
naming the stream each time acknowledgements free room.
One writeData of 20,000 bytes goes as two frames and is taken whole: a call
answers short only when the buffer filled, so the event the program waits for
always comes.
A HEADERS frame that must go whole and does not fit pads the buffer with a
reserved frame the client skips, sized to fill the room exactly — its length
written in a longer varint where the shortest would leave a byte over, as RFC
9000 §16 allows — so that QUIC names the stream once there is room (arm);
trailers on streams with 0, 1, 66 and 300 bytes of room all arrive after their
body, the padding skipped (66 is where the shortest length would have left a
stray byte in the stream).
A GOAWAY goes whole or not at all, and not again when its ID has not fallen.
Concurrency (net_http3): twelve requests open at once, ended in reverse;
two large responses interleaved; each whole.
The carrier (tests/link/net_http3_server, _f64): a handshake across
loopback through the listener into a slot; requests, a 100,000-byte echo and
a 300,000-byte response the pacer lets out over time, in GSO flights; a client
whose handshake chose another ALPN closed with CRYPTO_ERROR
no_application_protocol (0x0178) before any HTTP/3 byte, and its slot freed
(RFC 9114 §3.1); an Initial when every slot is taken dropped and counted; the
datagrams of H3-3 dropped, or answered, for nothing.
The connection-ID index keeps every ID found across removals in the middle of
probe runs, never files one twice or one over 20 bytes; the timer wheel answers
the earliest deadline, files one past its horizon at the horizon and again when
it comes round (a whole turn away after a tick, never "due now", so the loop
does not spin), and runs at most its 2,048 buckets in one tick, from a turn
ago when it is called late.
A connection closed while its pacer has no credit still sends its
CONNECTION_CLOSE before the slot is freed. A client on a clock in epoch
milliseconds that sends only to acknowledge what arrived, with time moved
only to the server's timeout, gets a 300,000-byte paced response whole, and
a slot the pacer holds back is filed at now + pacerDelay (H3-6).
The clock the carrier is given in microseconds reaches each connection's
pacer (H3-8).
One date on every final head (net_http3, dates.ts; net_http3_server;
and their _f64 twins; written against main at f8643b9, cited by function
rather than by line). writeHead puts the connection's date straight after
:status on every final head, a refusal's 431 included, and never on trailers
(HTTP/3 has no 1xx for a program to send); a program's own date
(http3NamesHoldDate, which matches any ASCII case) is sent instead, so a head
never carries two. A mixed-case Date never reaches it: respond refuses an
uppercase name with H3_INVALID (§4.2). Two of the program's own were sent as
they came until #696; httpFieldsCheckOutgoing now refuses a second date
(HTTP_FIELDS_DATE_REPEATED, RFC 9110 §5.3), so respond answers
H3_INVALID and writes nothing (net_http_date, net_http_fields and their
_f64 twins; before: the head went out with both).
The date counts against the client's SETTINGS_MAX_FIELD_SECTION_SIZE as any
field does, 65 bytes (RFC 9114 §4.2.2): a head that fits a limit of 107 bytes
exactly without it is refused with H3_TOO_LARGE with it. The server's own 431
counts 42 bytes bare and 107 with the date, so answerTooLarge sends it
without the date to a client whose limit has room only for the bare one, rather
than resetting the stream with H3_EXCESSIVE_LOAD. QPACK's dynamic table has
capacity 0, so the field is a literal and the encoder's streams carry nothing
for it. A bare Http3Connection is given no date and sends none.
Http3Server points every slot at its one HttpDate, refreshed at
connection(slot) and ready(), so a date is at most one turn of the
program's loop stale. Connection after connection through one slot, the pinned
clock a second on for each, keeps the arena at zero after the first; two slots
answered in one second share one format. Tests: link/net_http3: exits with 0 and stdout matches expected.out, link/net_http3_f64: exits with 0 and stdout matches expected.out, link/net_http3_server: exits with 0 and stdout matches expected.out, link/net_http3_server_f64: exits with 0 and stdout matches expected.out.
Caps, all fixed at start-up (Http3Config, the QUIC configuration, the
pool's size): the field section (maxFieldSectionSize, 16,384, which must fit
half a QUIC stream buffer with a frame header — checked when the connection
is made, since a HEADERS frame is read once all of it is in and QUIC raises a
stream's credit only once half a buffer is read, so a larger frame could stall
— and sizes the section buffer and the decoder's limit; the QUIC
connection's window must likewise hold one such frame on every request
stream twice over), the body chunk
(bodyChunk, 16,384, the data buffer), the DATA frame written
(writeChunk, 16,384), a control frame (H3_CONTROL_FRAME_MAX, 1,024 bytes),
the unknown settings kept (H3_SETTINGS_KEEP, 8), the client's unidirectional
streams and this side's own (at least 3 each, checked), the slots, the
datagrams one receive reads (H3_SERVER_RECEIVE_BURST, 256) and the answers
to unowned datagrams (H3_SERVER_ANSWER_BURST, 16, one per
H3_SERVER_ANSWER_INTERVAL, 100 ms), and the slot's two timeouts
(idleTimeout, 60,000 ms, and headTimeout, 30,000 ms).
A slot's clock (net_http3_server, clock.ts, and _f64; H3-5). Three
clients on one clock against a server with headTimeout 300 ms and
idleTimeout 1,000 ms: one sending a GET every 20 ms, one trickling a
request's HEADERS frame a byte a step, one sending only PING. The trickler is
closed with H3_EXCESSIVE_LOAD between 400 and 900 ms, the PING-only client
with H3_NO_ERROR past 1,000 ms, and the active client keeps its slot with
every GET answered. With the close removed the slot count stays at 3 and both
codes at -1.
A cap out of range panics (net_http3_bad_config,
net_http3_server_bad_config, net_http3_server_bad_idle_timeout,
net_http3_server_bad_head_timeout), as does a write's window outside its buffer
(net_http3_write_window).
Every counter a peer drives saturates: requests rejected, sections answered 431, stream errors, connections accepted, Initials refused, answers limited, sends failed, unknown settings dropped.
No lookup grows with a table. A stream's state is found through the QUIC
connection's own hash index (QuicStreams.slotOf), a datagram's slot through
the carrier's connection-ID index, and a timer through the wheel's bitmap;
nothing scans the slots or the streams per frame or per datagram.
Nothing on the request path allocates (net_http3, arena.ts, every
server call measured on its own with Arena.used()): 200 requests on a warm
connection — HEADERS and 1,000 bytes of DATA in, a 200 with two fields and
1,000 bytes out, ACKs and credit — keep 0 bytes; six connections through one
slot keep 0 bytes for the reset and 0 for everything after each handshake
(the client's streams, SETTINGS, ten requests, the close), from the second
on; through the carrier, five connections in one slot keep 0 bytes for each
handshake and 0 after it, from the second on (net_http3_server).
The slot itself, built on the first Initial accepted into it and kept (net_http3_server, "the first client builds one slot, and takes it"): HTTP/3 adds 1,344
bytes of buffers at the defaults (the control frame, scratch) and 108 bytes
per QUIC stream slot to the QUIC slot's own (QUIC-3); the body chunk and the
field section, 16,384 bytes each at the defaults, are lent per event from
pools the carrier shares across its slots (see below), so an idle slot holds
neither.
On the interop server (80 stream slots, 64 KiB of stream credit), the resident memory an HTTP/3 slot adds went from 12,462 kB to 254 kB. Add the decoder's and the field copies' growth to the largest section seen (H3-2).
A slot's address is the program's to trust only once QUIC validates it
(#806). Http3Server.addresses[slot] is the source of the slot's first
datagram, which anyone may forge; quic(slot).addressValidated says when
RFC 9000 §8.1 has proven it, by a Handshake packet or, with retry on, a
Retry token the listener checked.
The relay of examples/relay, which caps sessions per address with retry
off, claims an address's place only from that point, so Initials that name a
real client's address and never answer the server's flight hold a slot each
until the hello deadline, and none of the address's places (net_relay_forged,
"they hold no place of the address and no global place, and none is shed", "two
clients from that address then open sessions under its cap of two"); a
validated client past the cap is still refused ("a third validated client from
it is refused").
After the handshake the slot's address follows the client when its NAT rebinds (QUIC-11 in quic.md), first to an address not yet validated; the relay keeps the address it counted the session under, so a move neither frees nor takes a place.
The trade-off: before validation nothing caps an address. With retry off,
one real address, forging nothing, can open every slot of the pool
(maxSessions + spareSlots, 4,160 by default) and hold each until the hello
deadline, each answered within QUIC's amplification limit; when the cap was
claimed at the first Initial it held one address to maxPerPeer + spareSlots. Forged sources could fill the pool that way already; now no
forging is needed.
retry on closes both this and the hole of #806, at a
round trip's cost to every client: the listener answers an Initial without a
valid token with a Retry and gives it no slot (net_relay_forged, "with
retry on, each of four Initials without a token is answered with a Retry",
"and none of them holds a slot"). The relay ships with retry off.
What is and is not wiped
HTTP/3 holds no key material: the packet keys are QUIC's and TLS's
(docs/security/quic.md, QUIC-1, QUIC-2). The carrier takes the signing key
as a Secret on each receive and keeps nothing of it; its per-connection
entropy is wiped by QuicConnection as soon as it is copied. The
connection-ID index keeps eight bytes of the listener's entropy as its salt
for the server's life, and Http3Server.stop wipes it with the listener's
seed and the configuration's static keys (QUIC-5). What
the connection holds is application data — request field sections in
section, the decoder's buffer and the field copies, bodies in data — which
may carry credentials (cookie, authorization).
data and section are fixed-size buffers lent from pools an Http3Server
shares across its slots (a standalone Http3Connection makes a private pool of
one each): section for the one read and decode of a HEADERS frame, data for
the window an H3_DATA event hands the program, kept across the H3_DATA
events of a body read chunk by chunk and given back by the first next() call
that answers any other event.
Each is zeroed over the extent it was written as it goes back
(BufferPool.give, a plain fill the next borrower's reads keep), so the next
connection, or the next request of this one, borrows no byte of the last; the
QUIC stream buffers under them are lent and zeroed the same way (QUIC-3 in
quic.md). The fill is give's and not giveSecret's secureZero:
a later borrower reads the buffer, so the fill is no dead store -O2 may drop,
and secureZero clears all 16,384 bytes where the fill costs the bytes the
request wrote; before pooling, neither buffer was wiped at all.
WebTransportSession.data is h3.data itself during a WT_STREAM_DATA
event, not a copy, so it is lent and given back with it and is valid only
until the next next(). Anchors, by name (line numbers drifted and the commit they were taken at
is not on main): Http3Connection.next, giveData and giveSection in
std/net/http3.ts, WebTransportSession's alias of h3.data in
std/net/webtransport.ts, and Http3Connection.share in std/net/http3.ts, and Http3Server.release and
Http3Server.stop in std/net/http3-server.ts (the slot's give-back on release and stop). Not wiped: the decoder's buffer and the field
copies, which are the slot's own and overwritten by the next section, and a
pooled buffer while it is lent. A
credential the server sends is never indexed, and the dynamic table is never
used, so none sits in a compression table where a peer could probe it.

