feat: support webhook signing-key rotation without downtime - #1156
Merged
greatest0fallt1me merged 1 commit intoAug 27, 2026
Merged
Conversation
Accept current and previous secrets only inside the grace window, compare HMACs in constant time, persist nonces to reject replays, and keep failure responses from identifying which key matched.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Closes: #1147
Summary
Inbound webhook verification now accepts the current signing secret and the previous secret only while the configured rotation grace window is open. HMAC comparison is constant-time across every active key, timestamps outside the skew window are rejected, and nonces are persisted so replays fail. Failure responses never identify which key matched.
Acceptance criteria
WebhookStore.getActiveSecrets/expirePreviousSecret;src/webhooks/webhook.deliver.test.ts,src/webhooks/webhook.store.test.tsverifyWebhookSignature+ skew tests inwebhook.signature.test.ts/webhook.deliver.test.tsWebhookNonceStore+ replay testsINVALID_WEBHOOK_SIGNATURE/WEBHOOK_NONCE_REPLAYEDmessage;matchesAnySecretdoes not short-circuitSecurity and failure modes
<timestamp>.<nonce>.<rawBody>), so a captured signature cannot be replayed with a fresh nonce.current/previous, or a matched-key index.Test plan
POST /api/webhooks/:id/rotate-secretthen deliver with old and new secrets inside the grace window (both 200)previous_expires_at(401, no key identity in the body)WEBHOOK_TIMESTAMP_OUT_OF_WINDOW)WEBHOOK_NONCE_REPLAYED)sha256=/ nonce headers (400)DELETE /api/webhooks/:idthen deliver (404)