feat(webhooks): add linear verification scheme - #947
Open
kai-jmi wants to merge 1 commit into
Open
Conversation
Linear signs the raw request body with HMAC-SHA256 into the linear-signature header and embeds a webhookTimestamp in the signed payload. The generic hmac-sha256 scheme cannot verify these deliveries because it reads x-signature, so give Linear its own scheme: signature check plus a one-minute webhookTimestamp replay window, deduplicated on the signed body like the other schemes. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
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.
What
Adds a
linearwebhook verification scheme, alongside the existing github, slack, stripe and generic hmac-sha256 schemes.Linear signs the raw request body with HMAC-SHA256 using the webhook signing secret and sends the hex digest in the
linear-signatureheader, with awebhookTimestamp(ms epoch) embedded in the signed payload for replay protection. The generichmac-sha256scheme cannot verify these deliveries because it readsx-signature, so Linear webhooks currently cannot be verified at all.How
src/webhooks/verifiers.ts: newlinearverifier. Constant-time signature check over the raw body; when the signed payload carries a numericwebhookTimestamp, deliveries outside a one-minute window are rejected (Linear's documented recommendation). Payloads without a parseable timestamp pass on signature alone. Dedup key is the signed body hash, consistent with the other schemes (thelinear-deliveryheader is unsigned, so a replay with a fresh id still dedups).src/types.ts:"linear"added to the scheme union.WEBHOOK_SCHEMESderives from the verifier map, so API validation picks it up automatically.plugins/web-ui/src/webhooks.ts:Linearentry in the scheme selector with guidance text.Verified
node --test test/webhook-verifiers.test.ts: 14 pass (3 new: valid/forged signature, stale vs absentwebhookTimestamp, dedup on signed body ignoringlinear-delivery).tsc --noEmiton the root and the web-ui plugin: no new errors.The web-ui change adds one entry to the existing data-driven scheme list; markup and styles are untouched, so it renders identically to the four existing entries. No screenshot for that reason.
🤖 Generated with Claude Code
Need help on this PR? Tag
@codesmith-botwith what you need. Autofix is disabled.