{"slug": "before-you-ship-that-vibe-coded-app-run-this-10-minute-secrets-audit", "title": "Before You Ship That Vibe-Coded App, Run This 10-Minute Secrets Audit", "summary": "A developer's viral account describes a vibe-coded booking app built with Cursor, Claude, Supabase, Stripe, OpenAI and Resend that shipped its OpenAI, Stripe secret and Resend keys in plain text inside the client JavaScript bundle. The post lays out a ten-minute audit: grep the built bundle for key-shaped strings, curl /.env to confirm it returns 404, set hard spending caps on every provider, rotate any key that touched a frontend or public repo, and move keys server-side behind an edge function such as /api/chat.", "body_md": "This week a post went viral in a vibe-coding group. A developer had built a booking app for a small studio with AI tools — Cursor and Claude for the code, Supabase for the backend, Stripe for payments, OpenAI and Resend for the rest. It worked. Customers booked. Then someone looked at what the app was actually shipping to every visitor's browser — and found the OpenAI key, the Stripe secret key, and the Resend key sitting in plain text in the JavaScript bundle.\n\nThe comments split instantly. Half the thread called it a rookie mistake; the other half pointed out that the same mistake is now being made at industrial scale, by people who never wrote a line of the code that made it. Both sides are right. And that is exactly why this audit matters: AI coding tools are very good at making things work, and very bad at telling you what you just exposed while doing it.\n\nHere is the ten-minute check that would have caught it.\n\nModern frontend frameworks inline certain environment variables into the JavaScript bundle at build time. That is by design — the browser cannot read your server's environment, so anything the client-side code needs has to be baked into the files it downloads.\n\nIn Vite, any variable prefixed with `VITE_` is exposed to client code. In Next.js, it is `NEXT_PUBLIC_`. The prefix is the whole security model: if a variable has that prefix, it is public. If an AI agent (or a tired human) puts an API key behind that prefix, the key ships to everyone who opens the page.\n\nThe same thing happens more quietly when a `.env` file ends up in the deployed folder, or when a key is pasted directly into source code \"just to get it working\" and never moved. The app works. The tests pass. The key is public.\n\nYour source code can look clean while the built bundle leaks. The bundle is what the browser gets, so check the bundle:\n\n```\n# Build, then search the output for anything key-shaped\nnpm run build\ngrep -r \"sk-live\" dist/ || echo \"no live Stripe key in bundle\"\ngrep -r \"sk-\" dist/ | head -20\ngrep -ri \"api[_-]key\" dist/ | head -20\n```\n\nAny hit is a leak, full stop. It does not matter whether the key \"looks\" unused — if it is in the bundle, a visitor can read it.\n\nBots scan the internet for `/.env` constantly. Check what your deployment returns for the paths that should not exist:\n\n```\ncurl -s -o /dev/null -w \"%{http_code}\\n\" https://your-app.com/.env\ncurl -s https://your-app.com/.env | head -5\n```\n\nThe first command should print `404`. The second should print nothing. If either shows file contents, your environment file is being served — fix the deployment before you fix anything else. The same test applies to `.env.local`, `config.json`, and any backup files sitting in the public folder.\n\nA leaked key with no spending limit is an open wallet. A leaked key with a $20 hard cap is an embarrassing afternoon. Before shipping, open every provider dashboard and confirm:\n\n`pk_`) in the browser and keep `sk_live_` on the server. Restricted keys with minimal permissions beat a full secret key everywhere.\nCaps do not prevent leaks. They limit the blast radius, which is the part you can control after the fact.\n\nIf a key has ever been in a frontend bundle, a public repo, a screenshot, or a chat log, treat it as compromised. Rotation is unglamorous and it is the only fix:\n\nIf you are unsure whether a key was exposed, rotate it anyway. The cost of rotating is minutes; the cost of guessing wrong is someone else's bill.\n\nThe durable fix is architectural, not a checklist item: **API keys live on the server, and the browser talks to your server instead.**\n\n``` js\n// Don't do this in the browser:\nconst res = await fetch(\"https://api.openai.com/v1/chat/completions\", {\n  headers: { Authorization: `Bearer ${import.meta.env.VITE_OPENAI_KEY}` },\n});\n\n// Do this instead — the key stays in an edge function:\nconst res = await fetch(\"/api/chat\", {\n  method: \"POST\",\n  body: JSON.stringify({ message }),\n});\n```\n\nThe `/api/chat` endpoint — a Supabase edge function, a Vercel serverless function, a tiny Express route, whatever your stack offers — holds the key, validates the request, and calls the provider. The browser never sees the key at all. This is the one structural change that makes checks 1–4 mostly unnecessary.\n\nTwo habits make it stick:\n\nThe reason this story hit a nerve is not that one app leaked three keys. It is that the failure mode is invisible to the person shipping the app. The AI agent did exactly what it was asked to do: build a working booking app. Security review was never part of the prompt, so it never happened.\n\nThat is the gap vibe coding creates. The tools compress the time from idea to working software from weeks to an afternoon — but they do not compress the review. The review is still your job, and it is the part that cannot be skipped just because the building got faster.\n\nTen minutes, four checks, before every deploy. The app you ship next will work just as well — and this time, only you will hold the keys to it.\n\n— Davis George · zhuan.xyz", "url": "https://wpnews.pro/news/before-you-ship-that-vibe-coded-app-run-this-10-minute-secrets-audit", "canonical_source": "https://dev.to/zhuanxyz/before-you-ship-that-vibe-coded-app-run-this-10-minute-secrets-audit-hbb", "published_at": "2026-11-21 13:41:05+00:00", "updated_at": "2026-11-21 13:41:49.836944+00:00", "lang": "en", "topics": ["ai-tools", "ai-agents", "developer-tools", "ai-safety"], "entities": ["Cursor", "Claude", "Supabase", "Stripe", "OpenAI", "Resend", "Vite", "Next.js"], "also_reported_by": [], "takeaway": "Vite's VITE_ and Next.js's NEXT_PUBLIC_ prefixes make any variable public, so grep the built dist/ bundle for sk- and api_key strings, confirm /.env returns 404, and proxy model calls through a server endpoint like /api/chat instead of calling OpenAI from the browser.", "recommendation": {"advice": "After any AI-assisted build, grep the production bundle for key-shaped strings and curl /.env for a 404, then rotate every exposed key and move it behind a server-side endpoint.", "playbook": "agent-security", "playbook_url": "https://wpnews.pro/playbooks/agent-security"}, "alternates": {"html": "https://wpnews.pro/news/before-you-ship-that-vibe-coded-app-run-this-10-minute-secrets-audit", "markdown": "https://wpnews.pro/news/before-you-ship-that-vibe-coded-app-run-this-10-minute-secrets-audit.md", "text": "https://wpnews.pro/news/before-you-ship-that-vibe-coded-app-run-this-10-minute-secrets-audit.txt", "jsonld": "https://wpnews.pro/news/before-you-ship-that-vibe-coded-app-run-this-10-minute-secrets-audit.jsonld"}}