- Home
- Skills
- APIs & Backend
- Webhook Security & Idempotency Review (Stripe and more)
Works with the AI Agents you already use
Webhook Security & Idempotency Review (Stripe and more)
A missing signature check lets anyone spoof a payment, while a slow handler causes timeouts and duplicate orders.
$5
Webhook Security & Idempotency Review (Stripe and more)
Example session with this skill installed
Customers sometimes get credits twice after paying. Review our Stripe webhook in Next.js.
- Read your context and instructions
- Compiled the webhook security
Webhook review: app/api/stripe/route.ts
| # | Check | Status | Evidence | Fix |
|---|---|---|---|---|
| 1 | Signature verified | FAIL | const body = await req.json() then constructEvent(JSON.stringify(body), ...), wrapped in try/catch that only logs | Verify on await req.text() and return 400 on failure |
| 2 | Raw body | FAIL | Re-serialised JSON never matches the signature | Same as above |
| 4 | Replay window | PASS once #1 is fixed | constructEvent enforces 300 s | none |
| 5 | Idempotency | FAIL | No event ID stored; Stripe retries after a timeout and credits are added again | webhook_events (provider, event_id) primary key, insert first |
| 6 | Fast 2xx | FAIL | Handler sends 2 emails and calls OpenAI before responding (8-12 s) | Respond 200 after storing the event, do the work in a queue |
| 7 | Trust payload | FAIL | Credits = session.amount_total / 100 from the event | Look up the order by client_reference_id, credit the purchased pack |
| 8 | Out of order | PASS | Only checkout.session.completed handled | none |
Root cause of double credits: the slow handler (#6) times out, Stripe retries, and nothing de-duplicates (#5).
Rewritten handler
Raw-body verification, recordEvent('stripe', event.id) returning early on duplicates, enqueue, 200 in under 1 s. Includes the SQL migration for webhook_events.
Repair
A one-off script lists checkout.session.completed events for the last 30 days and finds users credited more than once. A nightly reconciliation job compares Stripe sessions with granted credits.
Connects securely to your tools. The creator never sees your data.
About this skill
Webhook bugs are silent and expensive. A missing signature check lets anyone spoof a payment, while a slow handler causes timeouts and duplicate orders. This skill audits your webhook routes to ensure they are secure, idempotent, and resilient against provider retries.
What it does
- Signature verification ensures the handler validates provider secrets before triggering any side effects.
- Raw body handling fixes verification failures caused by pre-parsed JSON middleware.
- Idempotency implementation prevents duplicate processing of retried events using unique constraints.
- Timing-safe comparison adds constant-time HMAC checks to prevent sensitive data leaks.
- Asynchronous processing refactors slow handlers to acknowledge events quickly before performing heavy tasks.
- State reconciliation drafts scheduled jobs to recover from missed events or provider outages.
How it works
- Inventory endpoints by searching the codebase for provider SDK calls, signature headers, and callback routes.
- Audit handlers against eight critical failure points including timestamp tolerance, out-of-order safety, and payload trust.
- Rewrite code using verified patterns for your specific framework and provider.
- Generate migrations for the idempotency tables required to track processed event IDs.
Frameworks & tools
This skill works with Next.js, Express, Fastify, Supabase Edge Functions, and Django. It identifies issues with Stripe, Paddle, PayPal, GitHub, Shopify, WhatsApp/Meta, and Twilio SDKs.
Why this beats prompting it yourself
Generic prompts often miss the "raw body" requirement in frameworks like Next.js, leading to broken signatures. This skill follows a strict 8-point checklist that covers edge cases like event replay attacks and out-of-order state updates that manual prompting usually ignores.
Use cases
- Audit Stripe webhook routes in Next.js for signature and duplicate handling.
- Fix orders being created twice when a payment provider retries a request.
- Add HMAC verification to a custom payment gateway callback.
- Refactor a slow webhook that times out under heavy load.
Known limitations
Requires access to the backend route handlers and database schema. It cannot fix issues residing solely within third-party provider dashboards.
How to use
- 1
Connect your agent to the Agensi MCP
Copy the prompt and paste it into Claude, ChatGPT, Cursor or any agent that supports MCP. It sets up the connection for you. Manual setup
- 2
Sign in to Agensi
Your agent shows a sign-in link. Sign in and click Allow.
- 3
Ask for what you need
Your agent loads this skill and uses it on your task. It always asks before buying a skill.
Reviews
No reviews yet
Be one of the first to try it. Every listed skill goes through the trust checks below.
Security scanned
Checked by our 8-point scan before listing
Fresh listing
Recently published to Agensi
Money-back guarantee
Doesn't do what its page promises? You get your money back.
Trust & safety
Security scan
Security scan passed 4 days ago
- Software
- Backend with webhook endpoints
- Optional
- Stripe CLI (for replay tests)
Permissions
What's inside
Frequently Asked Questions
New in APIs & Backend
Find more skills like this on the Claude Skills Marketplace, the Codex Skills Marketplace and the Gemini Skills Marketplace, or browse Claude Skills for APIs & Backend.