The two Supabase keys: one belongs in the browser, one is the master key
Supabase gives you two kinds of keys. The anon key (or new sb_publishable_ format) is meant to be public. The service role key (or sb_secret_) bypasses every database rule. Mix them up and anyone who reads your JavaScript owns your data.
What can go wrong
Supabase projects ship with an anon key and a service role key. The anon key is designed to live in your browser: it only works when Row Level Security (RLS, the per-row access rules on your tables) is configured correctly.
The service role key is a master key. It ignores RLS entirely. If it lands in client-side code, React components, or anything bundled for the browser, every visitor can read and write your database as an admin.
AI assistants often paste the wrong key into .env files or import the service role into a "use client" component because "the app needs database access."
It happened for real
In February 2026, researchers at Cognisys found a Lovable-built app with an anon key in the client bundle and no RLS on sensitive tables. Grepping the served JavaScript exposed roughly 30,000 records, including security PINs and one-time-password secrets (Cognisys disclosure, Feb 2026).
How to check yours
Seatbelt flags this automatically. A service_role JWT, sb_secret_ key, or legacy service-role material in client-reachable code is a must-fix hard gate. We also teach the difference: anon/sb_publishable_ keys belong in the browser only when RLS is on and correct.
Ask your agent: "Search my repo for service_role, sb_secret_, and Supabase JWTs in any file that ships to the browser. List file and line. The service role must live server-side only."
We don't catch this yet: Keys stored only in your hosting dashboard that never appear in the repo export you hand us.
Fix direction
Keep the anon/sb_publishable_ key in client code only when RLS protects every table. Move the service role to server-only routes. Never import it into a client component.
Paste into your agent: "Find any Supabase service role or sb_secret_ key in client code. Move database calls that need elevated access behind a server route. Rotate the service role if it was ever in the browser bundle."