Skip to content

fix(webhooks): cap github-ci and github-backup bodies before the HMAC check (#11335) - #11428

Merged
dezren39 merged 1 commit into
mainfrom
fix/11335-webhook-body-cap
Nov 17, 2026
Merged

dezren39 merged 1 commit into
mainfrom
fix/11335-webhook-body-cap

Conversation

@dezren39

@dezren39 dezren39 commented Nov 17, 2026 •

Copy link
Copy Markdown
Member

Closes #11335

Before: the github-ci and github-backup webhook receivers read the whole POST body with req.text() before checking the HMAC signature. Any unauthenticated POST made the Worker buffer an arbitrary body before returning 401.

After: both receivers refuse a declared Content-Length over 25 MB (GitHub's documented webhook payload cap) with 413 without reading the body, and read undeclared bodies through a capped reader that stops at the cap. Correctly signed deliveries under the cap behave exactly as before; the HMAC check is unchanged and still the gate.

How: pkgs/github-ci/worker/src/body.ts (readBodyUpTo, MAX_WEBHOOK_BODY_BYTES) used in src/index.ts, and the same reader inline in infra/github-backup/worker/src/index.js. They are separate deploy units in different packages (TypeScript with vitest, plain JS deployed as one file), so each carries its own copy rather than a shared import.

Testing:

  • github-backup: two new node tests (declared oversize never read, chunked oversize stops at the cap). 13 pass; both new tests fail without the change.
  • github-ci: new test/body.test.ts (declared, chunked, multibyte, empty) and an end-to-end 413 case in test/worker.test.ts. The package's npm ci can't run here (its lockfile resolves through a registry this sandbox can't reach), so I ran body.test.ts under node with a small vitest shim: 5 pass. The vitest suite itself has not been run; the scheduled github-ci worker workflow will cover it.

Generated by Claude Code


Autofix with [code]smith
Open in [code]smith · Need help on this PR? Tag @codesmith-bot with what you need.

… check (#11335)

Both receivers read the whole POST body with req.text() before the
signature check, so any unauthenticated request could make the Worker
buffer an arbitrary body. They now refuse a declared Content-Length
over GitHub's 25 MB payload cap with 413 without reading, and read
undeclared bodies through a capped reader that stops at the cap. The
HMAC check is unchanged and still runs after the bounded read.

The two receivers are separate deploy units in different packages, so
each carries its own small reader.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@dezren39
dezren39 marked this pull request as ready for review November 17, 2026 22:27
@dezren39
dezren39 requested a review from a team as a code owner November 17, 2026 22:27
@coderabbitai

coderabbitai Bot commented Nov 17, 2026 •

Copy link
Copy Markdown

Explain Change →

Caution

Review failed

The pull request is closed.

  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

Share

@dezren39
dezren39 merged commit 840a188 into main Nov 17, 2026
@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Nov 17, 2026 •

Copy link
Copy Markdown
Codex Review Summary: ✅ Completed

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-11-17T22:28:49.771324Z 563c3e2 Draft marked ready
ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

github-ci and github-backup webhook receivers buffer the whole body before verifying the HMAC signature

2 participants