Skip to content
Leakwise

How do I check if my Supabase tables are readable by anyone?

Request each table through the Supabase REST API using only your public anon key. If the response contains rows, anyone on the internet can read that table. Fix it by enabling Row Level Security and adding a policy that limits who can read.

Is it OK that my Supabase anon key is public?

Yes. The anon key is built to live in browser code. It only identifies your project. What the key can do is decided by Row Level Security (RLS). When RLS is on, a table returns only the rows your policies allow. When RLS is off, the anon key can read the whole table, and anyone can find that key in your JavaScript.

How do I test a table?

Take your project URL and anon key from the project settings. Then request one row from a table, using only the anon key:

curl "https://<project-ref>.supabase.co/rest/v1/<table>?select=*&limit=1" \
  -H "apikey: <anon-key>" \
  -H "Authorization: Bearer <anon-key>"

Read the result:

  • A JSON array with a row in it means the table is readable by anyone. Fix it now.
  • An empty array [] usually means RLS is on and no policy lets the anon role read. It can also mean the table is empty.
  • An error about permissions means the role has no access to the table.

Repeat this for every table in your public schema. Your frontend code shows many names in calls like supabase.from("profiles"). You can also list tables in the Supabase table editor.

How do I turn on RLS?

In the SQL editor, run this for each table:

alter table public.todos enable row level security;

With RLS on and no policies, the anon and authenticated roles get no rows. That is the safe starting point. Your app may stop showing data until you add policies. Test it before you ship.

How do I write a policy?

A policy says who may do what. This one lets a signed-in user read only their own rows. It assumes the table has a user_id column:

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

Add matching insert, update and delete policies for the actions your app needs. For writes, use with check to control the values being saved. Keep policies as narrow as you can. Avoid using (true) on a table with private data, because it lets everyone in.

What should I check after that?

  1. Run the curl test again with the anon key. You should get an empty array or an error.
  2. Sign in as one test user and try to read another user's row by ID.
  3. Make sure the service_role key is not in your frontend. See that guide.

Leakwise's deep scan, part of the $6 full report, runs this read test with the anon key against every table it can find, on sites you have verified you own.

Check your app

The free scan reads only what a browser downloads and takes under a minute. For a person to review your code, there is a human audit.