Case studies / Secret exposure
criticalVite · React · Supabase · Netlify

The side project whose server key was downloadable by every visitor

A weekend project built with Lovable went viral. The free Simple scan found a Supabase service-role key in the JavaScript bundle and source maps published alongside it. The key was rotated the same evening and the build settings fixed.

Composite case study: built from real Scanwright findings, with names, hosts and figures changed.

Team
One person, first app
Built with
Lovable
Scan
Simple (the free one)
Time to fix
One evening
Result
Key rotated, bundle clean on re-scan

The app

A small tool that turns a spreadsheet into a shareable page. It got picked up on social media and had a few thousand users within a week. The builder ran the free scan after reading that AI tools sometimes leak keys.

What the report said

Why it had not been caught

The AI had used the service key in a client-side helper because it made a query work. The variable was prefixed VITE_, so the build happily shipped it to the browser. The app ran perfectly.

The fix

Rotate the key, keep it on the server only, use the anon key in the browser with proper policies, and turn off source maps for production.

  1. Reset the service-role key in the Supabase dashboard.
  2. Move the helper that needs it into a server function; use the anon key in the browser.
  3. Set build.sourcemap to false for production.
  4. Update the three dependencies and re-run the free scan.
// vite.config.js
export default defineConfig({
  build: { sourcemap: false },
});
// .env: never prefix a secret with VITE_
The result
  • The re-scan found no secrets in the bundle and no source maps. The builder bought a Deep scan a month later when the app started charging.