Impact
Attackers can create fraudulent charges, steal customer payment data access, and permanently compromise your Stripe account until the key is rotated.
Redacted evidence
- Location
- /_next/static/chunks/app-billing-9a2f.js
- Snippet
- stripeKey: "sk_live_****9a2f"
Developer fix
1. Immediately rotate the Stripe secret key in the Stripe Dashboard → Developers → API keys.
2. Move the secret into a server-only environment variable (e.g. STRIPE_SECRET_KEY).
3. Ensure it is only read in Server Actions, Route Handlers, or backend workers — never import it into Client Components.
// apps/web/src/lib/stripe.ts (server-only)
import "server-only";
import Stripe from "stripe";
export const stripe = new Stripe(process.env.STRIPE_SECRET_KEY!, {
apiVersion: "2024-11-20.acacia",
});AI fix prompt (Cursor / Claude Code / Lovable / Bolt)
You are fixing a critical LeakRay finding in a Next.js App Router app. Finding: A Stripe live secret key (sk_live_) is bundled into client-side JavaScript. Tasks: 1. Find every import/usage of the Stripe secret key in client components or shared modules that get bundled for the browser. 2. Move Stripe secret usage into server-only modules (Server Actions / Route Handlers) guarded with `import "server-only"`. 3. Read the secret only from process.env.STRIPE_SECRET_KEY. 4. Add a brief comment explaining why the key must never ship to the client. 5. Do not invent new payment flows — only relocate and secure the existing secret usage. Keep changes minimal and production-safe.