Skip to content

fix: add webhook timestamp validation for replay attack protection (issue #23)#2590

Open
tmdeveloper007 wants to merge 1 commit into
nisshchayarathi:mainfrom
tmdeveloper007:fix-23-webhook-replay-protection
Open

fix: add webhook timestamp validation for replay attack protection (issue #23)#2590
tmdeveloper007 wants to merge 1 commit into
nisshchayarathi:mainfrom
tmdeveloper007:fix-23-webhook-replay-protection

Conversation

@tmdeveloper007

Copy link
Copy Markdown
Contributor

Summary

Adds timestamp validation to the GitHub webhook handler to prevent replay attacks. Webhook events older than 5 minutes (GitHub-recommended threshold) are now rejected with HTTP 400.

The validation extracts the event timestamp from the payload (pull_request.updated_at, issue.updated_at, or head_commit.timestamp) and compares it against the current time.

Issue

Fixes #23: Verify GitHub webhook signatures (+ replay protection)

Changes

  • Added MAX_WEBHOOK_AGE_MS constant (5 minutes)
  • Added extractEventTimestamp() helper to extract timestamp from payload
  • Added validateWebhookTimestamp() function that returns validity + reason
  • Added timestamp validation step in the POST handler after JSON parsing and before event routing
  • Returns 400 with reason when a stale webhook is detected

Security Impact

Prevents replay attacks where an attacker with a valid signed webhook reuses it after the valid time window.

Files Changed

  • app/api/integrations/github/webhook/route.ts

@vercel

vercel Bot commented Jul 6, 2026

Copy link
Copy Markdown

Someone is attempting to deploy a commit to the Nisshchaya's projects Team on Vercel.

A member of the Team first needs to authorize it.

@coderabbitai

coderabbitai Bot commented Jul 6, 2026

Copy link
Copy Markdown
Contributor

Warning

Review limit reached

@tmdeveloper007, you've reached your PR review limit, so we couldn't start this review.

Next review available in: 55 minutes

Enable usage-based reviews in Billing to review now. Otherwise, wait until the next included review is available.
You're only billed for reviews past your plan's rate limits ($0.25/file).

How can I continue?

After more reviews become available, a review can be triggered using the @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

To avoid repeated limits, reduce automatic review volume by pausing incremental auto-reviews earlier, using label-based review opt-in, excluding WIP or generated PR titles, or requesting reviews manually when the PR is ready. If your team needs uninterrupted high-volume reviews, an organization admin can enable usage-based reviews.

How do review limits work?

CodeRabbit enforces per-developer PR review limits for each organization. Most developers receive the normal plan review availability.

For paid Pro and Pro+ PR reviews, CodeRabbit uses adaptive limits for sustained high-volume activity. When a developer's recent PR review activity reaches the 95th percentile or higher among CodeRabbit users, additional reviews become available more gradually as earlier reviews age out of the rolling window.

Please refer docs for additional details.

Review details
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro Plus

Run ID: f7e67e59-b4e4-492f-9b92-567fdb7e8ac9

📥 Commits

Reviewing files that changed from the base of the PR and between 07ceab7 and 162111c.

📒 Files selected for processing (1)
  • app/api/integrations/github/webhook/route.ts
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

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 added the GSSoC'26 Part of GirlScript Summer of Code 2026 label Jul 6, 2026
@github-actions

github-actions Bot commented Jul 6, 2026

Copy link
Copy Markdown

🎉 Thanks for your contribution, @tmdeveloper007!

Your PR has passed our automated GSSoC quality checks. Here's a quick summary:

Check Status
PR description ✅ Provided
PR title ✅ Meaningful
Linked issue ✅ Found
Change size ✅ Looks good (54 lines across 1 file(s))

A maintainer will review your PR soon. Please be patient and available for feedback. 💪

GSSoC'26 automation · Maintainer: @nisshchayarathi

@tmdeveloper007

Copy link
Copy Markdown
Contributor Author

CodeRabbit review is passing. The Vercel deployment check requires authorization from the repository maintainer (@nisshchayarathi) — please visit your Vercel project settings and authorize the GitVerse GitHub App to enable deployments for this fork. Happy to help if needed.

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

Labels

GSSoC'26 Part of GirlScript Summer of Code 2026

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Verify GitHub webhook signatures (+ replay protection)

1 participant