AI Project Estimate

Supabase RLS, Explained for Founders: Can Strangers Read Your Users' Data?

Alexander Rocket10 min read

They can if any table your app uses has row-level security (RLS) switched off, or has a rule that lets everyone in. Supabase apps talk to the database straight from the browser with a key that is public by design, so RLS rules are the only lock on your data. One query in the Supabase SQL Editor shows you which tables are open, and it takes about a minute.

What does Supabase RLS do, in plain words?

In a typical Supabase app, including the ones Lovable and Bolt generate, the browser sends requests straight to Supabase’s API with a publishable key (called the anon key on older projects). Supabase says that key is safe to put in a web page, a mobile app or source code (Supabase API keys). Anyone who opens your app can copy it.

That’s fine, because the key alone shouldn’t unlock anything. Row-level security is a set of rules on each table that says which rows a request may read or change. Supabase’s docs put it this way: once RLS is enabled, no data comes through the API with a publishable key until you create policies (Supabase RLS docs). A policy is one rule, such as “a signed-in user can read their own profile.”

So the question “can strangers read my data?” comes down to two checks: is RLS on for every table, and are the policies tighter than “everyone”?

How common is an open Supabase table?

Common enough to check today. A security firm, Crissy Field, scanned Lovable projects published between December 2025 and September 2026. Of the 34,545 that used Supabase, 24,664 (about 71%) showed Supabase records as soon as the page loaded, and 7,403 had records containing email addresses, according to Techzine. Some of those records may be meant to be public, so this isn’t a confirmed breach rate, but it shows how often data is reachable without a login.

There’s a simple reason it happens. Supabase turns RLS on by default for tables created in its Dashboard, but not for tables created with SQL, and it tells you to enable RLS yourself for tables made in the SQL Editor or another tool (Securing your API). If an AI tool wrote migrations that created your tables, check every one of them.

The one query that lists tables without RLS

Open your project in Supabase, go to the SQL Editor, paste this and press Run:

select schemaname, tablename
from pg_tables
where schemaname = 'public'
  and rowsecurity = false
order by tablename;

It returns every table in the public schema, the one Supabase’s API exposes by default, with RLS switched off. If you exposed other schemas, run it again with their names.

An empty result is what you want. Every row in the result is a table that anyone with your publishable key may be able to read and write, unless someone has removed the API’s access to it. Supabase’s Security Advisor flags the same problem as “Table publicly accessible”, at its highest level (Database Advisors).

The USING (true) trap

Here’s the catch. RLS can be on and the table can still be wide open. A policy has a condition, written after using, and a row is visible when the condition is true. If the condition is just true, every row is visible to everyone the policy covers.

Supabase’s own docs show such a policy for public profiles, with the warning to use it only for data that is meant to be public. They also note that a policy with no to clause applies to every role, including visitors who aren’t signed in (Supabase RLS docs). It’s an easy rule to add when a screen won’t load during building, and an easy one to forget.

This second query lists every policy whose condition is just true:

select tablename, policyname, roles, cmd, qual, with_check
from pg_policies
where schemaname = 'public'
  and (qual = 'true' or with_check = 'true')
order by tablename;

qual is the read condition and with_check is the condition for new or changed rows. A row with cmd SELECT and qual true means anyone covered can read the whole table. A row with INSERT and with_check true means anyone covered can add rows. Look at the roles column: {public} or {anon} means people who aren’t signed in.

Some results are fine: a blog’s posts or a product catalog are meant to be public. Users, orders, messages or payments are not. Supabase’s Security Advisor warns about these rules too, as “Security policy allows unrestricted access”.

What does a correct policy look like?

For a table where each row belongs to one user, the rule is “you can read your own rows.” This is the pattern from Supabase’s docs:

alter table public.profiles enable row level security;

create policy "Users can view their own profile"
on public.profiles for select
to authenticated
using ( (select auth.uid()) = user_id );

auth.uid() is the ID of the signed-in user making the request, and user_id is the column that says whose row it is. to authenticated keeps visitors who aren’t signed in out entirely. Supabase recommends wrapping auth.uid() in select and adding an index on the column the policy filters on, so the rule stays fast as the table grows.

Inserts, updates and deletes each need their own rule. Check two more traps while you’re there. Views skip RLS by default, because they’re usually created by the postgres user; on Postgres 15 and above you can make a view obey the rules with with (security_invoker = true). And a policy that trusts user metadata relies on data the user can edit, which the Advisor flags as an error.

The service_role key in the browser

Supabase has two kinds of keys. The publishable key (or legacy anon key) is meant to be public and is limited by RLS. The secret key (or legacy service_role key) is for servers only: Supabase says it gives full access to your project’s data, bypassing row-level security, and must never go in a browser, a shipped app or source control (Supabase API keys).

If an AI tool pasted the service_role key into your front-end code to get a feature working, every rule above stops mattering. Anyone can copy the key from your site and read or change everything. Supabase rejects its newer secret keys when they’re sent from a browser, but its docs point out that this doesn’t stop someone using a leaked key from other tools.

To check, open your live app, open the browser’s developer tools, search all loaded files (Ctrl+Shift+F, or Cmd+Option+F on a Mac) for service_role and sb_secret_, and search your code repository and its history for the same. If you find one:

  1. Move the code that needs the key to the server side, for example a Supabase Edge Function.
  2. Create a new secret key and switch the server code to it.
  3. Disable the old key. Legacy anon and service_role keys keep working until you disable them under Settings > API Keys.

What should you do with what you find?

What you findWhat it meansWhat to do
Query 1 returns tablesThose tables may be readable and writable with your public keyEnable RLS and write policies before adding users
Query 2 returns a users, orders or messages tableRLS is on, but the rule lets everyone inReplace true with a condition tied to auth.uid()
Query 2 returns only catalog or blog tablesPublic data, public ruleKeep, but make sure no private column sits in that table
A secret or service_role key in front-end codeEvery rule is bypassedMove the code to the server, issue a new key, disable the old one
Both queries are empty and no keys leakThe basics are in placeRun the Security Advisor and test with two accounts
Supabase RLS check results and what to do

Last, sign up as user A and user B and try to open A’s records as B. If you can, a rule is still wrong.

When should a person look at it?

The queries tell you whether a lock exists. They can’t tell you whether each rule matches how your app works, whether the server code checks permissions before using a secret key, or whether storage buckets and functions are open. That needs someone to read the code.

Our code audit covers this: who can see whose data, where keys are kept (old commits included) and what’s open to the internet that shouldn’t be. If the app needs more than fixes, our project rescue team can take it over.

FAQ

What is Supabase RLS?

Row-level security is a Postgres feature that Supabase uses to decide which rows each request can read or change. You switch it on per table and add policies, such as “users can read their own profile.” With RLS on and no policies, requests with the publishable key get no data.

Is the Supabase anon or publishable key safe to expose?

Yes, Supabase says the publishable key is safe in a web page or app. It’s only safe because RLS limits what it can reach. If a table has RLS off, or a policy that lets everyone in, the public key can read that table.

Does Supabase enable RLS by default?

For tables created in the Supabase Dashboard, yes. For tables created with SQL, in the SQL Editor or by another tool’s migrations, you enable it yourself. The first query in this article shows which tables still have it off.

Does the service_role key bypass RLS?

Yes. Supabase’s secret keys and the legacy service_role key give full access and skip RLS. Keep them on the server only, and if one ever reached the browser or your code history, replace it and disable the old key.

Is USING (true) ever OK in a Supabase policy?

For data that is meant to be public, such as published blog posts or a product catalog, yes. For anything tied to a person, like profiles, orders or messages, no. Replace it with a condition such as (select auth.uid()) = user_id.

How do I fix Supabase RLS without breaking my app?

Fix one table at a time on a copy of the project first. Enable RLS, add a policy for each action the app needs, then test with two accounts. If a screen stops loading, the fix is a tighter policy, not using (true).

Find out what your app exposes

Send us the repo and access to your Supabase project. In 5 working days you get a written report on who can reach your data, which keys are exposed, and what to fix first, with an hours range for each fix at $39 to $55 an hour. A fixed $3,500, and the report is yours to take to any team.

Book a code audit

The best of our blog, bi-weekly

Carefully curated content for resourceful Devs, CTOs, and PMs. No spam.

You may also like

Talk to us!

Send us a message and we'll get in touch with you as soon as we can.