A Supabase app that runs in the browser ships its publishable key (the old anon key) in the page. Supabase's docs list it as safe to expose online: an API…
// the short version
A Supabase app that runs in the browser ships its publishable key (the old anon key) in the page. Supabase's docs list it as safe to expose online: an API key says which app is calling, not which person is asking. What decides who can read a row is Postgres Row Level Security (RLS).
// what to take away
- A Supabase app that runs in the browser ships its publishable key (the old anon key) in the page, and Supabase's docs list it as safe to expose: an API key says which app is calling, not which person is asking. What decides who can read a row is Postgres Row Level Security (RLS).
- Crissy Field and Handelsblatt looked at 159,041 Lovable projects in Common Crawl. On 7,403 of the 24,664 that sent Supabase records as soon as the page loaded, records with email addresses were readable without a login. The researchers say this is not a confirmed leak rate, and the report does not say which misconfiguration was behind each case.
- To lock your own table, per Supabase's RLS guide: enable row level security, revoke the default grants from anon and authenticated, write one policy per operation, and test allow and deny as both roles with supabase test db. Keep the secret (service_role) key on the server, because it bypasses RLS.
Why a Supabase app's key is in the page on purpose
A Supabase project is called with an API key on every request. Supabase's docs split keys by where the code runs. The publishable key (sb_publishable_..., the successor to the older anon key) is for anything you ship: a web page, a mobile app, a CLI. The docs list it as safe to expose online: anyone can read it from the page source or the build, so it only reaches what Row Level Security allows. The secret key (sb_secret_..., the successor to service_role) is for code you control, such as a server or an Edge Function, and must never leave your control, because it bypasses Row Level Security.
The docs are explicit about what a key is for: it identifies *what* is calling (a web page, an app, a server), not *who*. A signed-in user is identified separately, by Supabase Auth and their own token. Supabase's own picture is a building: the publishable key is taped to the front door and only opens the lobby; the secret key is the master key and stays in your pocket.
Supabase is deprecating the legacy anon and service_role keys by the end of 2026 in favour of publishable and secret keys. Both systems work side by side until the legacy keys are disabled in the dashboard.
What the Lovable study found, and what it did not say
Crissy Field GmbH, working with Handelsblatt (Lina Knees reported it on 2 November 2026), examined Lovable projects found in Common Crawl from December 2025 to September 2026:
- 159,041 Lovable projects identified.
- 34,545 of them used Supabase.
- 24,664 sent Supabase database records as soon as the page loaded, with no login. The researchers note that on its own this is not a security issue, because the data may be meant to be public.
- With further read-only requests, they found records containing email addresses in 10,560 tables across 7,403 of those 24,664 sites (30 %).
The researchers' own limits: email addresses can be public contact addresses or test data, records without an email are missed, and the 30 % should not be read as a confirmed leak rate. The sample is not representative of all Lovable apps. They retrieved only parts of the data and did not publish how to access it. They also note that Lovable's terms place responsibility for applications and data handling on its customers, and that Handelsblatt contacted Lovable with the findings.
The report does not say which misconfiguration caused each case. This page and the video describe how Supabase says data is meant to be protected; they do not claim that the researchers found Row Level Security switched off.
Row Level Security is the lock
Row Level Security (RLS) is a Postgres feature: authorization rules that run inside the database, attached to a table and checked every time the table is accessed. Supabase's docs describe a policy as adding a WHERE clause to every query. A policy like this one:
create policy "Individuals can view their own todos." on todos for select to authenticated using ( (select auth.uid()) = user_id );
means a signed-in user's select * from todos behaves as if it read where auth.uid() = todos.user_id. Every request maps to a Postgres role: anon for a request with the publishable key and no signed-in user, authenticated for a signed-in user. Policies are written for those two roles. The secret key's role, service_role, bypasses RLS.
Two checks run before a client touches a table. Grants decide whether a role may run an operation on the table at all; policies decide which rows it applies to. Supabase's docs warn that a table in an exposed schema without RLS is readable and writable by any role with a grant on it, and that on existing projects a new table in public starts with every privilege granted to anon, authenticated and service_role. Adding policies does not take those grants back.
Turning it on for your own table
Supabase's guide gives a procedure to follow for every table in an exposed schema. For a todos table owned row by row:
-- 1. Enable RLS. With RLS on and no policy, the publishable key gets no rows. alter table public.todos enable row level security; -- 2. Take back the default grants, then grant only what each role needs. revoke all on table public.todos from anon, authenticated; grant select, insert, update, delete on table public.todos to authenticated; -- 3. One policy per operation. create policy "Users can view their own todos." on todos for select to authenticated using ( (select auth.uid()) = user_id ); create policy "Users can create their own todos." on todos for insert to authenticated with check ( (select auth.uid()) = user_id ); create policy "Users can update their own todos." on todos for update to authenticated using ( (select auth.uid()) = user_id ) with check ( (select auth.uid()) = user_id ); create policy "Users can delete their own todos." on todos for delete to authenticated using ( (select auth.uid()) = user_id );
The docs explain the clauses: using decides which existing rows an operation can see or touch; with check decides what a new or updated row may look like, which stops a user creating a row for someone else or reassigning user_id. An update also needs a matching select policy to work as expected. Postgres does not accept several operations in one for clause, and the docs advise against for all, because it hides which operation each rule was meant to cover.
Then test it. The guide's fourth step is a .sql test file under supabase/tests/ that asserts allow and deny for select, insert, update and delete, for both anon and authenticated, run with supabase test db. In the docs' words, until the suite passes you don't know whether the policies do what you intended.
Two traps the docs call out
- Views bypass RLS by default, because they are usually created by the
postgresuser withsecurity definer. A view over a protected table can hand out every row its policies were meant to withhold; the docs have a section on exposing a view safely. - A policy that reads `to anon using ( true )` gives every signed-out visitor read access to every row the role can reach. It is right only for data that is meant to be public.
Terms
- Publishable key
- Supabase's client key (
sb_publishable_...), safe to ship in a web page or app; it reaches only what Row Level Security allows. - Secret key
- Supabase's server key (
sb_secret_...); it bypasses Row Level Security and must stay on servers you control. - anon key / service_role key
- The legacy JWT versions of the publishable and secret keys, being deprecated by the end of 2026.
- Row Level Security (RLS)
- Postgres rules attached to a table that decide, row by row, which rows each request may read or change.
- Policy
- One RLS rule for one operation (
select,insert,updateordelete) and one or more roles; it acts like aWHEREclause on every query. - Grant
- A Postgres privilege that lets a role run an operation on a table at all; checked before any policy.
- `auth.uid()`
- A Supabase helper that returns the ID of the signed-in user making the request.
- `anon` and `authenticated`
- The Postgres roles Supabase maps signed-out and signed-in requests to.
- Lovable
- A Swedish platform that turns plain-language descriptions into web applications; many of its projects use Supabase as their database.
Questions
Is it safe to put the Supabase anon key in frontend code?
Yes, by design. Supabase's docs list the publishable key (and its legacy form, the anon key) as safe to expose in web pages and apps. What protects the data is Row Level Security, so every table in an exposed schema needs RLS enabled, grants set and policies written.
How do I turn on Row Level Security in Supabase?
Run alter table public.<table> enable row level security; for each table, revoke the default grants from anon and authenticated, grant back only what each role needs, write one policy per operation, and test allow and deny for both roles with supabase test db.
What happens when RLS is enabled but there are no policies?
No data is accessible through the API with the publishable key until you create policies.
Did the Lovable study find that RLS was turned off?
The report does not say which misconfiguration was behind each case. It reports that records with email addresses were readable without a login on 7,403 of the 24,664 sites that sent records on page load, and warns that this is not a confirmed leak rate.
Where should the Supabase secret key go?
Only in code you control, such as a server, an API with its own authorization or an Edge Function. It bypasses Row Level Security, so it must never be bundled into a page or an app.
// further reading
- Supabase docs: Row Level Security ↗: the full procedure, policy patterns, tests and helper functions
- Supabase docs: API keys ↗: which key goes where, and how publishable and secret keys map to Postgres roles
- Supabase docs: Securing your API ↗: controlling which tables, columns and schemas the Data API exposes
- Crissy Field: Lovable apps expose sensitive data ↗: the research report, with its method and limits
// transcript
A Supabase app's database key sits right in the page, on purpose. Anyone can read it in the page, and Supabase itself calls it safe to expose, because the key only says which app is calling, not which person is asking. That difference is worth knowing after a study published in November. Crissy Field, working with Handelsblatt, looked at 159,041 Lovable projects in public web crawls. 24,664 of them sent records from Supabase as soon as the page loaded, and on 7,403 of those, they found records with email addresses readable without logging in. They say that's not a confirmed leak rate, since some addresses may be public contacts or test data, and they didn't publish how they reached it. So if the key is public, the lock has to be somewhere else, and in Supabase it's Postgres Row Level Security, rules that run inside the database and decide which rows each request can reach. Supabase describes a policy as a where clause added to every query, so a request for the whole table only comes back with the rows whose user id matches the person signed in. Switch it on, and nothing comes back through the public key until a policy allows it, and leave it off, and Supabase warns the table is readable and writable by any role that has a grant on it. Turning it on for your own table is one line, alter table, enable row level security. Then you take back the default grants, give signed-in users only what they need, and write one policy per operation, like a select that only matches rows where auth.uid() equals the row's user id. Supabase then has you write tests that try every operation as a signed-out and a signed-in user, because until they pass, you don't know the policy does what you meant. And the secret key skips all of this, so it never goes anywhere near the page. Lovable's terms leave the data to whoever builds the app, so the key was always meant to be seen, and the lock was always yours to turn.
// source
This explainer is based on Row Level Security by Supabase ↗. The original reporting and technical work belong to its publisher.