Answers · App rescue

What is Supabase row level security, and is mine turned on?

In short

Row level security (RLS) is a set of rules inside your Postgres database that decides which rows each user may read or change. Your app's anon key sits in the browser where anyone can copy it, so RLS is the only thing stopping a stranger from reading every table. Check the Security Advisor in your Supabase dashboard today.

Why is the anon key safe only with RLS?

Supabase calls the anon (now "publishable") key safe to expose online because anyone can read it, so it only reaches what RLS allows. Its docs are blunt about the other side: a table in an exposed schema without RLS is readable and writable by any role with a grant on it. The security advisor labels that finding "Table publicly accessible".

The secret key, called service_role on older projects, is different. It bypasses every policy you write. It belongs on a server, never in a browser, a shipped app, or source control.

This is not a theoretical risk. CVE-2025-48757, published in May 2025, describes insufficient RLS policies in sites generated by Lovable through April 2025 that let unauthenticated attackers read or write arbitrary tables. Lovable disputes the record, saying each customer is responsible for their app's data. Either way, the fix sits in your project.

How do I check mine in the dashboard?

  • Open your project and go to Advisors, then Security Advisor. An error named rls_disabled_in_public means a table is open.
  • Look for rls_references_user_metadata. That means a policy trusts data the user can edit.
  • Then test it for real: sign in as one user and try to load a record that belongs to another. You should get nothing back.

What does a correct policy look like?

For a notes table where each row has an owner_id, this turns RLS on and lets signed-in users read and write only their own rows:

alter table public.notes enable row level security;

create policy "Owners read their notes"
on public.notes for select
to authenticated
using ( (select auth.uid()) = owner_id );

create policy "Owners add their notes"
on public.notes for insert
to authenticated
with check ( (select auth.uid()) = owner_id );

create index on public.notes (owner_id);

using limits which existing rows a query can touch. with check stops a user from writing a row owned by someone else. Naming the role with to authenticated and wrapping auth.uid() in a select follow Supabase's own guidance, as does the index on the column the policy filters on. Update and delete need their own policies.

Which mistakes are most common?

  • RLS on, no policies. Nothing can be read through the API, the app looks broken, and the quick fix someone reaches for is turning RLS off or writing using (true).
  • Policies on user-editable fields. A user can change their own user_metadata through the client library, so a role stored there can be set to "admin" by anyone. Supabase points to app_metadata for authorization data.
  • The service role key in the client. Every policy stops mattering. If it was ever shipped, delete it and create a new one, as Supabase advises for a leaked key.
  • Insert without with check. Users can read only their own rows but create rows for anyone.

If the advisor shows errors and you are not sure which rule your app needs, our rescue audit reads every table's policies and sends a written fix list within 48 hours.

Questions owners ask

Does turning on RLS break my app?

Until you add policies, yes: the app will see no data through the API. That is the safe failure. Add a policy per table and action, then test with two accounts.

Is a policy that says using (true) acceptable?

Only for data you mean to publish to the whole internet, such as a public list of blog posts. For anything tied to a user, it is the same as having RLS off.

Does Lovable check this for me?

Lovable's scan flags tables without RLS and rules that let everyone through, but its docs say the tools cannot guarantee complete security and that you are responsible for your app's data.

Want a second pair of eyes on your app?

The rescue audit is a written report within 48 hours of read-only access, with a fixed price for every fix.