RLS does not usually break in a dramatic way. A migration drops FORCE ROW LEVEL SECURITY, someone clicks a console form and adds USING (true) to a SELECT policy, or a helper function loses its pinned search_path. The app keeps working, the last audit report is still in a drive folder, and the catalog is no longer what that report described.
I ended up with ten read-only catalog checks that answer one question each: did the database change in a way that widens access? They query pg_class, pg_policies, pg_proc, pg_roles and information_schema only. No application rows, no writes, no service_role needed.
1. “RLS enabled” is two flags, not one
relrowsecurity = true only means policies are applied to non-owners. If relforcerowsecurity = false, the table owner still reads every row. Most migration roles are the owner, so this is the first thing I check:
SELECT n.nspname || '.' || c.relname AS table_name, c.relrowsecurity, c.relforcerowsecurity FROM pg_class c JOIN pg_namespace n ON n.oid = c.relnamespace WHERE c.relkind IN ('r','p') AND n.nspname = 'public'; The opposite mistake is assuming permission denied for table x means RLS. It is often a missing USAGE grant on the schema or a missing SELECT grant for anon/authenticated. has_table_privilege('anon','public.x','SELECT') and information_schema.role_table_grants answer that directly.
2. Policy text has to be read with its role and composition
A permissive SELECT policy with USING (true) is public reads, whatever the table's RLS flag says. A FOR ALL policy without WITH CHECK lets a user UPDATE a row into a state no policy would have allowed at insert time. And pg_policies.permissive stores the full string PERMISSIVE/RESTRICTIVE — a check for P/R silently returns nothing. Permissive policies combine with OR, restrictive ones with AND, so the effective predicate is not the text of any single row.
SELECT tablename, policyname, cmd, permissive, roles, qual, with_check FROM pg_policies WHERE schemaname = 'public' AND ((qual IS NULL OR qual = 'true') OR (cmd = 'ALL' AND (with_check IS NULL OR with_check = 'true'))); 3. Grants and definer functions are part of the same picture
An anon or authenticated role holding INSERT/UPDATE/DELETE is a write path even if the policies look careful. So is a SECURITY DEFINER function with no pinned search_path: it runs under its owner's rights, and if that owner has BYPASSRLS, table policies no longer constrain it. Ten minutes in information_schema.role_table_grants and pg_proc.proconfig has saved me more time than any policy review.
4. A scan is stale the moment you run it
The part I found missing in one-off audits is the diff. I capture the catalog findings once as a baseline, then on every run compare and report only NEW and RESOLVED items with a severity order. The job must fail closed: if the credential breaks, the workflow stops. It must never write an empty baseline and announce that all findings were resolved — a silent reader is not a clean database.
I packed those ten checks into a free n8n workflow (nightly schedule plus a manual “Run now”), with the same checks as a standalone SQL file: Supabase RLS Drift Monitor — https://kurtoglu1.gumroad.com/l/supabase-rls-drift-monitor-free. Read-only by design, first run silent, later runs report the diff. No support commitment, no service_role, no application data read.
Honest limits: this is a catalog diff, not an exploit test. It cannot tell you whether a policy matches what your team meant, and zero findings is not proof that the database is safe. Test on a scratch database before pointing anything at production. When I need one concrete question answered with evidence — for example, whether the anon key still reaches a table it should not — I use a documents-only spot check (fixed scope, starts only after payment is secured): https://kurtoglu1.gumroad.com/l/supabase-rls-spot-check.
If you have a check that caught something these ten would miss, I would genuinely like to hear it in the comments.
