Skip to content

fix(api): reject GitHub webhook deliveries whose signature does not match - #6619

Merged
saddlepaddle merged 1 commit into
mainfrom
fix/github-webhook-verify-result
Aug 18, 2026
Merged

saddlepaddle merged 1 commit into
mainfrom
fix/github-webhook-verify-result

Conversation

@saddlepaddle

@saddlepaddle saddlepaddle commented Aug 18, 2026 •

Copy link
Copy Markdown
Collaborator

Summary

webhooks.verify(body, signature) from @octokit/webhooks returns false on an HMAC mismatch and only throws when the signature is empty. The route awaited it inside a try/catch and discarded the boolean, so any request carrying a well-formed x-hub-signature-256: sha256=<64 hex> header was accepted and fully processed (webhook_events → PR mirror → automation_events → dispatch). Pre-existing since 99920ed; surfaced by the trigger-provider audit.

Fix: capture the result and 401 when it is not true.

Test plan

  • typecheck + biome
  • Deliver a real GitHub ping → 200; same body with the last hex digit changed → 401

Summary by cubic

Rejects GitHub webhook deliveries when the HMAC signature does not match, preventing unverified events from entering the pipeline. Previously, the route awaited @octokit/webhooks verify() inside a try/catch and ignored its boolean result, so any well-formed x-hub-signature-256 header was accepted; now we check the return value and return 401 on mismatch.

  • Behavior change: mismatched or missing signatures now return 401 and the event is not stored, mirrored, or dispatched.
  • Required: ensure the GitHub webhook secret matches the server’s configured secret; validate with a GitHub “ping” delivery.
  • Rollout: monitor 401s on the GitHub webhook endpoint after deploy.

Written for commit 98e4acd. Summary will update on new commits.

Review in cubic

Summary by CodeRabbit

  • Bug Fixes
    • Improved webhook signature validation to consistently reject requests with invalid signatures.
    • Requests are now rejected whether verification fails explicitly or encounters an error, helping prevent unauthorized webhook processing.

…atch

@octokit/webhooks' verify() returns false on a mismatch and only throws when
the signature is absent; the route awaited it inside a try/catch and ignored
the boolean, so any well-formed sha256= header was accepted. Check the result.
@coderabbitai

coderabbitai Bot commented Aug 18, 2026 •

Copy link
Copy Markdown
Contributor

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro Plus

Run ID: 5b0a51eb-4137-43f7-bac9-960243ad810d

📥 Commits

Reviewing files that changed from the base of the PR and between b57afc9 and 98e4acd.

📒 Files selected for processing (1)
  • apps/api/src/app/api/github/webhook/route.ts

Included review availability: Your plan includes up to 10 reviews per rolling hour; 8 remain after this review.


📝 Walkthrough

Walkthrough

The GitHub webhook route now captures the webhooks.verify result. It returns HTTP 401 when verification returns false or throws an exception.

Changes

GitHub webhook verification

Layer / File(s) Summary
Handle verification failures
apps/api/src/app/api/github/webhook/route.ts
The route rejects webhook requests when webhooks.verify returns false or throws an exception.

Estimated code review effort: 2 (Simple) | ~5 minutes

Merge Risk: ⚪ Minimal · up to 98e4a

This localized change rejects webhook requests with invalid signatures; no actionable merge-blocking risk remains after normal checks and review.

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Description check ✅ Passed The description explains the bug and fix, includes testing details, and records checklist status.
Title check ✅ Passed The title uses conventional commit format and clearly describes rejecting GitHub webhook requests with invalid signatures.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
✨ Finishing Touches 💡 1
📝 Generate docstrings 💡
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch fix/github-webhook-verify-result

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

Comment @coderabbitai help to get the list of available commands.

@github-actions

github-actions Bot commented Aug 18, 2026 •

Copy link
Copy Markdown
Contributor

🧹 Preview Cleanup Complete

The following preview resources have been cleaned up:

  • ✅ Neon database branch

Thank you for your contribution! 🎉

@saddlepaddle
saddlepaddle merged commit 289febd into main Aug 18, 2026
20 checks passed
@saddlepaddle
saddlepaddle deleted the fix/github-webhook-verify-result branch August 18, 2026 17:21

This branch was previously deployed

1 inactive deployment
preview — 98e4acde Deployed Aug 18, 2026 by saddlepaddle via Deploy Web #8024
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.

1 participant