Repository navigation
Description
Evidence (origin/main cb96495)
pkgs/github-ci/worker/src/index.ts:76(const raw = await req.text();) buffers the whole webhook body. The HMAC is computed only afterwards, at:78, and compared at:79. Auth fails closed on the secret (:70-74), but the body read runs before the signature check.infra/github-backup/worker/src/index.js:44(const body = await req.text();) has the same order. The secret check is at:41-43, the HMAC at:46, and the signature comparison at:50.- Neither handler checks
Content-Lengthor caps the read. A grep of bothsrc/trees forcontent-length,413and size limits finds nothing.
Result: any unauthenticated POST to either receiver makes the Worker buffer an arbitrary body in memory before a 401 is returned. The platform request limit is the only bound. This is the same order-of-operations problem that #11331 and #11332 describe for other Worker routes.
Not reproduced at runtime. The claim is about the code path.
Why it matters
GitHub's webhook payloads are bounded (about 25 MB per GitHub's documented limit; confirm the exact figure before setting the cap). A legitimate delivery never needs more, so a cap can refuse oversized input cheaply without changing behaviour for real deliveries. Today an oversized or drip-fed unauthenticated body costs the Worker its full memory before the signature fails.
Fix shape
- Reject with 413 when
Content-Lengthis present and exceeds the cap, before reading the body. - For bodies without a length, read through a size-capped reader that stops at cap + 1 byte and returns 413.
- Keep the existing HMAC check as the authoritative gate, unchanged in order after the bounded read.
- Apply the same helper to both receivers rather than two copies.
Acceptance criteria
- A POST whose declared
Content-Lengthexceeds the cap returns 413 without reading the body, on bothgithub-ciandgithub-backup. - A chunked POST larger than the cap stops reading at the cap and returns 413.
- A correctly signed delivery under the cap is processed exactly as before (existing tests stay green).
- A test covers the early reject and the chunked cap on each worker.
Dedupe
Searched open and closed issues for github-ci worker body, github-backup worker, webhook signature body, X-Hub-Signature, HMAC verify before read and buffers body before signature. Related but different: #6936 (fail-open secret, closed), #6946 and #6951 (JSON null bodies, closed), #9445 and #9454 (projector webhook intake design; the projector already caps at 10 MB and is a different component). No open issue or PR covers a body cap on these two workers.
Queue: repo-queue is not available in this environment, so no queue item was enqueued. Coverage needs a follow-up pass.
Activity
developing-today commentedon Nov 17, 2026
CODE-4115
dezren39 commentedon Nov 17, 2026
Current-main triage (2026-11-17): both receiver paths still buffer the full POST before HMAC. On origin/main
a03c40960a6b938bf36258687f1305237da717e6,pkgs/github-ci/worker/src/index.ts:76readsreq.text()before HMAC computation/comparison at :78-79;infra/github-backup/worker/src/index.js:44does the same before :46-50. No open PR matches #11335.Enqueued current-main triage task 20775 in
repo-health-code-pilotto maintain live issue coverage and route the two-handler bounded-read fix with tests for declared and chunked bodies plus valid signed deliveries.Merge pull request #11428 from developing-today/fix/11335-webhook-bod…
dezren39 commentedon Nov 18, 2026
agent-note:v1
state: done
task: 20775
lane: code-i (OpenChamber scheduled lane, worker repo-worker-code)
stage: claimed -> verified -> complete
Current-main verification 2026-11-18 (origin/main, read via gh api): both webhook receivers now read through a capped reader before the HMAC check. pkgs/github-ci/worker/src/index.ts reads with readBodyUpTo and returns 413 when over the limit, and infra/github-backup/worker/src/index.js uses readBodyUpTo(req, MAX_WEBHOOK_BODY_BYTES) with 413 before hmacHex. The issue was already closed COMPLETED on 2026-11-17. No further fix needed; outcome already_done.
dezren39 commentedon Nov 18, 2026
agent-note:v1
lane: openchamber-scheduled-lane (code-j) · worker repo-worker-code · queue task 20807
state: already_done (verified)
Fresh origin/main 6a87937. Both receivers now read through a bounded helper before HMAC: pkgs/github-ci/worker/src/index.ts (readBodyUpTo before hmacHex) and infra/github-backup/worker/src/index.js (readBodyUpTo at line 75, hmacHex at 78). Fix landed in 563c3e2 via PR #11428 (merge 840a188). Tests cover declared oversized 413, chunked cap, and the helper (github-backup test/index.test.mjs:316,332; github-ci test/body.test.ts:21). Issue is CLOSED; no further work.