Supabase row level security: how to check your tables aren't open
Updated 9 November 2026 · 7 min read
Every Supabase project ships two keys. The anon key goes into your website or app, so every visitor has it. The service role key stays on your server. What stops a visitor using the anon key to read your whole database is row level security (RLS): Postgres rules that decide, row by row, who can see or change what.
If a table has RLS switched off, the anon key can read and write all of it. This is one of the most common problems in apps built quickly with AI tools, because the table works perfectly in testing either way.
How to tell if a table is open
In the Supabase dashboard, the Table Editor marks tables without RLS as Unrestricted. In SQL, check your migrations: every create table in the public schema needs a matching line like this.
alter table profiles enable row level security;
Turning RLS on with no policies blocks everything for the anon key, which is a safe starting point. Then you add policies for what each user may do.
Owner-only policies
Most tables hold rows that belong to one user. Give each row a user_id and limit every action to its owner:
create policy "Users read their own profile"
on profiles for select
using (auth.uid() = user_id);
create policy "Users update their own profile"
on profiles for update
using (auth.uid() = user_id)
with check (auth.uid() = user_id);
using decides which existing rows a request can see or change. with check decides which new values it’s allowed to write, so a user can’t move a row to someone else’s user_id.
The policy that lets everyone in
RLS can be on and still let everyone through:
create policy "Enable read access for all users"
on profiles for select
using (true);
using (true) matches every row. That’s right for data that’s meant to be public, like published blog posts, and wrong for anything personal. It often comes from a dashboard template or an AI suggestion that “fixes” a permission error. Read every using (true) and with check (true) and ask: should a stranger see this?
The service role key in the browser
The service role key skips RLS completely. If it’s used in code that runs in the browser (a file marked "use client", or a variable starting with NEXT_PUBLIC_ or VITE_), your policies stop mattering. Keep it in server code only, and rotate it if it was ever shipped. Our guide on keeping secrets out of browser variables covers the variable side.
Test with two accounts
Code review catches missing RLS, but only a test proves a policy works. Sign in as user A, then try to read and update user B’s rows with the anon key. Each request should come back empty or be refused.
Which rules this relates to
An open table relates to GDPR Article 32 (security of processing), OWASP A01:2025 Broken Access Control and CWE-862 Missing Authorization. Supabase’s own row level security guide has the full policy syntax.
Checking it automatically
Lintsure reads every SQL file in your supabase/ folder together. It flags tables created without RLS (supabase.rls-disabled), policies that allow everyone (supabase.policy-allows-all) and the service role key in browser code (supabase.service-key-in-client). It runs on your machine and never uploads your code. Add it to your coding agent and ask: “Are any of my Supabase tables open?”
Check your own code
Lintsure runs these checks on your machine and never uploads your code.
npx lintsure scanThis guide is our own reading of public texts, written for software teams. It is not legal advice and it doesn't cover your whole obligation, only the parts code can show. Ask a qualified person before any audit or decision. Disclaimer