Cross-backend request-smuggling probe for the body-size limit's connection
handling — the security sibling of body_size.ts.
When the server caps the request body it answers 413 on the
Content-Length header. The strong (defense-in-depth) posture is to close
the connection *without reading the oversized body*: HTTP/1.1 forbids reusing
a keep-alive connection whose request body wasn't consumed, because unread
body bytes would be parsed as the start of the next request — a classic
request-smuggling vector. This suite probes the boundary by pipelining:
it opens a raw TCP socket and sends, in one write, an oversized POST
immediately followed by a second GET. Every backend must close after the
reject, so the pipelined GET goes unanswered and at most one response
comes back. <= 1 rather than "exactly the 413" because the impls close
differently at the TCP level (a graceful close delivers the 413 first;
hyper's RST can drop the in-flight 413 before the client reads it), so
demanding a cleanly-read 413 would be flaky.
- Node closes at once with the body unread — create_app_server's body
limit (http/body_limit.ts) refuses on the header and answers
Connection: close, which is what makes @hono/node-server close. - Bun closes at once too, honouring that header. Bun 1.4.3 is the tested
floor: an older Bun kept the connection after the 413 and served the next
request (correctly framed), which fails this suite.
- hyper (the Rust spine) closes at once.
The oversized body is rejected *with* a 413 on every backend — pinned
reliably by describe_body_size_cross_tests, which sends the over-cap
request's head and no body, so no upload races the close; this test owns
only the connection-handling half. A positive control (two pipelined
requests → >= 2 responses) proves a second response *would* be seen if a
trailing request were processed — without it <= 1 would be vacuous on a
server that never reuses connections — and that the counter isn't
undercounting.
Content-Length beside Transfer-Encoding. The second probe sends a
request carrying both headers — the shape a request-smuggling attack hands a
server and a proxy that disagree on which one frames the body — with a
GET pipelined behind it. What the backends share is the outcome, not the
status: the request is refused with 400 (the Node and Bun parsers)
or answered as its chunked body reads (hyper, which drops the
Content-Length), and either way the server closes the connection and
the pipelined request is never served. The status of the one response
is implementation-defined and not asserted.
Raw-socket by necessity (the FetchTransport can't pipeline two requests on
one connection), so — unlike body_size.ts — this is cross-process only
(no in-process leg; there is no socket in-process — the in-process pin is
that the reject never reads the request body, in
server/create_app_server.db.test.ts).
Cited property: docs/security.md §"Body Size Limiting" (connection handling
on oversized reject).