Repository navigation
fix(webhooks): cap github-ci and github-backup bodies before the HMAC check (#11335) - #11428
Merged
Merged
Conversation
… 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
marked this pull request as ready for review
November 17, 2026 22:27
|
Caution Review failedThe pull request is closed.
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. |
Codex Review Summary: ✅ CompletedThis comment shows the latest Codex review activity on this pull request.
ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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-Lengthover 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 insrc/index.ts, and the same reader inline ininfra/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:
test/body.test.ts(declared, chunked, multibyte, empty) and an end-to-end 413 case intest/worker.test.ts. The package'snpm cican't run here (its lockfile resolves through a registry this sandbox can't reach), so I ranbody.test.tsunder 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
Open in [code]smith · Need help on this PR? Tag
@codesmith-botwith what you need.