# Is it safe to expose the Supabase anon key in my frontend?

Canonical: https://caelo.sh/guides/is-supabase-anon-key-safe-to-expose
Published: 2026-11-25 · Updated: 2026-11-27 · Arthi Arumugam, Caelo by Irth Labs

**Short answer:** Yes. The Supabase anon key (the legacy name; new projects use its replacement, the publishable key) is meant to be in your browser code, and anyone can read it. It is safe only when every table has row level security switched on with policies that limit each user to their own rows. Without that, the anon key lets anyone read or change your data. The service_role key is different: it bypasses all row level security and must never appear in frontend code, a mobile app or a public repository.

## What is the difference between the anon key and the service_role key?

- Anon (publishable) key: public by design. It identifies your project. What it can do is decided entirely by your row level security policies.
- The service_role key: a full-access admin key. It skips every row level security rule. Use it only on a server you control, never in the browser.
- Rule of thumb: if the key ships to users' devices, assume every user has it. Your database rules are the only lock.

## Why do apps get this wrong?

The anon key being public is not the problem. The problem is a public key combined with missing or loose database rules. A security firm's scan of over 5,600 public vibe-coded apps (about 4,000 of them built with Lovable) found the public key in browser bundles and reported 400+ exposed secrets and 175 instances of personal data.

In the write-up for CVE-2025-48757, researchers found 170 of 1,645 showcase apps on one AI app builder (about 10%) had database rules weak enough to expose data from homepage requests alone.

A note on names, checked 2026-11-27: Supabase now issues publishable keys (`sb_publishable_...`) and secret keys (`sb_secret_...`), and says it is deprecating the legacy anon and service_role keys in early 2027. The rule is the same for both generations. The anon or publishable key may ship to the browser. The service_role or secret key may not. Supabase rejects a secret key used from a browser with a 401, which the legacy service_role key does not do.

## How do you check your own app in 5 minutes?

1. In the Supabase dashboard of your own project, open the table editor. Any table marked as unrestricted, or with RLS disabled, is readable, and usually writable, with the anon key.
2. Read each policy. A condition of just true, or a rule for all authenticated users with no owner check, is effectively public.
3. Search your live site's JavaScript (browser developer tools, Sources tab) for the service_role key. If you find it, rotate it now: see our guide on leaked keys.
4. Open a private window and confirm a signed-out visitor sees no private data.

## Check your own app

1. Run the free local check: `npx caelo .` Caelo is a free, open source (MIT) command line tool and MCP server from Irth Labs that checks the files of an AI-built app for exposed API keys, Supabase and Firebase misconfigurations and `.env` files with real values. It runs on your machine, uploads nothing and uses no AI model. Each finding comes with a plain-English fix.
2. Follow the fix in the report and rerun Caelo. For an untracked, unignored file containing secrets, preview the US$19 quick fix. https://caelo.sh/fix
3. For an engineer's assessment, book the US$490 App Health Check. Irth Labs delivers a report and fixed repair quote, with credit toward the repair. https://www.irthlabs.com/start?service=app-health-check

## Questions

### Should I hide the anon key in an environment variable?

You can keep it in an environment variable for tidiness, but it still ships to the browser. Hiding it does not protect anything. Row level security does.

### Can someone abuse my anon key even with RLS on?

They can call your API with it, like your own app does. With correct policies they only reach what a normal visitor could. Add rate limits and email confirmation on sign-up to reduce abuse.

### I committed the service_role key to GitHub. Is deleting the commit enough?

No. Rotate the key first, because anyone may already have copied it. Then clean the history. Our leaked-key guide has the steps.

### Does this apply to the new publishable and secret keys?

Yes. The publishable key replaces the anon key and is public; the secret key replaces the service_role key and must stay on the server.

## Sources

- [Supabase docs: API keys.](https://supabase.com/docs/guides/getting-started/api-keys)
- [Supabase docs: Row Level Security.](https://supabase.com/docs/guides/database/postgres/row-level-security)
- [Escape.tech, 2025. How we discovered vulnerabilities in apps built with vibe coding platforms.](https://escape.tech/blog/methodology-how-we-discovered-vulnerabilities-apps-built-with-vibe-coding/)
- [Palmer and others, 2025. Statement on CVE-2025-48757.](https://mattpalmer.io/posts/2025/05/statement-on-CVE-2025-48757/)

## Related guides

- [How to check your Supabase row level security is actually working](https://caelo.sh/guides/supabase-rls-check)
- [I leaked an API key or the Supabase service_role key. What do I do now?](https://caelo.sh/guides/leaked-api-key-what-to-do)
- [Is my Lovable app secure? A 15-minute self-check](https://caelo.sh/guides/is-my-lovable-app-secure)
- [Is my v0 app secure? A check for v0 apps on Vercel](https://caelo.sh/guides/is-my-v0-app-secure)
- [Supabase service_role key exposed in the frontend: what to do now](https://caelo.sh/guides/supabase-service-role-key-exposed)
- [What does USING (true) mean in a Supabase RLS policy, and is it safe?](https://caelo.sh/guides/supabase-rls-using-true)
