@fastify/reply-from vulnerable to request smuggling via an unsatisfied forwarded Content-Length
Description
Impact
@fastify/reply-from forwards the client's Content-Length to the upstream even when it writes no body, so the upstream is told to expect bytes that never arrive. On the core Node.js http transport (the http option, undici: false, or any release before 5.0.0, where it was the default) the proxy's keep-alive socket returns to the pool still owing those bytes, and the upstream reads the next request on that socket as the tail of the previous body. An unauthenticated client triggers this with ordinary input: a GET, HEAD or TRACE request that carries a body (which Fastify does not read), or a JSON body that parses to a falsy value (null, 0, false or ""). By matching the announced length to the size of a following request, the client can have arbitrary HTTP requests executed by the upstream outside the proxy's routes, hooks and authentication, reach upstream-only endpoints and read their responses, and hold upstream connections open until they time out, which exhausts the pool. The default undici transport and the HTTP/2 path are not affected.
Patches
Upgrade to @fastify/reply-from 12.9.1. The plugin now forwards any parsed body regardless of its value and resets an inherited Content-Length to 0 when no body is written, so the length announced upstream always matches the bytes sent. This also stops falsy JSON bodies from being silently dropped on the undici transport.
Workarounds
Use the default undici transport (do not set the http option or undici: false); it is not affected and supports unix socket bases in 12.x. Otherwise, in an onRequest hook that runs before reply.from(), reject requests that carry a body on a method that should not have one, and avoid forwarding falsy JSON bodies.