Stripe secret keys and unsigned webhooks: the payment bugs AI-built apps ship with (proofforge.live)
If your app takes payments with Stripe, two secrets matter more than any others: your secret API key (sk_live_...) and your webhook signing secret (whsec_...). AI-generated checkout code often gets both wrong in quiet wa
If your app takes payments with Stripe, two secrets matter more than any others: your secret API key (sk_live_...) and your webhook signing secret (whsec_...). AI-generated checkout code often gets both wrong in quiet ways.
What goes wrong
-
Secret key in the frontend. Anything starting
sk_live_orsk_test_that appears in your JavaScript bundle can be used to create charges, issue refunds and read customer data. Only the publishable key (pk_) belongs in the browser. -
Webhook without signature check. If your
/api/webhookroute trusts any POST, anyone can send a fake "payment succeeded" event and unlock paid features for free. -
Success page as proof of payment. Granting access because a user landed on
/successis not verification. Anyone can type that URL.
How to check your own app
- View source or open DevTools Sources on your live site and search the bundles for
sk_live,sk_testandwhsec_. You should find none. - Read your webhook handler. It should call
stripe.webhooks.constructEvent(rawBody, signatureHeader, endpointSecret)and reject on failure. It needs the raw request body, not parsed JSON. - Check that access is granted from the verified webhook event or a server-side session lookup, not from a redirect.
Only check apps you own.
Fix
Move the secret key to server environment variables and rotate it in the Stripe dashboard if it was ever public. Verify webhook signatures on every request. Make the handler idempotent so replayed events do not grant twice.
Check your own app from the outside, free. Run the free ProofForge scan on your live URL. No account needed for the first scan. It looks at your public site the way a stranger would and says pass, fail or inconclusive, so you know what is confirmed and what it could not see. One-time reports start at $9: see pricing. Building with an AI agent? There is an MCP server so it can check before it deploys.
Originally published by Dev.to Security. Aggregated on AIWithGhost for educational purposes β full credit and traffic to the original publisher.