Cluster 14 · SaaS Provider · 60s Replay Window

Linear Linear-Signature Verification, webhookTimestamp Replay Guard & Queue Pattern

Verify Linear's `Linear-Signature` hex HMAC-SHA256, validate `payload.webhookTimestamp` against Linear's tight 60-second replay threshold, and persist `Linear-Delivery` IDs.

100% Browser-Side · WebCrypto crypto.subtle · Strict CSP

1. Webhook Signature & Replay-Window Inputs

crypto.subtle HMAC-SHA256
Paste an incoming signature header to run constant-time verification.
Replay-Window & Clock-Skew Gate
15s age vs 60s max
PASS: WITHIN REPLAY WINDOW
Event age 15s is within <=60s tolerance window (45s remaining). Pair with Idempotency/Delivery ID cache. (121 UTF-8 bytes · Linear signs raw body bytes with hex HMAC-SHA256 and includes `webhookTimestamp` (ms) for 60s replay protection.)
Computed HTTP Signature Header
Linear-Signature: 449d89e76e0eba3193b3c6eb49b4bdcbce9b576dbc46dc290968a3cf929b2b6e
HMAC-SHA256 Hex
449d89e76e0eba3193b3c6eb49b4bdcbce9b576dbc46dc290968a3cf929b2b6e
HMAC-SHA256 Base64
RJ2J524OujGTs8brSbS9y86bV228RtwpCWijz5KbK24=
Drop-In WebCrypto Verifier + Replay Guard (verifyWebhook.ts)
// Strict WebCrypto Webhook Verifier + Replay Guard (Cloudflare Workers / Node 20+)
const REPLAY_TOLERANCE_SEC = 60;

function timingSafeEqual(a: Uint8Array, b: Uint8Array): boolean {
  if (a.length !== b.length) return false;
  let diff = 0;
  for (let i = 0; i < a.length; i++) diff |= a[i] ^ b[i];
  return diff === 0;
}

export async function verifyWebhookRequest(request: Request, secret: string): Promise<{ ok: boolean; reason: string; rawBody: string }> {
  const rawBody = await request.text();
  const sigHeader = request.headers.get("linear-signature") || "";
  const signedInput = rawBody;
  const providedSig = sigHeader.trim().toLowerCase();
  const enc = new TextEncoder();
  const key = await crypto.subtle.importKey("raw", enc.encode(secret), { name: "HMAC", hash: "SHA-256" }, false, ["sign"]);
  const mac = new Uint8Array(await crypto.subtle.sign("HMAC", key, enc.encode(signedInput)));
  const expectedHex = [...mac].map((b) => b.toString(16).padStart(2, "0")).join("");
  const ok = timingSafeEqual(enc.encode(providedSig), enc.encode(expectedHex));
  return { ok, reason: ok ? "verified" : "invalid_signature", rawBody };
}
WebhookSLA Guard · Live Check $29 WebhookSLA Guard Kit

Verify Live Webhook Replay Defense, 429 Retry-After & DLQ SLA Readiness

Run a live webhook endpoint & SLA audit on WebhookSLA Guard (webhook.runglab.dev), grab the turnkey $29 WebhookSLA Guard Kit (WebCrypto HMAC verifiers, replay-window store, RFC RateLimit-* middleware & DLQ runbooks) on Creem, or audit webhook OpenAPI specs on SpecDiff (spec.runglab.dev). Need a PayPal invoice? Email [email protected].

Webhook SLA, Signature & Retry Specification Matrix

Control / Header Production Baseline Reliability & Security Rationale
Signature Header Linear-Signature: <hex> Lowercase hex HMAC-SHA256 over raw JSON request body
Replay Timestamp payload.webhookTimestamp (ms) Millisecond epoch timestamp; Linear recommends rejecting events >60s old
Delivery Header Linear-Delivery Unique UUID identifying the webhook delivery for idempotent issue sync
Retry Behavior Exponential backoff retries Non-2xx responses retry with backoff; enqueue issue sync jobs quickly

Linear HMAC + 60s Millisecond Replay Guard (TypeScript)

linear-webhook-verify.ts
export async function verifyLinearWebhook(rawBody: string, sigHex: string, secret: string): Promise<boolean> {
  const enc = new TextEncoder();
  const key = await crypto.subtle.importKey("raw", enc.encode(secret), { name: "HMAC", hash: "SHA-256" }, false, ["sign"]);
  const mac = new Uint8Array(await crypto.subtle.sign("HMAC", key, enc.encode(rawBody)));
  const expected = [...mac].map((b) => b.toString(16).padStart(2, "0")).join("");
  const provided = sigHex.trim().toLowerCase();
  if (provided.length !== expected.length) return false;
  let diff = 0;
  for (let i = 0; i < expected.length; i++) diff |= expected.charCodeAt(i) ^ provided.charCodeAt(i);
  if (diff !== 0) return false;

  const parsed = JSON.parse(rawBody);
  const ageMs = Date.now() - Number(parsed.webhookTimestamp || 0);
  return Number.isFinite(ageMs) && ageMs <= 60_000 && ageMs >= -30_000;
}

Linear Webhook Retry & DLQ Policy JSON

linear-dlq-policy.json
{
  "provider": "linear",
  "replayWindowSec": 60,
  "idempotencyHeader": "Linear-Delivery",
  "maxAttempts": 6,
  "backoff": { "baseDelaySec": 15, "multiplier": 2, "maxDelaySec": 1800, "jitter": "equal" }
}

Implementation Steps & Key Insights

  1. Verify `Linear-Signature` against raw request bytes with constant-time hex comparison first.
  2. Parse JSON ONLY after signature validation succeeds, then inspect `payload.webhookTimestamp` (milliseconds).
  3. Reject events older than 60,000 ms (or >30,000 ms in the future) to close replay windows.
  4. Store `Linear-Delivery` UUIDs so repeated issue-update webhooks stay idempotent.
  • Linear encodes `webhookTimestamp` in **milliseconds** (`13` digits) rather than seconds (`10` digits) — failing to divide by `1000` causes every event to look centuries in the future!
  • Cluster 14's Replay-Window Verifier automatically detects 13-digit millisecond timestamps and normalizes them to seconds cleanly.
  • Never parse untrusted JSON before validating the HMAC signature, protecting against oversized JSON DoS payloads.

Common Production Pitfalls

  • Comparing `Date.now() / 1000` (seconds) directly against `payload.webhookTimestamp` (milliseconds).
  • Parsing JSON before authenticating `Linear-Signature`.
  • Forgetting `Linear-Delivery` deduplication on bi-directional Jira/GitHub sync workers.
Ship Faster: Audit your live endpoint on webhook.runglab.dev or grab the $29 WebhookSLA Guard Kit.

More Enterprise Webhook SLA & Signature Guides

← Back to Webhook SLA Kit Hub · WebhookSLA Guard ($29 Kit) → · SpecDiff OpenAPI Audit → · Cluster 7B: CORS & HMAC → · Cluster 9: OpenAPI OWASP →

Frequently Asked Questions

Why does Linear use a 60-second replay tolerance instead of 5 minutes?

Issue tracker updates are low-latency events; a tighter 60s window minimizes exposure if an internal proxy logs raw webhook headers.

What happens if I paste a 13-digit millisecond timestamp into Cluster 14's Replay Verifier?

Cluster 14 detects timestamps >= 10^12 and automatically converts them from milliseconds to seconds when computing event age.

Where can I validate live webhook endpoint resilience?

Run a live audit on https://webhook.runglab.dev or inspect OpenAPI webhook schemas on https://spec.runglab.dev.