fix(web): verify review webhook deliveries#1378
Conversation
This comment has been minimized.
This comment has been minimized.
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Organization UI Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (2)
✅ Files skipped from review due to trivial changes (1)
🚧 Files skipped from review as they are similar to previous changes (1)
WalkthroughThe webhook route now reads raw request bodies, verifies GitHub webhooks before JSON parsing, derives the GitHub API base URL from the payload, and handles invalid GitLab JSON without throwing. Tests cover the verification paths, and the changelog is updated. ChangesGitHub Webhook Signature Verification
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~20 minutes 🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✨ Finishing Touches📝 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 |
There was a problem hiding this comment.
Actionable comments posted: 1
🧹 Nitpick comments (1)
packages/web/src/app/api/(server)/webhook/route.ts (1)
185-185: 🔒 Security & Privacy | 🔵 Trivial | ⚡ Quick winRequire
X-Hub-Signature-256here. GitHub recommends the SHA-256 webhook signature header, and supported GitHub Enterprise Server versions send it too. AcceptingX-Hub-Signaturekeeps the SHA-1 legacy path open unnecessarily.Proposed hardening
- const signature = headers['x-hub-signature-256'] ?? headers['x-hub-signature']; + const signature = headers['x-hub-signature-256'];🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the rest with a brief reason, keep changes minimal, and validate. In `@packages/web/src/app/api/`(server)/webhook/route.ts at line 185, The webhook signature lookup currently falls back from X-Hub-Signature-256 to X-Hub-Signature, which leaves the legacy SHA-1 path open. Update the webhook validation in route.ts to require only X-Hub-Signature-256 and make the signature handling in the webhook handler reject requests when that header is missing, using the existing signature verification logic around the signature/header parsing.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Inline comments:
In `@packages/web/src/app/api/`(server)/webhook/route.test.ts:
- Around line 153-169: The failure-path test in POST should assert that
verifyAndReceive was actually called before the webhook is skipped. Update the
test "skips GitHub events when verification fails" to include an expectation on
mocks.verifyAndReceive so it proves the handler reached verification and exited
because that step rejected, not due to an earlier guard. Keep the existing
checks on getInstallationOctokit and processGitHubPullRequest.
---
Nitpick comments:
In `@packages/web/src/app/api/`(server)/webhook/route.ts:
- Line 185: The webhook signature lookup currently falls back from
X-Hub-Signature-256 to X-Hub-Signature, which leaves the legacy SHA-1 path open.
Update the webhook validation in route.ts to require only X-Hub-Signature-256
and make the signature handling in the webhook handler reject requests when that
header is missing, using the existing signature verification logic around the
signature/header parsing.
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: Organization UI
Review profile: CHILL
Plan: Pro
Run ID: 141a98f6-1cfc-4c68-a6c0-fbdeb7b557e2
📒 Files selected for processing (3)
CHANGELOG.mdpackages/web/src/app/api/(server)/webhook/route.test.tspackages/web/src/app/api/(server)/webhook/route.ts
Fixes SOU-1463
Summary
Tests
Summary by CodeRabbit