Abbi Labs

Guides

Supabase "authenticated users only" policies: why any stranger who signs up passes them

By Abbi Labs · Last updated 21 November 2026

Scan your app free and see what a stranger can read without even signing up.

Abbi Labs checks your live site from the outside: Supabase tables readable with your public key, role-looking columns exposed to the anon role, secret keys in the JavaScript, exposed .env and .git files, security headers, CORS, cookie flags and TLS certificate expiry. Read-only. No sign-up for the quick check. For "any signed-in user" policies, use the free policy checker below.

No app handy?

No sign-up. Read-only public-resource and protocol metadata checks. No model prompts or tool execution. Scan only sites you own or are allowed to test.

Run on every deploy or use from Cursor / Claude Code via MCP →

Weekly AI-app security checklist

One short email a week: a practical check for apps built with Supabase, Next.js and AI tools (RLS, leaked keys, headers and more). Unsubscribe anytime.

You turned on RLS, your app shows each user their own stuff, and a signed-out curl gets nothing back. Feels done. Then you look at the policy your AI builder wrote and it says to authenticated using (true), or using (auth.role() = 'authenticated'). That policy doesn't mean "the right user". It means "anyone with an account". And on most Supabase projects, anyone can make an account.

Role and sign-up behaviour below is from Supabase's Row Level Security, anonymous sign-ins and Auth configuration docs, checked 21 November 2026.

Why "authenticated" is a much bigger group than you think

So the real test isn't "can a signed-out visitor read this". It's "can a brand new account read someone else's rows".

The policies that look safe and aren't

-- 1. Any signed-in account reads every row
create policy "Enable read for authenticated users"
on public.invoices for select
to authenticated
using (true);

-- 2. Same thing, older style
create policy "logged in users"
on public.invoices for select
using (auth.role() = 'authenticated');

-- 3. Same thing again
create policy "has session"
on public.invoices for select
using (auth.uid() is not null);

All three let a stranger who signed up a minute ago run supabase.from('invoices').select('*') and get everyone's invoices. On INSERT, UPDATE or DELETE it's worse: they can write rows under someone else's user_id, or edit and delete other people's data.

When it's fine: a table that every signed-in user really is meant to read, like a list of plans, a public feed for members, or app settings. The question to ask is whether you'd be OK with a random person who signed up with a throwaway email seeing all of it.

Find them in one query

Run this in the SQL Editor. It's read-only and only reads policy metadata, not your data.

select schemaname, tablename, policyname, cmd, roles, qual, with_check
from pg_policies
where schemaname = 'public'
  and (
    qual in ('true')
    or with_check in ('true')
    or qual ilike '%auth.role()%'
    or with_check ilike '%auth.role()%'
    or qual ilike '%auth.uid() is not null%'
    or with_check ilike '%auth.uid() is not null%'
  )
order by tablename, cmd;

For each row, look at the table name. Anything holding user data (profiles, orders, messages, invoices, uploads, chats) needs an ownership check, not just a role. Or paste the output of the policy checker's query into the free Supabase policy checker, which flags using (true) for authenticated, write policies that only check the caller is signed in on tables with a user_id-style column, and policies that never mention auth.uid().

Fix: tie the row to the user

drop policy "Enable read for authenticated users" on public.invoices;

create policy "own invoices"
on public.invoices for select
to authenticated
using ((select auth.uid()) = user_id);

create policy "insert own invoices"
on public.invoices for insert
to authenticated
with check ((select auth.uid()) = user_id);

create policy "update own invoices"
on public.invoices for update
to authenticated
using ((select auth.uid()) = user_id)
with check ((select auth.uid()) = user_id);

Keep to authenticated, it states who the policy is for. The auth.uid() part is what decides which rows. If rows are shared by a team, check membership instead, for example using (team_id in (select team_id from public.team_members where user_id = (select auth.uid()))), and make sure users can't insert themselves into team_members.

If you prompt your AI builder to do it, be specific: "Replace every RLS policy that uses true, auth.role() = 'authenticated' or auth.uid() is not null on tables with user data with policies that check auth.uid() = user_id. Don't change anything else and show me the SQL first."

Close the door too, if the app isn't public

Test it like a stranger would

  1. Sign up a second account with a different email (or in a private window).
  2. Open the browser console on your app while signed in as that account and run await supabase.from('invoices').select('*') (swap in your table).
  3. You should only see that account's rows. Try an update on a row id that belongs to your first account: it should change 0 rows.

To test in SQL without a second account, see testing RLS as a real user in the SQL Editor.

What Abbi Labs checks

Honest scope: the free outside scan reads your live site signed out, with your own public key, and reports which Supabase tables a stranger can read without an account, plus keys in your JavaScript, exposed .env and .git files, security headers, CORS, cookie flags and TLS expiry. It doesn't create accounts on your app, so it won't see a table that's only open to signed-in users. That's what the free policy checker is for: it runs in your browser on the output of one read-only query and flags "any signed-in user" policies like the ones above. Neither writes to your database.

Scan your app free

FAQ

Is a 'to authenticated' policy secure in Supabase?

Only if every signed-in user is allowed to see every row it covers. The authenticated role is any request with a valid user session. If your project allows new users to sign up (the default), anyone can create an account with your public key and get that role, even without using your app's sign-up screen.

What's the difference between to authenticated and auth.uid() = user_id?

to authenticated decides which role the policy applies to. It doesn't say which rows. using (true) then allows every row. auth.uid() = user_id is the part that limits a user to their own rows. Most user-owned tables need both: to authenticated using ((select auth.uid()) = user_id).

Is auth.role() = 'authenticated' the same thing?

In practice, yes. It passes for any signed-in user and says nothing about which rows are theirs. Supabase's own examples use the TO clause for roles and auth.uid() for ownership.

Can someone sign up to my Supabase app without using my sign-up page?

Yes. Your project URL and public (anon or publishable) key are in your site's JavaScript, and the Supabase Auth API accepts a sign-up call from anywhere while 'Allow new users to sign up' is on. Hiding the sign-up button doesn't close it.

Do anonymous users count as authenticated?

Yes. Supabase's docs say anonymous users assume the authenticated role. If you turned on anonymous sign-ins, every 'authenticated' policy covers them too, unless the policy checks auth.jwt()->>'is_anonymous'.

Should I just turn off sign-ups?

If the app is internal or invite-only, yes, it's one switch in Authentication settings and existing users can still sign in. If it's a public product, sign-ups have to stay on, so fix the policies instead.

Will the Supabase Security Advisor catch this?

Not always. A policy like using (auth.role() = 'authenticated') isn't literally using (true), so it can look fine to a pattern check while still opening every row to any account.

Related guides

Weekly AI-app security checklist

One short email a week: a practical check for apps built with Supabase, Next.js and AI tools (RLS, leaked keys, headers and more). Unsubscribe anytime.