Supabase RLS Not Working? Fix Leaks Between Users (2026)
You sign up with a second test account, open the dashboard, and there they are: the first account’s notes, orders or messages. Or a user emails you a screenshot of someone else’s invoice. RLS is “on”, the builder said the database was secure, and yet one user can see another user’s rows.
That’s the worst bug a small app can ship. If you searched for Supabase RLS not working, here’s the good news: it’s almost never Supabase being broken. The cause is nearly always one of a short list of holes: RLS off on one table, a policy that says using (true), rows with no owner, a secret key in the wrong place, a view or function that skips RLS, or a public storage bucket. This guide shows you how to find which one you have and the copy-paste SQL to close it. New to RLS? Start with the Supabase RLS explainer for the basics, then come back here to fix the leak.
Quick answer: If Supabase users can see other users’ data, check five things in order: RLS is enabled on every exposed table, no policy uses using (true) or only checks the role, every row has a user_id set to auth.uid(), no secret or service_role key runs in the browser, and views use security_invoker = true.
| What you see | Most likely cause | Check | Fix |
|---|---|---|---|
| Every user sees every row | RLS disabled on the table | pg_tables.rowsecurity is false | Enable RLS and add owner policies |
| Signed-in users see all rows, signed-out see none | Policy is to authenticated using (true) | List policies in pg_policies | Replace with (select auth.uid()) = user_id |
| New rows show up for everyone, or for nobody | user_id is null or never set | Count rows where user_id is null | Add default auth.uid() and backfill |
| A user can move a row to another account | UPDATE policy has no WITH CHECK | Read the policy definition | Add with check on insert and update |
| RLS works in tests, leaks in the app | Secret or service_role key in the frontend or a function | Search the bundle and functions for the key | Use the publishable key, rotate the secret |
| Table is safe, a view or rpc() leaks | View or function runs as its owner | Security Advisor 0010 and 0028 | security_invoker views, invoker functions |
| Anyone with a link can open files | Public storage bucket | Bucket settings | Private bucket plus storage.objects policies |
Want it fixed for you? Launch Mango moves your Lovable, Bolt, v0 or Cursor app onto your own GitHub, Supabase and Vercel accounts and makes it safe for real users. Own and Secure is $199 one-off: everything in Own Your App plus sign-in and redirects, Supabase RLS and permissions locked down, exposed API keys removed, live Stripe payments and webhooks, a security report and your custom domain included. Not sure how exposed you are? Run the free 2-minute app check.
Why Can Users See Other Users’ Data in Supabase?
Because something lets a request reach rows its policies should hide. Postgres checks grants first, then RLS policies, and any gap in either one leaks data. The usual gaps are RLS turned off, a policy that allows every row, rows with no owner, a key that bypasses RLS, or a view, function or bucket that skips it.

Every request from your app runs as a Postgres role. Your publishable key makes a signed-out visitor anon. A signed-in user’s session makes them authenticated. A secret key (or the legacy service_role key) runs as service_role. Supabase’s Row Level Security docs describe two checks: grants decide whether a role can touch a table at all, and policies decide which rows it gets.
A policy works like an invisible WHERE clause added to every query. That’s the whole trick. If the WHERE clause is missing, too loose, or skipped, every row comes back. Here’s who RLS applies to:
| Role | Who it is | Does RLS apply? |
|---|---|---|
anon | Requests with only your publishable key, signed out | Yes |
authenticated | Signed-in users, including anonymous sign-ins | Yes |
service_role | Secret key or legacy service_role key | No, it has BYPASSRLS |
postgres | Table owner, the SQL Editor by default, migrations | No, owners and superusers bypass it by default |
That last row explains a classic false alarm: you run a query in the SQL Editor, see every row, and think RLS is broken. It isn’t. The SQL Editor runs as the owner. You have to test as the user, which we cover below.
Is RLS Actually Enabled on Every Table?
Check it, don’t assume it. Query pg_tables in the SQL Editor and look at the rowsecurity column for every table in the public schema. Any table showing false is readable and writable by every role with a grant on it. Supabase’s Security Advisor flags the same problem as lint 0013, rls disabled in public.

Builders often enable RLS on the first tables they create, then skip it on a table added later in a quick prompt. Run this to see every table at once:
select tablename, rowsecurity
from pg_tables
where schemaname = 'public'
order by rowsecurity, tablename;
Tables with rowsecurity = false sort to the top. Per Postgres’s pg_tables reference, that column is true only when row security is enabled on the table. Turn it on for each one:
alter table public.your_table enable row level security;
Careful: the moment RLS is on with no policies, Postgres uses default deny and returns no rows to anon and authenticated. Your app will look empty until you add the policies in the next section. That’s expected and much better than a leak. Supabase’s docs also mention event triggers if you want RLS turned on automatically for every new table.
The reverse problem shows up too. Security Advisor lint 0007 policy exists rls disabled means someone wrote policies but never enabled RLS, so the policies do nothing at all.
Are Your RLS Policies Too Broad?
Very often, yes. A policy with using (true), or one that only says to authenticated, lets every signed-in user read every row. Postgres combines permissive policies with OR, so one loose leftover policy cancels a correct owner policy. List every policy in pg_policies, then drop or rewrite any that don’t compare auth.uid() to an owner column.

This is the number one cause of “RLS is on but users see each other’s data”. Here’s what a leaky setup looks like:
-- Leaks: every signed-in user reads every row
create policy "Enable read access for authenticated users"
on public.notes for select
to authenticated
using (true);
RLS is enabled. A policy exists. The dashboard shows a green shield. But true matches every row, so the only thing this policy checks is “are you logged in?” Per the Postgres CREATE POLICY docs, policies are permissive by default and all permissive policies that apply to a query are combined with OR. So even if you add a perfect owner policy later, the old using (true) one still lets every row through.
Find every policy and what it actually checks:
select tablename, policyname, cmd, roles, qual, with_check
from pg_policies
where schemaname = 'public'
order by tablename, cmd;
Look at the qual column (the USING part). Anything that reads true, or doesn’t mention auth.uid() or a membership check, is a suspect on any table holding private data. Replace it with an owner-only policy:
drop policy "Enable read access for authenticated users" on public.notes;
create policy "Users read own notes" on public.notes
for select to authenticated
using ((select auth.uid()) = user_id);
Supabase’s Security Advisor helps here too: lint 0024 permissive rls policy and 0006 multiple permissive policies point straight at these. Public data, like a published blog feed, can still use using (true), but only on tables where every row really is public.
Does Every Row Have a user_id Set to auth.uid()?
It needs to. An owner policy can only protect rows that record their owner. If the table has no user_id column, or inserts leave it null, policies either hide those rows from everyone or someone loosens the policy to make them visible. Add a user_id column that defaults to auth.uid(), backfill old rows and make it not null.

Builder-generated tables sometimes skip the owner column entirely, or rely on the frontend to send it. Check for orphan rows first:
select count(*) as rows_without_owner
from public.notes
where user_id is null;
If the column is missing or unreliable, this sets it up properly:
-- 1. Owner column, filled in by the database, not the browser
alter table public.notes
add column if not exists user_id uuid references auth.users (id) default auth.uid();
alter table public.notes
alter column user_id set default auth.uid();
-- 2. Backfill old rows to the right owner before this step
alter table public.notes
alter column user_id set not null;
-- 3. Index it, because every policy filters on it
create index if not exists notes_user_id_idx on public.notes using btree (user_id);
You have to decide who owns the old rows; SQL can’t guess that for you. Supabase’s docs recommend indexing every column your policies filter on, since an unindexed user_id turns each read into a full table scan. One more catch from the docs: auth.uid() returns null for signed-out requests, and null = user_id is never true, so a signed-out request matches no rows rather than erroring.
Do Your Insert and Update Policies Use WITH CHECK?
They should. USING decides which existing rows a user can touch. WITH CHECK decides what a new or changed row may look like. Without WITH CHECK on insert and update, a user can write rows owned by someone else or reassign their own row’s user_id to another account. Add with check ((select auth.uid()) = user_id) to both.

Leaks aren’t only about reading. If a user can insert a row with someone else’s user_id, that row lands in the victim’s account. Here’s the full, separate-policy-per-operation set Supabase’s docs recommend:
create policy "Users read own notes" on public.notes
for select to authenticated
using ((select auth.uid()) = user_id);
create policy "Users insert own notes" on public.notes
for insert to authenticated
with check ((select auth.uid()) = user_id);
create policy "Users update own notes" on public.notes
for update to authenticated
using ((select auth.uid()) = user_id)
with check ((select auth.uid()) = user_id);
create policy "Users delete own notes" on public.notes
for delete to authenticated
using ((select auth.uid()) = user_id);
Why separate policies instead of one for all? Supabase’s docs say a for all policy hides which operation each rule was meant to cover. Wrapping auth.uid() in (select ...) lets Postgres evaluate it once per statement instead of once per row, which keeps policies fast. And name the role with to authenticated so the policy never runs for anon.
While you’re in there, check grants. If a table still grants INSERT, UPDATE or DELETE to anon and nothing signed-out needs them, revoke them; the docs note that adding policies doesn’t take grants back. Our post on Supabase permission denied for table covers grants in detail.
revoke insert, update, delete on table public.notes from anon;
Is a Secret or service_role Key Bypassing RLS?
If your app or an Edge Function uses a secret key or the legacy service_role key, RLS never runs for those requests. Supabase says policies never apply to a secret key because service_role has the BYPASSRLS attribute. Use the publishable key in the browser, and inside functions use a client scoped to the signed-in user.

This one is sneaky because your policies can be perfect and you still leak. Supabase’s API keys docs put it plainly: the publishable key only reaches what RLS allows, while the secret key bypasses RLS and must never leave your control. Look for it in three places:
- Frontend env vars. Anything prefixed
VITE_orNEXT_PUBLIC_ends up in the browser bundle. AVITE_SUPABASE_SERVICE_ROLE_KEYis a public master key. See Vite env variables not working for how those prefixes work. - The client file. Open your
supabase.tsorclient.ts. The key passed tocreateClientin browser code must be the publishable key (sb_publishable_...) or the legacy anon key, neversb_secret_...or a service_role JWT. - Edge Functions and API routes. A function that builds its client with the secret key and returns rows for “the current user” is filtering in code, not in the database. Supabase’s Edge Function auth docs show
withSupabase({ auth: 'user' }), which gives you a client scoped to the caller’s RLS policies. Keep the admin client for jobs that truly need it.
If a secret key ever shipped to the browser, treat it as leaked: create a new one in the dashboard, update your server and functions, then delete the old key. Supabase is also deprecating the legacy anon and service_role keys by the end of 2026 in favor of publishable and secret keys, so this is a good moment to switch. The vibe-coded app security check lists the other places keys hide.
Are Views or Database Functions Leaking Rows?
They can, even when every table is locked down. Postgres views run with their owner’s privileges by default, and Supabase’s docs say that means views bypass RLS. Security definer functions run as their creator, usually postgres. Recreate views with security_invoker = true and switch functions to security invoker or check ownership inside them.

A dashboard view like order_summary that joins your users’ orders is a common leak. The table has perfect policies, the view ignores them. On Postgres 15 and above, the fix from Supabase’s docs is one option:
create or replace view public.order_summary
with (security_invoker = true)
as
select id, user_id, total, created_at
from public.orders;
-- or fix an existing view in place
alter view public.order_summary set (security_invoker = true);
Per the Postgres CREATE VIEW docs, security_invoker checks the underlying tables against the privileges of the user of the view rather than the view owner. Security Advisor lint 0010 security definer view lists the views that need it.
Functions called with supabase.rpc() need the same care. Supabase’s database functions docs say a security definer function can return rows the caller isn’t allowed to read, and any role can call it by default, including anon. Prefer security invoker (the default). If a function must be definer, check the caller inside it and lock down who can execute it:
create or replace function public.my_notes()
returns setof public.notes
language sql
security invoker
set search_path = ''
as $$
select * from public.notes where user_id = (select auth.uid());
$$;
revoke execute on function public.my_notes() from public, anon;
grant execute on function public.my_notes() to authenticated;
Lints 0028 anon security definer function executable and 0029 authenticated security definer function executable flag the definer functions anyone can call.
Are Your Supabase Storage Files Public?
Check each bucket. Supabase says a public bucket bypasses access controls for retrieving and serving files, so anyone with the file URL can open it. That’s fine for avatars and blog images, but not for invoices, IDs or user uploads. Make private buckets the default and add storage.objects policies that tie each file to its owner’s folder.

Storage is just another table, storage.objects, with its own RLS. Supabase’s bucket docs say buckets are private by default, but builders often flip a bucket to public to make image previews work. Store each user’s files under a folder named after their user id, then use the policy pattern from Supabase’s storage access control docs:
create policy "Users upload to own folder"
on storage.objects for insert
to authenticated
with check (
bucket_id = 'user-files'
and (storage.foldername(name))[1] = (select auth.jwt() ->> 'sub')
);
create policy "Users read own files"
on storage.objects for select
to authenticated
using (
bucket_id = 'user-files'
and (storage.foldername(name))[1] = (select auth.jwt() ->> 'sub')
);
Then serve private files with signed URLs instead of public ones. Security Advisor lint 0025 public bucket allows listing catches public buckets whose contents can also be listed.
Why Isn’t Filtering With .eq(‘user_id’) Enough?
Because they run in the browser, and the browser belongs to the user. A query like .eq(‘user_id’, user.id) only filters what your own code asks for. Anyone can open dev tools, copy your publishable key and request the table without the filter. Only RLS policies in the database actually stop them. Keep the filter for speed, never for security.

This is how most builder apps “work” while leaking. The screen only shows your own rows because the frontend asks for them:
// Looks safe, isn't: this filter is a request, not a rule
const { data } = await supabase
.from('notes')
.select('*')
.eq('user_id', user.id)
But your publishable key and project URL are in the page source by design. Here’s the same table, asked for by a stranger with no filter at all:
curl "https://YOUR_PROJECT.supabase.co/rest/v1/notes?select=*" \
-H "apikey: YOUR_PUBLISHABLE_KEY"
If that returns rows, you have a leak, whatever your app’s screens show. With owner policies in place, the same request returns an empty list, and a signed-in user’s unfiltered query returns only their own rows. The filter becomes optional, which is the point.
How Do You Test Supabase RLS as a Real User?
Switch roles inside a transaction in the SQL Editor, set the user id the policy will see, run your app’s queries, then roll back. Test as anon and as two different authenticated users. Then run the Security Advisor and call the REST API with only your publishable key. Supabase’s docs also recommend pgTAP tests run with supabase test db.

The SQL Editor runs as the owner, so it bypasses RLS. This snippet makes Postgres treat the query as a specific signed-in user, using the role and claim switch Supabase’s docs describe:
begin;
set local role authenticated;
set local request.jwt.claim.sub = 'USER_A_UUID';
select count(*) from public.notes; -- only user A's rows
select count(*) from public.notes where user_id <> 'USER_A_UUID'; -- expect 0
rollback;
Copy two real user ids from Authentication, Users. Run it once as user A, once as user B, and once as anon:
begin;
set local role anon;
select count(*) from public.notes; -- expect 0 for private tables
rollback;
| Test | Run as | Expected result |
|---|---|---|
| Read own rows | authenticated, user A | Only user A’s rows |
| Read someone else’s rows | authenticated, user A | 0 rows |
| Read private table signed out | anon | 0 rows or an error |
| Insert with another user_id | authenticated, user A | new row violates row-level security policy |
| REST call with publishable key only | anon | Empty list for private tables |
| Security Advisor | Dashboard | No 0007, 0010, 0013, 0024, 0025 or 0028 findings left |
Supabase’s Advisors docs say you can run the Security Advisor in Studio or with supabase db advisors from the CLI. Some findings may be intentional, so read each one against what the table should allow.
How Do You Fix RLS Leaks in Lovable, Bolt, v0 or Cursor Apps?
Fix it in the database, then make sure the fix lives in your code. Run the checks above on the Supabase project your live app actually uses, add the SQL as a migration in supabase/migrations, and remove any secret key from frontend code. Then retest with two accounts on the live URL, not just the preview.

- Check you’re on the right project. The live app reads its Supabase URL from env vars on the host. If it points at a different project than the one you just fixed, nothing changes for your users.
- Save the SQL as a migration. Lovable and Cursor projects with Supabase usually keep SQL files in
supabase/migrations. If you only fix things in the dashboard, the next generated migration can recreate a loose policy. - Prompt precisely. Ask the builder for owner-only policies per operation, with WITH CHECK on insert and update, on every table with user data. Then read the SQL it writes for any using (true) before you run it.
- Moved recently? If you migrated off Lovable or Bolt onto your own project, re-run the pg_tables and pg_policies queries there. Policies and bucket settings don’t always come across the way you expect.
Leaks like this are why one-click publish isn’t the same as production-ready. The full checklist to launch your vibe-coded app puts RLS alongside sign-in, keys and payments, in the order to fix them.
Supabase RLS Not Working FAQ

Why does the SQL Editor show every row even with RLS on?
Because the SQL Editor runs as the postgres role, which owns your tables. Table owners and superusers bypass row security by default, so you see everything. That doesn’t mean RLS is broken. Test as your users instead, with set local role authenticated and set local request.jwt.claim.sub inside a transaction that you roll back.
Why do users see each other’s data when RLS is enabled?
Usually because a policy is too broad. A policy with using (true) or one that only checks to authenticated lets every signed-in user read every row, and Postgres combines permissive policies with OR. Other causes are a secret key in the frontend, a security definer view or function, or rows missing a user_id.
Why does my app show no data after I enable RLS?
Because RLS with no matching policy returns no rows. Postgres uses default deny when RLS is on and no policy allows access, so reads come back empty without an error. Add a select policy for the authenticated role that compares (select auth.uid()) to your owner column, then insert, update and delete policies.
Does the service_role key respect RLS?
No. Supabase says policies never apply to a secret key, because service_role has the BYPASSRLS attribute. That includes the legacy service_role JWT. Use it only in server code you control, never in the browser or in VITE_ or NEXT_PUBLIC_ env variables, and use a user-scoped client for requests on behalf of a user.
Can I use user_metadata in RLS policies?
Not for security decisions. Supabase warns that raw_user_meta_data can be updated by the signed-in user, so a policy that trusts a role or team stored there can be bypassed. Store authorization data in app_meta_data, which users can’t change, or in your own table protected by RLS.
Do anonymous sign-ins use the anon role?
No. Supabase says an anonymous user in Supabase Auth assumes the authenticated role, not anon. A policy written to authenticated with using (true) therefore lets anonymous sign-ins read everything too. Owner policies based on auth.uid() still work, and you can check the is_anonymous claim in the JWT.
Want Your App Locked Down Before Real Users Find the Gap?
Closing one leaky policy takes a few lines of SQL. Checking every table, view, function, bucket and key, and keeping it all in migrations on accounts you own, takes longer. If you’d rather hand it off, Launch Mango’s Own and Secure plan locks down Supabase RLS and permissions for a flat $199.

Most data leaks in builder apps aren’t one bad policy. They’re the sign of an app that was built fast on someone else’s accounts, with RLS a mix of right, missing and wide open. The fix is owning it properly: your code, your database, your keys, with rules you can read.
That’s what we do at Launch Mango. Own and Secure ($199 one-off) is everything in Own Your App plus sign-in and redirects checked and fixed, Supabase RLS policies and permissions locked down, exposed API keys removed from the frontend, live Stripe payments and webhooks, a security report and your custom domain included. Own Your App ($79 one-off) moves your Lovable, Bolt, v0 or Cursor app onto your own GitHub, Supabase and Vercel accounts, live at a real URL with a plain-English handover report, usually in 1 to 2 days. Either way, money back if it isn’t live on your accounts.
Not sure how exposed your app is? Run the free 2-minute app check. Five quick questions flag your lock-in and security risks and tell you whether Own Your App or Own and Secure fits.
Your app, on your accounts, safe for real users.
