A recent viral incident in the vibe-coding community has highlighted a critical infrastructure gap: AI-assisted development tools are rapidly shipping applications with sensitive API keys exposed in plain text. Davis George, writing on DEV.to, detailed a case where a booking app built with Cursor and Claude leaked its OpenAI, Stripe, and Resend keys directly into the JavaScript bundle. While half the community dismissed this as a rookie error, the other half correctly identified it as a systemic failure occurring at industrial scale, driven by developers who never manually wrote the vulnerable code.

The Mechanism of Exposure

The root cause lies in how modern frontend frameworks handle environment variables. In Vite, any variable prefixed with VITE_ is automatically inlined into the client-side bundle, while Next.js exposes variables prefixed with NEXT_PUBLIC_. AI agents, focused on functionality rather than security architecture, often place secret keys behind these prefixes to get the app running. Consequently, the keys are baked into the files downloaded by every visitor, effectively making server-side secrets public information.

Practical Audit Steps for Builders

George proposes a ten-minute audit that developers should run before every deployment. First, grep the build output, not just the source code, because the bundle is what the browser actually receives. Commands like grep -r "sk-live" dist/ can instantly reveal if a Stripe secret key has been accidentally included. Second, verify that server deployments do not serve .env files by checking for 404 responses on those paths. These checks catch the most common leaks that automated tests often miss because the application functions correctly despite the exposure.

Architectural Fixes Over Quick Patches

While rotating keys and setting hard spending caps on provider dashboards are essential damage-control measures, the durable fix is architectural. API keys must remain on the server, with the browser communicating through a proxy endpoint like a Supabase edge function or Vercel serverless function. This ensures the browser never sees the secret key. Additionally, implementing secret scanning in CI pipelines using tools like gitleaks can catch exposures at the commit stage, preventing them from reaching production.

Key Takeaways

  • AI coding tools excel at functionality but lack inherent security review, leading to frequent secret exposures in frontend bundles.
  • Framework prefixes like VITE_ and NEXT_PUBLIC_ are the primary vectors for leaking server-side secrets into client code.
  • Developers must audit build outputs (dist/) rather than just source code, as bundles contain the inlined variables sent to users.
  • The structural solution is routing all API calls through server-side functions so secrets never reach the client-side JavaScript.

The Bottom Line

Vibe coding compresses development time but does not compress security review. If you are shipping AI-generated code without manually auditing for exposed secrets, you are not building a product; you are building a public wallet.