Security & Reliability

Webhook Signature Verification

Direct Definition

Webhook signature verification is validating that an incoming webhook was sent by the expected provider and was not altered. Providers sign each payload with a shared secret, typically using HMAC-SHA256, and your endpoint recomputes the signature and compares it before trusting the event.

Technical Architecture & Deep-Dive

Webhook endpoints are public URLs, so anyone can send fake events, such as a forged payment succeeded notification. Signatures prevent this. Stripe, Paddle, Shopify, and GitHub each send a signature header computed over the raw request body and often a timestamp.

Verification must use the raw body before JSON parsing, a constant-time comparison, and a timestamp tolerance to block replay attacks. Edge runtimes support Web Crypto HMAC natively.

Key Architectural Benefits

Rejects forged webhook events from attackers.
Detects tampered payloads in transit.
Timestamp checks prevent replay attacks.

HMAC Webhook Verification

typescript
const key = await crypto.subtle.importKey(
  'raw', new TextEncoder().encode(env.WEBHOOK_SECRET),
  { name: 'HMAC', hash: 'SHA-256' }, false, ['verify']
);
const valid = await crypto.subtle.verify(
  'HMAC', key, hexToBytes(signature), new TextEncoder().encode(rawBody)
);
if (!valid) return new Response('Invalid signature', { status: 401 });
REALCOMPOSER EDGE WORKSPACE

Implement Webhook Signature Verification at the Edge

Deploy lightweight API aggregation, edge caching, and secret injection in minutes without Docker containers or complex servers.

START BUILDING FREE

Frequently Asked Questions

Q:Why must I use the raw request body?

Parsing and re-serializing JSON can change whitespace or key order, producing a different signature even for a legitimate payload.