- Home
- Skills
- APIs & Backend
- stripe webhook sentinel
More screenshots
Works with the AI Agents you already use
stripe webhook sentinel
Audit Stripe and payment webhooks for missing idempotency, timing attack vulnerabilities, unhandled subscription failures, and race condition edge cases.
$19.99
stripe webhook sentinel
Example session with this skill installed
Review this Next.js 14 Stripe webhook handler for vulnerabilities: [pasted code using express.json() and missing idempotency checks]
- Read your context and instructions
- Compiled the stripe webhook sentinel
I have completed the audit of your Next.js 14 Stripe webhook handler. Your current implementation is highly vulnerable to signature verification failures and duplicate fulfillment.
Webhook Risk Scorecard
| Gate | Status | Finding |
|---|---|---|
| G1: Signature Verification | CRITICAL | req.json() used before verification; alters body byte-order. |
| G2: Idempotency & Dedup | CRITICAL | No event ID tracking; retries will trigger duplicate fulfillment. |
| G3: Fast Ack (Async) | WARNING | Database writes are inline; high latency may trigger Stripe timeouts. |
| G4: Lifecycle State | PASS | Basic checkout and payment success events are covered. |
| G5: Defense-in-Depth | PASS | Official SDK constructEvent handles timestamp tolerance. |
| G6: Audit Trail | WARNING | No logging of processing status for failed events. |
Hardened Implementation (Next.js App Router)
import { NextResponse } from 'next/server';
import { headers } from 'next/headers';
import stripe from '@/lib/stripe';
import { prisma } from '@/lib/db';
export async function POST(req: Request) {
const body = await req.text();
const signature = headers().get('Stripe-Signature') as string;
let event;
try {
event = stripe.webhooks.constructEvent(body, signature, process.env.STRIPE_WEBHOOK_SECRET!);
} catch (err) {
return new NextResponse('Invalid Signature', { status: 400 });
}
// Gate 2: ACID Idempotency Gate
const existingEvent = await prisma.processedWebhookEvent.upsert({
where: { id: event.id },
update: {},
create: { id: event.id, status: 'PROCESSING' },
});
if (existingEvent.status === 'COMPLETED') {
return new NextResponse(null, { status: 200 });
}
// Gate 3: Fast Ack (Logic should be moved to a background worker for production)
try {
switch (event.type) {
case 'checkout.session.completed':
// Handle fulfillment
break;
case 'customer.subscription.deleted':
// Revoke access
break;
}
await prisma.processedWebhookEvent.update({
where: { id: event.id },
data: { status: 'COMPLETED' },
});
return new NextResponse(null, { status: 200 });
} catch (error) {
return new NextResponse('Internal Server Error', { status: 500 });
}
}
Next steps
- Run the database migration to create the
ProcessedWebhookEventtable with a unique ID constraint. - Update your
.envfile with the correctSTRIPE_WEBHOOK_SECRET. - Use
stripe listen --forward-to localhost:3000/api/webhooksto test the new idempotency gate.
Connects securely to your tools. The creator never sees your data.
About this skill
Payment webhooks are the most fragile boundary in SaaS apps. Standard tutorials often skip production realities, leading to duplicate credits, silent fulfillment failures, and signature bypasses. This skill functions as an adversarial auditor for your payment infrastructure. It identifies financial risks before they hit production, ensuring your system handles Stripe retries and race conditions correctly.
What it does
- Cryptographic Audit: Checks if raw request bodies are correctly handled for timing-safe signature verification.
- Idempotency Verification: Scans for atomic deduplication gates that prevent users from receiving duplicate credits or double fulfillment during Stripe retries.
- Race Condition Detection: Highlights potential data corruption where multiple concurrent webhooks might conflict.
- Lifecycle Coverage: Audits your handler for missing subscription states like dunning, grace periods, and cancellations.
- Latency Protection: Detects slow business logic that triggers Stripe timeouts and provides async queue architectures.
How it works
- Submit Code: Provide your current webhook endpoint file or architectural design.
- Review Scorecard: Receive a vulnerability report scoring your implementation across 6 security and resiliency gates.
- Apply Fixes: Use the provided drop-in replacement code tailored for your specific framework.
- Migrate Schema: Implement the suggested database migration for event deduplication tracking.
Frameworks & tools
Specifically designed for Node.js (Express, Next.js App Router), Python (FastAPI), and SQL-based databases like PostgreSQL or MySQL using ORMs like Prisma or SQLAlchemy.
Why this beats prompting it yourself
Standard LLMs often generate "happy-path" code from outdated training data that omits raw body parsing requirements or atomic database constraints. This skill uses a 6-gate verification rubric to enforce specific, production-hardened patterns that prevent real-world revenue leakage.
Use cases
- Auditing an existing Stripe integration for double-billing or fulfillment bugs.
- Building a new payment gate in Next.js 14 while ensuring 100% signature reliability.
- Hardening a subscription system against mid-cycle upgrades and failed payments.
- Replacing brittle webhook logic with a robust, queue-based background processing system.
Known limitations
Focuses on backend implementation logic only. Does not solve frontend UI state management or Stripe dashboard configuration.
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.
Focuses on backend logic. Requires access to raw request bodies. Does not handle frontend UI or Stripe dashboard configuration.
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 today