Guide
RLS is on but my Supabase data still leaks
The badge can say enabled and every row can still be public. A policy of using (true), a with check (true) added to silence an insert error, a policy that trusts user_metadata, or a SECURITY DEFINER function anon can call will do that. ShipShape Scan cannot see policies.
Where these statements come from
The SQL in this guide is the statement Supabase publishes, or it is marked as an edit not to ship. Read on 10 November 2026. Sources: Row Level Security, Database functions, and Securing your API. The RLS check covers grants, enabling RLS, and the optional event trigger. This page is the cases where RLS is already on and the data is still open.
A policy of using (true)
Supabase’s row level security guide uses this policy for profiles that are meant to be public. The same page says a policy that reads to anon using ( true ) grants every unauthenticated visitor read access to every row that role can already reach through grants. Use it only for data that is meant to be public.
create policy "Profiles are viewable by everyone" on profiles for select to authenticated, anon using ( true );
On a private table that policy is the leak. RLS is enabled, and the policy then adds every row back. Replace it with a policy that compares (select auth.uid()) to the owner column, for the role that should see the row. The RLS check has that select policy. Enabling RLS does not write it for you.
Do not silence the insert error with with check (true)
An insert that fails the policy comes back as Postgres error 42501. The message the Supabase client shows is new row violates row-level security policy for table …. Supabase’s row level security guide says a with check violation raises 42501, and that the with check expression is what stops a user from creating a row that belongs to someone else. The documented insert policy is this:
create policy "Users can create their own profile." on profiles for insert to authenticated with check ( (select auth.uid()) = user_id );
The edit that clears the error by deleting the check is the one to refuse. If the policy names anon, anyone who can call the API can insert.
-- Do not ship this. It clears the error by accepting every new row. create policy "allow any insert" on public.your_table for insert to authenticated with check ( true );
A different 42501 is permission denied for table. Supabase’s API security guide shows that message and the GRANT it is asking for. The grant runs before any policy. Disabling row level security does not add the grant, and it opens the table if a broad grant is already there. The 30 October explainer is that case. No insert policy at all also denies the insert: with RLS on and no policy, Postgres denies the row. Add a with check that matches the row you mean to allow.
Do not trust user_metadata
Supabase’s row level security guide warns that not every claim in the JWT belongs in a policy. A policy that relies on user_metadata is one of those. The same section says raw_user_meta_data can be updated by the authenticated user with supabase.auth.update(), and that it is not a place to store authorization data. raw_app_meta_data cannot be updated by the user. This is the policy to refuse:
-- Do not ship this. The signed-in user can edit user_metadata. create policy "admins only" on public.your_table for select to authenticated using ( (select auth.jwt() -> 'user_metadata' ->> 'role') = 'admin' );
The documented replacement reads app_metadata. Supabase’s example is a team id list:
create policy "User is in team" on my_table to authenticated using ( team_id in (select auth.jwt() -> 'app_metadata' -> 'teams'));
That page also says the JWT is not always up to date. Removing someone from the team does not show up in auth.jwt() until the token refreshes. A table you control, read from the policy, is the other place for a role that has to change immediately. Do not put that role where the user can write it.
Functions in public, especially SECURITY DEFINER
Row level security does not apply to functions. Supabase’s API security guide says to grant execute only to the roles that should call a function, and to review every security definer function. The functions guide says to prefer security invoker, which is the default. When you do use security definer, you must set search_path. Their example:
create or replace function hello_world() returns text language plpgsql security definer set search_path = '' as $$ begin return 'hello world'; end; $$;
A function created in the dashboard or by a migration is owned by postgres, which bypasses row level security. Any role can call it by default, including anon, the role for a request with no user session. PostgREST exposes a function in an exposed schema at /rest/v1/rpc/<name>. Pinning search_path does not change who can call it. An empty search_path means every name in the body has to be schema-qualified, which stops a caller from pointing an unqualified name at their own object.
Supabase’s row level security guide says a security definer function in an exposed schema is callable over the Data API with the creator’s privileges, and not to create one in a schema listed under Exposed schemas. The helper they show lives in private, with set search_path = '', and the policy calls private.has_good_role(). Revoke execute from public and from anon, then grant it only to the role that should call the function. The functions guide shows the revoke:
revoke execute on function public.hello_world from public; revoke execute on function public.hello_world from anon;
An execute grant decides who can call the function. It does not decide which rows they get back. A security definer function that returns per-user rows has to check ownership in the function body. Granting execute to authenticated still returns any user’s row to every signed-in caller if the body does not filter.
When an assistant fixes a permission error
A model that is asked to clear 42501 often does one of three things. Each one opens data the policy was supposed to hold.
It disables row level security. The table then follows grants only. Supabase’s API security guide says tables and views exposed through the Data API without RLS can be accessed by any role with a matching grant.
It adds using (true) or with check (true). The badge stays on. The policy allows every row.
It puts the service_role key, or a database connection string, in the client. Often the name starts with NEXT_PUBLIC_ or VITE_. Supabase’s row level security guide says service_role bypasses RLS and that the secret key stays server-side. A connection string with a password is the database password. On Supabase the direct connection user is postgres, which bypasses row level security. The env variable guide explains the prefix. The prefix is not a lock.
The check with two users
This is a check you run. The RLS guide spells it out. Create two users. Log in as user A and note the id of a row that belongs to A. Log in as user B and request that same id. User B’s response should not include A’s row. A policy of using (true) fails this test on purpose. It returns every row. ShipShape Scan does not log in, and it does not run this test.
What a passive scan can see
ShipShape fetches the public page, the same-origin scripts, seven fixed paths, and source maps those scripts name. It does not query tables and it does not test row level security. It does not call /rest/v1/rpc. It cannot see a policy, a grant, or a function body.
It can report a service_role key in that material, and a database connection string that carries a password (postgres://, mysql://, mongodb://, redis://, and the TLS form rediss://). The password is masked. The fix is to rotate it, move database access to server-only code, and keep it out of NEXT_PUBLIC_ and VITE_ variables. A grade of A does not mean the policies are right.
Questions
Why does data leak when the RLS badge says enabled?
Enabling row level security with no policy denies rows to anon and authenticated. A policy of using (true), or with check (true) on insert, allows every row that role can already reach through its grants. Supabase’s row level security guide says a policy that reads to anon using (true) grants every unauthenticated visitor read access to every row that role can reach. Use that only for data that is meant to be public.
Should I set with check (true) when insert fails row level security?
No. Supabase’s row level security guide says a with check violation raises 42501, and that with check is what stops a user from inserting a row for someone else. The documented shape is with check ( (select auth.uid()) = user_id ). with check (true) accepts any row. A different 42501, permission denied for table, is a missing GRANT. Do not disable row level security for either error.
Is user_metadata safe inside a policy?
No. Supabase’s row level security guide says a policy that relies on the user_metadata claim is unsafe, because an authenticated user can update raw_user_meta_data. Store the role in app_metadata, which the user cannot edit, or in a table you control. app_metadata inside the JWT stays stale until the token refreshes.
Can ShipShape see that my policies are wrong?
No. The free check does not query tables and does not test row level security. It can report a service_role key or a database connection string in the HTML or same-origin JavaScript. It cannot see policies, grants, or functions.