Repository navigation
fix(api): reject GitHub webhook deliveries whose signature does not match - #6619
Conversation
…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.
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: defaults Review profile: CHILL Plan: Pro Plus Run ID: 📒 Files selected for processing (1)
Included review availability: Your plan includes up to 10 reviews per rolling hour; 8 remain after this review. 📝 WalkthroughWalkthroughThe GitHub webhook route now captures the ChangesGitHub webhook verification
Estimated code review effort: 2 (Simple) | ~5 minutes Merge Risk: ⚪ Minimal · up to 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)
✅ Passed checks (4 passed)
✨ Finishing Touches 💡 1📝 Generate docstrings 💡
🧪 Generate unit tests (beta)
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. Comment |
🧹 Preview Cleanup CompleteThe following preview resources have been cleaned up:
Thank you for your contribution! 🎉 |
Summary
webhooks.verify(body, signature)from@octokit/webhooksreturnsfalseon an HMAC mismatch and only throws when the signature is empty. The route awaited it inside atry/catchand discarded the boolean, so any request carrying a well-formedx-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
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/webhooksverify()inside a try/catch and ignored its boolean result, so any well-formedx-hub-signature-256header was accepted; now we check the return value and return 401 on mismatch.Written for commit 98e4acd. Summary will update on new commits.
Summary by CodeRabbit