Skip to content

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)

  1. [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
  2. [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
  3. [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
  4. [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
  5. [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
  6. [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
  7. [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
  8. [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

  1. 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.
  2. 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.
  3. 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.
RuleSeverityFires when
rls-not-enabledHighA 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-trueHigh on update, delete and for all. Medium on selectusing (true), with or without extra parentheses.
with-check-trueHighwith check (true) on an insert, update or for all policy.
insert-without-with-checkHighA for insert policy with no with check clause.
update-without-with-checkMediumA for update policy with no with check clause.
clause-not-allowedHighusing on a for insert policy, or with check on a for select or for delete policy. Postgres refuses these.
no-to-roleMediumA policy with no to clause.
anon-writeHighAn insert, update, delete or for all policy whose to list names anon or public, or that has no to clause.
auth-call-not-wrappedLowauth.uid() or auth.jwt() in a policy expression where the word before it is not select.
missing-indexLowA 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:

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.

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:

← all toolsranked lists