Repository navigation
Closed
Labels
app/idPackage/app: id (pkgs/ or apps/ in this repo)Package/app: id (pkgs/ or apps/ in this repo)effort/sSmall: expected under 2 hours of workSmall: expected under 2 hours of workkind/bugSomething isn't working (prefixed form of the classic bug label)Something isn't working (prefixed form of the classic bug label)priority/normalOrdinary priority (the default)Ordinary priority (the default)queue/queuedHas a queued queue taskHas a queued queue tasksource/creatorFiled by the new-issue-creator jobFiled by the new-issue-creator jobstatus/triagedTriaged and routed (see agent note)Triaged and routed (see agent note)status:donetask/small-fixQueue packet kind: bounded fix with reproduction and targeted testsQueue packet kind: bounded fix with reproduction and targeted tests
Description
Summary
The hosted data-plane front door reads every non-GET/HEAD request body into memory before routing, so the body cap added to the user DO in PR #11336 (closing #11332) can never refuse an oversized request early. The early refusal (Content-Length check and readTextUpTo cap in pkgs/id/hosted-worker/src/user-do.ts:341-344) only runs after the Worker has already buffered the whole body.
Evidence (origin/main c4a5fb592e)
pkgs/id/hosted-worker/src/worker.ts:42-47:const forwarded = new Request(req.url, { method: req.method, headers, body: req.method === "GET" || req.method === "HEAD" ? undefined : await req.arrayBuffer(), }); return await stub.fetch(forwarded);
req.arrayBuffer()reads the full body for every method other than GET/HEAD, on every route, before any size check, and before the DO's storage ceiling is consulted.pkgs/id/hosted-worker/wrangler.toml:6deployssrc/worker.tsasmain, so this is the production entry point, not a test shim.pkgs/id/hosted-worker/src/user-do.ts:341-344: the KV PUT path checkscontent-lengthagainst headroom and capsreadTextUpTobefore reading. By the time the DO receivesforwarded, the body is already a fully materialisedArrayBuffersupplied tonew Request, so that cap bounds nothing at the front door.- hosted-worker user-do: KV and blob PUT buffer the whole request body before the storage ceiling check #11332 (closed, fixed by PR hosted-worker: refuse oversized kv PUT before buffering the body (#11332) #11336, merged 2026-11-17 20:11Z) described the defect as "KV and blob PUT buffer the whole request body before the storage ceiling check". The merged fix changed only
user-do.tsandtest/usage.test.ts;worker.tsis unchanged, so the buffering that hosted-worker user-do: KV and blob PUT buffer the whole request body before the storage ceiling check #11332 reported still happens at the front door. - Fresh search of issues (all states) for hosted-worker, arrayBuffer, and body-buffering terms found no tracker for
worker.ts:45. hosted-worker user-do: KV and blob PUT buffer the whole request body before the storage ceiling check #11332 and hosted-worker: refuse oversized kv PUT before buffering the body (#11332) #11336 are the nearest; they cover the DO-side check only.
Why it matters
- Memory: a single unauthenticated-size PUT/POST of arbitrary length is held in the Worker isolate before the storage ceiling or any per-route limit applies. The DO-side fix is therefore ineffective for the exact case it targets.
- Cost and reliability: the buffer is paid even for requests the DO will refuse with 413 after the fact.
- Scope: every mutating route in the hosted data plane (KV, blob, and any future POST) shares this path, so the gap is not specific to one route.
Suggested fix shape
- In
worker.ts, enforce a front-door body limit for non-GET/HEAD requests beforearrayBuffer(): refuse a declaredContent-Lengthabove the largest per-route limit with 413, and pass the request body through as aReadableStream(or a capped reader) so no route reads more than its limit into memory. - Keep the DO's per-route check as the authority for storage ceilings. The front-door check only bounds memory.
- Route-specific limits should be defined once and used by both the front door and the DO, so the two cannot drift.
Acceptance criteria
- An oversized PUT with a declared
Content-Lengthabove the limit is refused with 413 at the Worker front door, and the forwarded body is never read into memory (test: a body stream that records bytes read, asserting the read stops at the limit). - An oversized chunked PUT (no
Content-Length) is refused after reading at most the limit plus one chunk (same instrumentation). - A normal-size KV PUT and blob PUT still succeed end to end through
worker.ts, not only through the DO in isolation. The existingtest/usage.test.tstests callUserDOdirectly and do not exerciseworker.ts, so add a test that goes through the default export. - Mutation check: removing the new front-door cap fails test 1.
Related
- hosted-worker user-do: KV and blob PUT buffer the whole request body before the storage ceiling check #11332 (closed) and PR hosted-worker: refuse oversized kv PUT before buffering the body (#11332) #11336 (merged): DO-side early refusal. This issue is the front-door half that hosted-worker: refuse oversized kv PUT before buffering the body (#11332) #11336 does not reach.
- github-ci and github-backup webhook receivers buffer the whole body before verifying the HMAC signature #11335 (open): the same buffering-before-verification shape in
pkgs/github-ciandinfra/github-backup. Separate deployment, separate fix.
Metadata
Metadata
Assignees
Labels
app/idPackage/app: id (pkgs/ or apps/ in this repo)Package/app: id (pkgs/ or apps/ in this repo)effort/sSmall: expected under 2 hours of workSmall: expected under 2 hours of workkind/bugSomething isn't working (prefixed form of the classic bug label)Something isn't working (prefixed form of the classic bug label)priority/normalOrdinary priority (the default)Ordinary priority (the default)queue/queuedHas a queued queue taskHas a queued queue tasksource/creatorFiled by the new-issue-creator jobFiled by the new-issue-creator jobstatus/triagedTriaged and routed (see agent note)Triaged and routed (see agent note)status:donetask/small-fixQueue packet kind: bounded fix with reproduction and targeted testsQueue packet kind: bounded fix with reproduction and targeted tests
Activity
developing-today commentedon Nov 17, 2026
CODE-4116
dezren39 commentedon Nov 17, 2026
Current-main triage (2026-11-17): still reproducible by source inspection at origin/main
a03c40960a6b938bf36258687f1305237da717e6.pkgs/id/hosted-worker/src/worker.ts:42-47awaitsreq.arrayBuffer()for every non-GET/HEAD method before callingstub.fetch; the Durable Object cap inuser-do.ts:342-345therefore runs only after full buffering.wrangler.tomlpoints production at this entry point. No open PR matches #11337.A fresh
repo-queuededupe lookup found the existing task 20766 inrepo-health-code-pilot, statusqueued(the task is a fix task; the issue labels had not reflected that). I’m syncing issue labels to the live task.Merge pull request #11427 from developing-today/fix/11337-front-door-…
dezren39 commentedon Nov 18, 2026
agent-note:v1 — picked up (queue task 20766, lane oc-code-04)
Fresh claim revalidation found #11337 already CLOSED by merged PR #11427. The PR explicitly closes this issue, changes the front-door worker and adds the acceptance tests. No implementation started in this claim.
dezren39 commentedon Nov 18, 2026
agent-note:v1 — done/already_done (queue task 20766, lane oc-code-04)
Verified #11337 is CLOSED by merged PR #11427 (
Closes #11337), merged 2026-11-17T22:24:59Z at c89be38. The PR fixes the front-door body buffering, adds end-to-end front-door tests, and reports 27 tests passing plus cleantsc --noEmit. No branch or code changes were needed in this claim.