Skip to content
LockShip

Free tool · Supabase · Updated

Is my Supabase table public? A free RLS check you run yourself

Nothing you paste leaves this page. The check runs in your browser. There’s no upload, no account, and we don’t store anything. Once the page has loaded, you could switch off your Wi-Fi and it would still work.

In our guides we kept ending up at the same advice: run this query, then read the output slowly. That second part is the hard bit. A page of grants and policy expressions is a lot to take in when you just want to know whether a stranger can read your users table. So here’s the shortcut. Copy one read-only query, run it in your Supabase SQL Editor, paste what comes back, and this page tells you in plain words which tables are open, to whom, and which guide section fixes each one.

1. Copy the query

It only reads Postgres’s own catalog: table names, grants and policies. It doesn’t read a single row of your data and it can’t change anything. It covers the public schema, which is the one your app’s public key reaches.

SQL · read-only self-check
-- LockShip RLS self-check: https://lockship.dev/tools/supabase-rls-check
-- Read-only. It only looks at Postgres's own catalog: no rows from your tables, and it changes nothing.
-- For every table, view and database function in the public schema: is RLS on, what can the public key (anon)
-- and any signed-in user (authenticated) do, and which policies apply. The last row shows what new tables get.
with objects as (
  select c.oid,
         c.relname::text as name,
         case c.relkind when 'r' then 'table' when 'p' then 'table' when 'v' then 'view'
                        when 'm' then 'materialized view' when 'f' then 'foreign table' end as kind,
         c.relrowsecurity as rls_enabled,
         c.relforcerowsecurity as rls_forced,
         exists (select 1 from unnest(c.reloptions) o
                 where o ~* '^security_invoker=(true|on|yes|1)$') as security_invoker,
         exists (select 1 from pg_depend d
                 where d.classid = 'pg_class'::regclass and d.objid = c.oid and d.deptype = 'e') as from_extension
  from pg_class c
  join pg_namespace n on n.oid = c.relnamespace
  where n.nspname = 'public'
    and c.relkind in ('r', 'p', 'v', 'm', 'f')
),
access as (
  select o.oid, r.role, string_agg(p.priv, ', ' order by p.ord) as privileges
  from objects o
  cross join (values ('anon'), ('authenticated')) r(role)
  cross join (values (1, 'select'), (2, 'insert'), (3, 'update'), (4, 'delete')) p(ord, priv)
  where has_table_privilege(r.role, o.oid, p.priv)
     or (p.priv <> 'delete' and has_any_column_privilege(r.role, o.oid, p.priv))
  group by o.oid, r.role
),
policies as (
  select (quote_ident(schemaname) || '.' || quote_ident(tablename))::regclass::oid as oid,
         json_agg(json_build_object(
           'name', policyname,
           'command', lower(cmd),
           'roles', roles,
           'permissive', permissive = 'PERMISSIVE',
           'using', qual,
           'with_check', with_check
         ) order by policyname) as list
  from pg_policies
  where schemaname = 'public'
  group by 1
),
functions as (
  select p.oid,
         p.proname || '(' || pg_get_function_identity_arguments(p.oid) || ')' as name,
         p.prosecdef as security_definer
  from pg_proc p
  join pg_namespace n on n.oid = p.pronamespace
  where n.nspname = 'public'
    and p.prokind = 'f'
    and p.prorettype not in ('trigger'::regtype, 'event_trigger'::regtype)
    and not exists (select 1 from pg_depend d
                    where d.classid = 'pg_proc'::regclass and d.objid = p.oid and d.deptype = 'e')
),
new_tables as (
  select string_agg(a.privilege_type, ', ' order by a.privilege_type) filter (where a.grantee = 'anon'::regrole) as anon,
         string_agg(a.privilege_type, ', ' order by a.privilege_type) filter (where a.grantee = 'authenticated'::regrole) as authenticated
  from pg_default_acl d
  cross join lateral aclexplode(d.defaclacl) a
  where d.defaclrole = 'postgres'::regrole
    and d.defaclnamespace = 'public'::regnamespace
    and d.defaclobjtype = 'r'
    and a.privilege_type in ('SELECT', 'INSERT', 'UPDATE', 'DELETE')
)
select * from (
  select o.name, o.kind, o.rls_enabled, o.rls_forced, o.security_invoker,
         null::boolean as security_definer, o.from_extension,
         coalesce(an.privileges, '') as anon_can,
         coalesce(au.privileges, '') as authenticated_can,
         coalesce(p.list, '[]'::json) as policies
  from objects o
  left join access an on an.oid = o.oid and an.role = 'anon'
  left join access au on au.oid = o.oid and au.role = 'authenticated'
  left join policies p on p.oid = o.oid
  union all
  select f.name, 'function', null, null, null, f.security_definer, false,
         case when has_function_privilege('anon', f.oid, 'execute') then 'execute' else '' end,
         case when has_function_privilege('authenticated', f.oid, 'execute') then 'execute' else '' end,
         '[]'::json
  from functions f
  union all
  select '(new tables)', 'default for new tables', null, null, null, null, false,
         coalesce(lower(nt.anon), ''), coalesce(lower(nt.authenticated), ''), '[]'::json
  from new_tables nt
) result
order by case kind when 'table' then 1 when 'view' then 2 when 'materialized view' then 3
                   when 'foreign table' then 4 when 'function' then 5 else 6 end, name
limit 1000;

2. Run it in Supabase

  1. Open your project in the Supabase dashboard and go to SQL Editor.
  2. Start a new query, paste, and press Run. You’ll get one row per table, view and function, plus a last row about new tables.
  3. Above the results, open Export and choose Copy as JSON. Copy as CSV and Copy as Markdown work too.

The query ends with limit 1000, so the editor shows every row instead of stopping at its usual 100. If your builder runs the database for you and there’s no SQL editor in sight (Lovable Cloud, Bolt Database), paste the query into its chat and ask it to run it and show you the raw result as JSON.

3. Paste the result

Copy as JSON, Copy as CSV, Copy as Markdown or the downloaded CSV all work. This runs in your browser. Nothing you paste here is sent to us or anyone else.

What it looks for

Each table gets read the way Postgres reads it: first the grants, which decide whether the public key (the anon role) or a signed-in user (authenticated) may try something at all, then RLS and the policies, which decide which rows they get. Only when both let someone through does it count as open. That’s the difference from reading pg_policies on its own.

  • RLS off on a table the API roles can reach. Anyone with your public key can read it, and usually change it too. The fix starts with turning RLS on.
  • RLS on, but a policy lets everyone in. A using (true) for anon, or a policy with no to clause, which covers every role. Fine for a blog. Not for profiles or orders. See being deliberate about what is public.
  • Write policies that reach everyone’s rows. Update and delete with using (true), insert with with check (true), and update policies whose with check is (true) while using checks the owner. The fix is one policy per operation, tied to auth.uid().
  • Rules that trust user_metadata, which users can edit themselves (why).
  • Views that skip RLS and materialized views the API roles can read (checking your views), and security definer functions anyone can call at /rest/v1/rpc/ (locking down functions).
  • Grants RLS is quietly covering for, like write grants for the public key that no policy uses. Not open today, but one change away (trimming grants).
  • Whether new tables start closed. Supabase’s changelog says that from 30 October 2026, new tables on existing projects get no grants for the API roles until you add them. Tables you already had keep theirs. Our anon key guide covers what that change does and doesn’t fix.

One thing we got wrong before and want to be straight about: if an update policy has no with check at all, Postgres reuses the using rule for the changed row. We tested it on Postgres 15, 17 and 18, and a user couldn’t hand her row to someone else. So the check doesn’t flag a missing with check on update. It flags with check (true), which really does let the row say anything.

What it can’t tell you

  • Whether a narrow rule is the right rule. published = true or team_id = … look fine to a pattern check. Only you know whose data is whose, so do the two-account test from the RLS checklist too.
  • What a function called inside a policy really does, or what an invoker function returns. It flags security definer functions because those skip RLS.
  • Schemas other than public, storage buckets and their policies (our Storage guide covers those), and Edge Functions (see check 9 of the anon key guide).
  • Whether your app’s page really ships the public key and not the secret one. That needs a look from the outside.

We tested the query on real Postgres 15.19, 17.11 and 18.4 and on PGlite, each set up like a Supabase project with the anon, authenticated and service_role roles, the old default grants and then the 30 October ones, and a set of tables, views and functions we broke on purpose or set up properly. For each kind of hole the page reports, we first showed it was real by acting as the public key and as signed-in users. We haven’t run it on a hosted Supabase project, so if something looks off on yours, tell us at hi@lockship.dev.

Then check it from the outside

This page reads your rules. The free scan goes to your live app, finds the Supabase key your page ships and asks your tables for a row the way a stranger would. Paste your address, prove it’s yours, and see the worst thing it finds.

Run the free scan

Questions people ask

How do I check if RLS is enabled on my Supabase tables?

Run the query on this page in the Supabase SQL Editor. The rls_enabled column says whether row level security is on for each table in the public schema, and the anon_can and authenticated_can columns say what the public key and any signed-in user are allowed to try. Paste the result back here and the page reads it for you. Supabase’s Security Advisor also flags public tables with RLS off, but it doesn’t tell you which policies let everyone in.

Is it safe to paste my query result here?

Yes. The check runs in your browser and nothing you paste is sent to us or anyone else: no upload, no account, nothing stored. You can load the page, switch off your connection and it still works. The result holds the names of your tables, policies and functions, not any rows of data. It is still a map of your database, so don’t post it in a public forum.

My table has RLS turned on. Why is it still flagged?

Because RLS on is only half of it. A policy that says using (true) for the anon role lets every stranger read every row, and an update or delete policy with using (true) lets every signed-in user change everyone’s rows. The check reads each policy together with the grants, so it can tell a table that is truly locked from one where a policy opens it up again.

Does the 30 October 2026 Supabase change make this unnecessary?

No. Since 30 October 2026 Supabase no longer grants new tables to the API roles on existing projects, so a table you create now starts closed. Tables you already had keep their grants, RLS behaves exactly as before, and a grant added back later re-opens a table. The last row of the result shows whether new tables in your project start closed.

What does “RLS forced” mean?

Forcing RLS makes the policies apply to the table’s owner as well. The public key and signed-in users never own your tables, so it doesn’t change what they can reach. We show it so you have the full picture, but the check doesn’t flag it either way.

Does this work for Lovable Cloud or Bolt Database?

Both run on Supabase, so the query works anywhere you can run SQL against the database. If your builder doesn’t show you a SQL editor, paste the query into its chat and ask it to run it and show you the raw result as JSON, then paste that here.

Keep reading

Sources