Kept internal under SECURITY.md: this one is exploitable. The GitHub advisory goes out with the fix.
On Deno, Bun and Workers, readRequestBytes (src/http/web.ts:113) calls request.arrayBuffer() and compares the size afterwards. With the 1 MB default, a 2 GB upload is buffered in full before the 413. A handful of parallel requests exhausts memory. Node is not affected: it counts while reading.
Fix: read request.body chunk by chunk, keep a running total, and cancel() the reader as soon as it goes over. A Content-Length over the limit can be refused before reading anything. Test: a streamed body over a 1-byte limit is refused after reading at most one chunk, on all three runtimes.
Kept internal under SECURITY.md: this one is exploitable. The GitHub advisory goes out with the fix.
On Deno, Bun and Workers, `readRequestBytes` (src/http/web.ts:113) calls `request.arrayBuffer()` and compares the size afterwards. With the 1 MB default, a 2 GB upload is buffered in full before the 413. A handful of parallel requests exhausts memory. Node is not affected: it counts while reading.
**Fix:** read `request.body` chunk by chunk, keep a running total, and `cancel()` the reader as soon as it goes over. A `Content-Length` over the limit can be refused before reading anything. **Test:** a streamed body over a 1-byte limit is refused after reading at most one chunk, on all three runtimes.
Fixed in 26.11.0-rc.1 (ae60cd6). From the changelog:
Deno, Bun and the edge enforce maxBodyBytes while reading the body, not after (#105). The fetch adapter read every request through request.arrayBuffer() and compared the length once the whole body was in memory, so a 10 GB upload was buffered in full before it was refused. It now reads request.body chunk by chunk, stops at the chunk that crosses the limit and cancels the stream, so nothing further is pulled. A content-length that already declares more than the limit is refused before any of the body is read, on Node too, where the request used to wait for its first chunk. A malformed or absent content-length proves nothing and is ignored; the running count enforces the limit either way. The response is unchanged: the same 413 Payload Too Large, through onError, with the same route-over-server precedence for maxBodyBytes and maxParts. workerd may drop content-length from a chunked upload, so there an oversized body is refused by the count rather than up front. The status is the same; only how early it comes differs.
Fixed in **26.11.0-rc.1** (`ae60cd6`). From the changelog:
- **Deno, Bun and the edge enforce `maxBodyBytes` while reading the body, not after** (#105). The fetch adapter read every request through `request.arrayBuffer()` and compared the length once the whole body was in memory, so a 10 GB upload was buffered in full before it was refused. It now reads `request.body` chunk by chunk, stops at the chunk that crosses the limit and cancels the stream, so nothing further is pulled. A `content-length` that already declares more than the limit is refused before any of the body is read, on Node too, where the request used to wait for its first chunk. A malformed or absent `content-length` proves nothing and is ignored; the running count enforces the limit either way. The response is unchanged: the same `413 Payload Too Large`, through `onError`, with the same route-over-server precedence for `maxBodyBytes` and `maxParts`. workerd may drop `content-length` from a chunked upload, so there an oversized body is refused by the count rather than up front. The status is the same; only how early it comes differs.
Blocking a user prevents them from interacting with repositories, such as opening or commenting on pull requests or issues. Learn more about blocking a user.
Kept internal under SECURITY.md: this one is exploitable. The GitHub advisory goes out with the fix.
On Deno, Bun and Workers,
readRequestBytes(src/http/web.ts:113) callsrequest.arrayBuffer()and compares the size afterwards. With the 1 MB default, a 2 GB upload is buffered in full before the 413. A handful of parallel requests exhausts memory. Node is not affected: it counts while reading.Fix: read
request.bodychunk by chunk, keep a running total, andcancel()the reader as soon as it goes over. AContent-Lengthover the limit can be refused before reading anything. Test: a streamed body over a 1-byte limit is refused after reading at most one chunk, on all three runtimes.Fixed in 26.11.0-rc.1 (
ae60cd6). From the changelog:maxBodyByteswhile reading the body, not after (#105). The fetch adapter read every request throughrequest.arrayBuffer()and compared the length once the whole body was in memory, so a 10 GB upload was buffered in full before it was refused. It now readsrequest.bodychunk by chunk, stops at the chunk that crosses the limit and cancels the stream, so nothing further is pulled. Acontent-lengththat already declares more than the limit is refused before any of the body is read, on Node too, where the request used to wait for its first chunk. A malformed or absentcontent-lengthproves nothing and is ignored; the running count enforces the limit either way. The response is unchanged: the same413 Payload Too Large, throughonError, with the same route-over-server precedence formaxBodyBytesandmaxParts. workerd may dropcontent-lengthfrom a chunked upload, so there an oversized body is refused by the count rather than up front. The status is the same; only how early it comes differs.