Supabase RLS policy checker
Last updated . Rules checked against the docs on 2026-11-12.
A Supabase RLS policy is a Postgres rule that decides which rows a role can read or change. Enable RLS on every public table, name the role with TO, add WITH CHECK to insert and update policies, and write (select auth.uid()).
Paste the SQL for your tables and policies. The checker flags only what Supabase's RLS guide and the Postgres CREATE POLICY page describe, and quotes the line each finding rests on. Everything runs in your browser. No database connection, and your SQL is not sent anywhere or stored.
8 findings: 4 high, 2 medium, 2 low (example SQL)
[High] Table in the public schema without RLS enabled line 9
public.messages is in the public schema and the SQL never runs "alter table public.messages enable row level security". Its 1 policy does nothing until RLS is on.
"A table in an exposed schema without RLS is readable and writable by any role with a grant on it. Enable RLS on every table in an exposed schema." Row Level Security (Danger note at the top)
"These grants make new objects reachable through the Data API, even when you don't intend to expose them." Securing your API, Default privileges
"This expression will be added to queries that refer to the table if row-level security is enabled." CREATE POLICY, using_expression
[High] Insert policy without WITH CHECK line 19
INSERT policy "Users can create a profile" on public.profiles has no WITH CHECK, so nothing in it checks the new row.
"You can specify insert policies with the `with check` clause. The `with check` expression ensures that any new row adheres to the policy constraints, so a user cannot create a row that belongs to someone else." INSERT policies
[High] Write policy that applies to anon line 28
INSERT policy "Anyone can post" on public.messages names anon, so signed-out visitors can insert rows that pass it.
"`anon`: an unauthenticated request (the user is not signed in)" Authenticated and unauthenticated roles
"Only what signed-out visitors are meant to read" Grants and policies (role table, anon row, What it should keep)
"The default is PUBLIC, which will apply the policy to all roles." CREATE POLICY, role_name
[High] Policy with with check (true) line 31
INSERT policy "Anyone can post" on public.messages uses with check (true), so any new row passes, including one that belongs to someone else.
"When a WITH CHECK expression returns true for a row then that row is inserted or updated, while if false or null is returned then an error occurs." CREATE POLICY, Description
"The `with check` expression ensures that any new row adheres to the policy constraints, so a user cannot create a row that belongs to someone else." INSERT policies
[Medium] Policy with no TO role line 15
Policy "Users can view their own profile" on public.profiles has no TO clause, so it applies to PUBLIC, which is every role, anon included.
"Always name the role a policy applies to, using the `to` clause." Specify roles in your policies
"The role(s) to which the policy is to be applied. The default is PUBLIC, which will apply the policy to all roles." CREATE POLICY, role_name
[Medium] Update policy without WITH CHECK line 23
UPDATE policy "Users can update their own profile" on public.profiles has no WITH CHECK, so its USING expression also decides what the updated row may look like. Add a WITH CHECK that pins the owner column.
"The `with check` clause decides what the resulting row is allowed to look like, which stops a user from reassigning `user_id` to someone else." UPDATE policies
"If no `with check` expression is defined, the `using` expression decides both which rows are visible and which new rows are allowed." UPDATE policies
[Low] Policy filter column with no index in the pasted SQL line 15
Policy "Users can view their own profile" on public.profiles filters on user_id, and no index, primary key or unique constraint in the pasted SQL starts with user_id. Add: create index on public.profiles using btree (user_id);
"Add an index on every column your policies filter on. Postgres evaluates the policy against each candidate row, so an unindexed filter column turns a read into a sequential scan." Add indexes
"A column counts as indexed only when it comes first in a `btree` index." Add indexes
"PostgreSQL automatically creates a unique index when a unique constraint or primary key is defined for a table." Unique indexes
[Low] auth.uid() or auth.jwt() called without (select ...) line 17
Policy "Users can view their own profile" on public.profiles calls auth.uid() directly. Write (select auth.uid()) so Postgres runs it once per statement instead of once per row.
"This method works well for JWT functions like `auth.uid()` and `auth.jwt()` as well as `security definer` Functions. Wrapping the function causes an `initPlan` to be run by the Postgres optimizer, which allows it to "cache" the results per-statement, rather than calling the function on each row." Call functions with select
"Caution: You can only use this technique if the results of the query or function do not change based on the row data." Call functions with select
The check runs in this page. The SQL never leaves your browser and is not stored.
How it works
- A small tokenizer, written for this page, splits the text into words, quoted names, strings and symbols. It skips -- and /* */ comments and keeps $$ function bodies in one piece, then cuts statements at semicolons.
- It reads six kinds of statement: create table, alter table (enable or disable row level security, primary key, unique), create index, create policy, drop policy and drop table. It ignores everything else.
- It applies the rules in the table below. Each rule quotes Supabase's or Postgres's docs, and each finding shows that quote and a link to the doc section.
| Rule | Severity | Fires when |
|---|---|---|
| rls-not-enabled | High | A table created in the public schema (or with no schema, which Postgres puts in public) and no later alter table ... enable row level security for it. |
| using-true | High on update, delete and for all. Medium on select | using (true), with or without extra parentheses. |
| with-check-true | High | with check (true) on an insert, update or for all policy. |
| insert-without-with-check | High | A for insert policy with no with check clause. |
| update-without-with-check | Medium | A for update policy with no with check clause. |
| clause-not-allowed | High | using on a for insert policy, or with check on a for select or for delete policy. Postgres refuses these. |
| no-to-role | Medium | A policy with no to clause. |
| anon-write | High | An insert, update, delete or for all policy whose to list names anon or public, or that has no to clause. |
| auth-call-not-wrapped | Low | auth.uid() or auth.jwt() in a policy expression where the word before it is not select. |
| missing-index | Low | A policy compares a column to auth.uid() with =, the table's create table is in the paste, and no create index (btree), primary key or unique constraint in the paste starts with that column. |
A policy the docs would write passes every rule. This one from Supabase's guide gives no findings:
create policy "Users can update their own profile." on profiles for update to authenticated using ( (select auth.uid()) = user_id ) with check ( (select auth.uid()) = user_id );
What it cannot see
This is a text scanner, not a Postgres parser, and it never connects to your database. It misses:
- Dynamic SQL, such as execute format(...) inside a function or a DO block.
- Function bodies. It does not check security definer functions, their search_path, or what a function called from a policy does.
- Grants and revokes. Supabase's docs say grants decide whether a role can touch a table at all and that adding policies does not remove them. Check those with the queries in Check your default privileges.
- Your live database. Tables, policies and indexes made in the dashboard or in a migration you did not paste do not exist for the checker. The RLS rule only fires for tables whose create table is in the paste.
- Other exposed schemas. It flags tables in public only. If you expose more schemas in the Data API settings, check those tables by hand. It also does not follow set search_path.
- alter policy, views (Supabase's docs say views bypass RLS by default; see Views and RLS), how permissive and restrictive policies combine, joins inside policies, and recursive policies.
- Index details. It counts any btree index whose first column matches, partial or not, and only checks columns compared to auth.uid() with =.
No findings does not mean the policies are right. Supabase's guide says to write a pgTAP test file per table and run supabase test db: "Until the suite passes, you don't know whether the policies do what you intended."
Sources
Each page was fetched on 2026-11-12. The sha256 is of the copy fetched, so you can tell if the page has changed since.
- Supabase docs, Row Level Security. Checked 2026-11-12. Fetched from https://supabase.com/docs/guides/database/postgres/row-level-security.md, sha256
f59323752afcad187709f128ca41602491d495f252a71676e7ef489f1bbeb460. - Supabase docs, Securing your API. Checked 2026-11-12. Fetched from https://supabase.com/docs/guides/api/securing-your-api.md, sha256
f0d76ef73192de9859b111d33a1521049be84b9164fc0c502e928ad393863597. - PostgreSQL 18 docs, CREATE POLICY. Checked 2026-11-12. Fetched from https://www.postgresql.org/docs/current/sql-createpolicy.html, sha256
fd38b691c3a015b2bd6ae71d66d9f939fab18315a21e6c9bb6196c4c677b1eda. - PostgreSQL 18 docs, Unique indexes. Checked 2026-11-12. Fetched from https://www.postgresql.org/docs/current/indexes-unique.html, sha256
89c23456c50805b76a6eb18c95339a5b074aa929cad874deec2ace1bb3bc12ff. - PostgreSQL 18 docs, CREATE INDEX. Checked 2026-11-12. Fetched from https://www.postgresql.org/docs/current/sql-createindex.html, sha256
913765bae87275e61983a2efd1da3b3d9fde82654d7cda2e713b9dcf763edf39. - PostgreSQL 18 docs, Schemas (the public schema). Checked 2026-11-12. Fetched from https://www.postgresql.org/docs/current/ddl-schemas.html, sha256
5539e7d2846be8b1f3edf582de621d8b98ec14b12e2642a701d45e5299634d9c.
FAQ
How do I write a Supabase RLS policy for authenticated users?
Name the role with to authenticated and compare the owner column to the signed-in user. Supabase's docs use: create policy "Users can view their own profile." on profiles for select to authenticated using ( (select auth.uid()) = user_id ); The to clause stops the policy from running for anon requests.
How do I write a Supabase RLS insert policy?
Use with check, not using. Postgres does not accept a using clause on an insert policy. Supabase's example is: create policy "Users can create their own profile." on profiles for insert to authenticated with check ( (select auth.uid()) = user_id ); The with check stops a user from creating a row that belongs to someone else.
Why does my Supabase update policy not work?
Supabase's docs say an update needs a matching select policy: "To perform an UPDATE operation, a corresponding SELECT policy is required." Also check the grants. A missing grant raises error 42501 before any policy runs.
How do I write an RLS policy that joins another table?
Use exists (select 1 from other_table where ...) inside using, as in Supabase's roles_table example. If two tables' policies read each other, Postgres raises 42P17, infinite recursion detected in policy. Supabase's fix is a security definer function in a private schema with set search_path = ''. This checker does not follow joins or functions, so test these policies with pgTAP.
Is using (true) ever fine in a Supabase policy?
On a select policy, yes, for data that is meant to be public. Supabase's docs say a policy that reads to anon using ( true ) gives every signed-out visitor read access, and to "use it only for data that is meant to be public." On an update, delete or for all policy it opens every row to change.
Why wrap auth.uid() in select?
Supabase's docs say (select auth.uid()) makes the Postgres optimizer run an initPlan that caches the result per statement instead of calling the function on each row. The same applies to auth.jwt(). It only works when the result does not depend on the row.
Does this checker send my SQL anywhere?
No. The scan runs in your browser with a small tokenizer written for this page. There is no database connection and no request with your SQL. Nothing is stored.
Need someone to fix it?
If the checker turns up open tables in an app built with Lovable or another AI builder, these ranked lists cover teams that do this work: