webhook-hardening
/webhook-hardening
Harden a commerce webhook handler: verify the provider signature with a constant-time compare BEFORE parsing the body, then de-duplicate retried deliveries by provider event id. Use when writing or reviewing any Stripe/Square/Shopify webhook receiver. Two invariants (verify-before-parse, event-id idempotency) that are non-negotiable.
- Author
- mcorbett51090 ↗
- Repository
- ravenclaude ↗
- Licence
- MIT
- Last repository change
- 27.10.2026
Assessment and security
- Files in this package
- 1
- Scripts
- 0
- HTML comments
- 0
- URLs in SKILL.md
- 0
No signals detected. Repository changed on 27.10.2026, without references to retired models or APIs.
MIT, open: use and modify while retaining author attribution.
What it does and when to use it
Harden a commerce webhook handler: verify the provider signature with a constant-time compare BEFORE parsing the body, then de-duplicate retried deliveries by provider event id. Use when writing or reviewing any Stripe/Square/Shopify webhook receiver. Two invariants (verify-before-parse, event-id idempotency) that are non-negotiable.
Original author description
Harden a commerce webhook handler: verify the provider signature with a constant-time compare BEFORE parsing the body, then de-duplicate retried deliveries by provider event id. Use when writing or reviewing any Stripe/Square/Shopify webhook receiver. Two invariants (verify-before-parse, event-id idempotency) that are non-negotiable.
How it works
- Invariant 1 — verify (constant-time) BEFORE parsing
- Invariant 2 — idempotency (exactly-once)
- Also
SKILL.md preview
--- name: webhook-hardening description: "Harden a commerce webhook handler: verify the provider signature with a constant-time compare BEFORE parsing the body, then de-duplicate retried deliveries by provider event id. Use when writing or reviewing any Stripe/Square/Shopify webhook receiver. Two invariants (verify-before-parse, event-id idempotency) that are non-negotiable." --- # Webhook Hardening Two non-negotiable invariants for every webhook handler this plugin scaffolds. Both are enforced by the [`commerce-gold-standard-rubric`](../commerce-gold-standard-rubric/SKILL.md) (dimensions 2 and 3). ## Invariant 1 — verify (constant-time) BEFORE parsing 1. Read the **raw** body — do not parse or re-serialize it first (that changes bytes and invalidates the signature). 2. Recompute the signature and compare with `safeSignatureEqual` from `templates/shared/webhook-verify.ts` — a constant-time compare. A plain `===` leaks timing an attacker uses to forge signatures. 3. On mismatch, drop the request (4xx). Only a verified request proceeds. Per-provider scheme: | Provider | Header | Signed over | Notes | |---|---|---|---| | **Stripe** | `Stripe-Signature` | payload + `whsec_` secret | 5-min timestamp tolerance guards replays | | **Square** | `x-square-hmacsha256-signature` | signatureKey + notificationUrl + rawBody | HMAC-SHA256 | | **Shopify** | `X-Shopify-Hmac-Sha256` | rawBody | base64 HMAC-SHA256 | ## Invariant 2 — idempotency (exactly-once) Providers **retry** deliveries and do **not** guarantee ordering. Before any side effect: 1. Extract the provider event id (Stripe `event.id`, Square `event_id`, Shopify delivery id). 2. `await store.seen(eventId)` — if true, return 2xx and stop (already processed). 3. Do the work, then `await store.remember(eventId, ttl)`. Use an `IdempotencyStore` (`templates/shared/idempotency-store.ts`). **On a static tier the store is KV-backed** (Upstash / Vercel KV) behind a serverless function — never a process-memory `Set` (a recycled invocation loses it and re-processes) and never browser state. ## Also - Return **2xx fast**, then process heavy work async — providers time out and retry on a slow 2xx. - Store only safe fields (card type / last4 / expiry), never the PAN. - Mutating API calls carry their own idempotency key (separate from webhook dedup) — see [`payment-lifecycle-contract`](../payment-lifecycle-contract/SKILL.md).
Versions
The database has no other skills named webhook-hardening.
Database snapshot: 13.11.2026 · package version 68b65eb22d68 (SHA-256 digest of the entire package)
Downloads in the last 30 days: 2 · ranking
Report a problem with this skill: harmful content, incorrect descriptions or an author’s removal request.
Similar skills
- 100webhook-receiver
Design, implement, or review inbound webhook handling that is verified, idempotent, and asynchronous. Use when adding a webhook endpoint or callback receiver for any provider (payments, messaging, analytics, CMS, CRM), when a provider is retrying or timing out, when webhook… - 100webhook-receiver-design
Use when designing webhook endpoints (Stripe/GitHub/Slack/internal), implementing HMAC signature verification, ensuring idempotency on retries, handling out-of-order events, building dead-letter queues, or replaying historical webhooks. Triggers: signature header verification… - 100webinarjam-webhooks
Receive and authenticate WebinarJam and EverWebinar Custom Webhook deliveries. Use when setting up a webhook endpoint for WebinarJam autoresponder triggers (registered, attended live, missed live, left early, purchased), when asking how to verify a WebinarJam webhook signature… - 100webhook-receiver-hardener
Hardens an inbound webhook endpoint so it verifies the sender signature on the raw body, resists replays, and acknowledges fast by persisting-then-enqueueing before any processing. Use when building or reviewing a handler that receives webhooks from Stripe, GitHub, or any third… - 90payment-provider-router # description: routing-facing summary of what the skill
Use when dispatching a verified payment event (Stripe webhook or future provider) to the correct downstream handler based on event type. Routes `checkout.session.completed` to subscription provisioning, `invoice.payment_failed` to dunning logic, and… - 100webhook-receiver-generator
Generate webhook receiver generator operations. Auto-activating skill for API Integration. Triggers on: webhook receiver generator, webhook receiver generator Part of the API Integration skill category. Use when working with webhook receiver generator functionality. Trigger with…