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
- Critical: the bundle served to every visitor contained a Supabase service-role key, which bypasses every database policy.
- Medium: source maps with the original source were published next to the bundles.
- Low: three dependencies had known vulnerabilities with fixes available.
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.
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.
- Reset the service-role key in the Supabase dashboard.
- Move the helper that needs it into a server function; use the anon key in the browser.
- Set build.sourcemap to false for production.
- 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 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.