Supabase RLS bypass: how to find it in a React app

Updated November 17, 2026

Supabase gives the browser direct access to your database. Row-level security (RLS) is the only thing deciding who can read which rows. When RLS is off, misconfigured or bypassed, every signed-in user, and often every visitor, can read your whole table with the anon key that ships in your JavaScript bundle.

1. RLS is off on a table

New tables created with SQL don't have RLS enabled unless you turn it on. Check every table in public:

select tablename, rowsecurity
from pg_tables
where schemaname = 'public';

Any row with rowsecurity = false is readable and writable through the API by anyone holding your anon key.

2. A policy that allows everything

create policy "read" on profiles for select using (true);

using (true) means "everyone". Scope policies to the owner: using (auth.uid() = user_id).

3. The service-role key in client code

The service_role key skips RLS completely. If it appears in a file that runs in the browser, or in a variable prefixed NEXT_PUBLIC_ or VITE_, RLS doesn't matter any more. Keep it in server code only, and rotate it if it was ever shipped.

4. SECURITY DEFINER functions without checks

A Postgres function marked security definer runs with its owner's rights, which skips RLS. If it's callable through rpc() and doesn't check auth.uid() itself, it's a bypass:

create function get_user_email(id uuid) returns text
language sql security definer as $$
  select email from auth.users where users.id = id;  -- any caller, any user
$$;

Add an explicit check inside the function, set search_path, and revoke execute from anon and authenticated unless they need it.

Trusting the user id from the request

Even with perfect RLS, server routes that use the service-role client and take userId from the request body hand any user any other user's data. Read the user from the session on the server instead.

Scan for all of it

Periderm reads your migrations, your client code and your server routes together. It flags tables without RLS, permissive policies, service-role keys in client code, unchecked security definer functions and routes that trust a user id from the request:

npm i -g periderm-cli
periderm scan

more guides