fix: verify incident webhook signatures#1540
Conversation
|
@RachanaB5 is attempting to deploy a commit to the Nisshchaya's projects Team on Vercel. A member of the Team first needs to authorize it. |
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Organization UI Review profile: CHILL Plan: Pro Plus Run ID: 📒 Files selected for processing (3)
📝 WalkthroughWalkthroughThis PR hardens the incident webhook endpoint against forged requests by adding HMAC-SHA256 signature verification and URL parameter validation. The handler now rejects unauthorized requests with 401 and invalid target parameters with 400 before processing incidents. ChangesIncident Webhook Security Hardening
Sequence DiagramsequenceDiagram
participant Caller
participant WebhookHandler
participant VerifySignature as verifyIncidentWebhookSignature
participant ParseTarget as parseIncidentTarget
participant IncidentProcessor
Caller->>WebhookHandler: POST /webhook + raw body + x-incident-signature-256
WebhookHandler->>VerifySignature: (rawBody, signatureHeader, webhookSecret)
VerifySignature->>VerifySignature: Extract sha256= prefix
VerifySignature->>VerifySignature: HMAC-SHA256(rawBody)
VerifySignature->>VerifySignature: timingSafeEqual(computed, provided)
VerifySignature-->>WebhookHandler: true/false
alt Signature Invalid
WebhookHandler-->>Caller: 401 Unauthorized
else Signature Valid
WebhookHandler->>WebhookHandler: Parse JSON body
WebhookHandler->>ParseTarget: (URLSearchParams)
ParseTarget->>ParseTarget: Validate installationId (positive safe integer)
ParseTarget->>ParseTarget: Validate owner/repo (restricted charset)
ParseTarget-->>WebhookHandler: { installationId, owner, repo } or null
alt Target Missing/Invalid
WebhookHandler-->>Caller: 400 Bad Request
else Target Valid
WebhookHandler->>IncidentProcessor: Process incident with validated target
IncidentProcessor-->>Caller: 200 OK
end
end
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~25 minutes Suggested labels
🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches🧪 Generate unit tests (beta)
Comment |
🎉 Thanks for your contribution, @RachanaB5!Your PR has passed our automated GSSoC quality checks. Here's a quick summary:
A maintainer will review your PR soon. Please be patient and available for feedback. 💪 GSSoC'26 automation · Maintainer: @nisshchayarathi |
1 similar comment
🎉 Thanks for your contribution, @RachanaB5!Your PR has passed our automated GSSoC quality checks. Here's a quick summary:
A maintainer will review your PR soon. Please be patient and available for feedback. 💪 GSSoC'26 automation · Maintainer: @nisshchayarathi |
Closes #1539
Summary
x-incident-signature-256INCIDENT_WEBHOOK_SECRETbefore processing incident payloadsSecurity Impact
Prevents forged incident webhook requests from triggering deployment correlation and rollback PR preparation.
Testing
npm test -- --runTestsByPath lib/__tests__/incidentWebhook.test.tsgit diff --checkSummary by CodeRabbit
New Features
Tests