Hire Lovable Xperts
RLS Policy Checker

Check your Lovable app's Supabase RLS policies

Paste your policies or a migration file and get severity-ranked findings, each with the SQL that fixes it. It runs in your browser: nothing you paste is uploaded.

Step 1: get your policies (run this read-only query in Supabase)

Open a SQL editor (Supabase: SQL Editor → New query; Lovable Cloud: Database → Manage → SQL editor), paste this, run it, then copy the single result cell. It only reads table and policy definitions. Or skip this and paste the migration files from your synced repo's supabase/migrations or drizzle/migrations folder.

-- Read-only: lists your public tables' RLS state and every public policy.
select string_agg(stmt, E'\n' order by ord, stmt) as rls_snapshot
from (
  select 1 as ord,
         format('alter table %I.%I %s row level security;',
                n.nspname, c.relname,
                case when c.relrowsecurity then 'enable' else 'disable' end) as stmt
  from pg_class c
  join pg_namespace n on n.oid = c.relnamespace
  where c.relkind in ('r', 'p') and n.nspname = 'public'
  union all
  select 2,
         format('create policy %I on %I.%I as %s for %s to %s%s%s;',
                policyname, schemaname, tablename, permissive, cmd,
                array_to_string(roles, ', '),
                coalesce(' using (' || qual || ')', ''),
                coalesce(' with check (' || with_check || ')', ''))
  from pg_policies
  where schemaname = 'public'
) s;

Checked in your browser. Nothing you paste is uploaded, stored or sent anywhere.

What the checker looks for

Each rule comes from Supabase's own database linter, the Supabase docs or the PostgreSQL docs. A table with RLS off is the plainest leak; the subtler ones are policies that exist but let everyone through.

Rules the Lovable RLS policy checker applies
CheckSeverityWhy it matters
A public table with Row Level Security offCriticalAnyone with your project URL and publishable key can read and change every row through the API. Policies on such a table do nothing. Source
Write policies whose condition is trueCritical (anon) / Warning (signed-in)Permissive policies combine with OR, so one using (true) or with check (true) on insert, update or delete opens the table. Source
Policies that trust user_metadataCriticalUsers can edit their own user_metadata, so a role or flag stored there can be set by anyone signed in. Source
A Supabase secret or service_role key in the pasted textCriticalThose keys bypass every RLS policy and must never reach a browser. Source
Read policies whose condition is trueWarning (anon) / Info (signed-in)Fine for public content, a leak for anything personal or per-user. Source
Policies with no TO roleWarningWithout TO, a policy applies to every role, signed-out visitors included. Supabase advises always naming the role. Source
A policy that selects from its own tableWarningThe classic cause of “infinite recursion detected in policy for relation”. The fix is a security definer helper outside your exposed schemas. Source
An UPDATE policy with no matching SELECT policyWarningSupabase needs a SELECT policy for a row to be updated, so saves silently change nothing. Source
auth.uid() or auth.jwt() not wrapped in (select …)Warning (performance)Unwrapped, the function can run once per row; wrapped, once per query. The checker writes the rewritten policy for you. Source
RLS on with no policiesInfoThe API returns nothing for that table, which is right for server-only tables and a bug if the app reads it. Source

What it can't see

  • It reads only the SQL you paste. It never connects to your database, so a policy changed in the dashboard after your last migration is invisible to it until you paste the snapshot query's result.
  • It doesn't check table grants, storage bucket settings, views, functions' bodies, Edge Functions or your frontend code.
  • It can't know your intent: a public read policy is right for a blog and wrong for invoices. Read each finding against what the table holds.
  • A clean result means none of these rules fired, not that the app is secure.

Those gaps are what a person checks. Our Lovable security audit covers RLS on every table, secrets including git history, auth and public endpoints. If a key or data has already leaked, start with breach response.

Guides for each finding

RLS policy checker: questions

Is it safe to paste my policies into this checker?
Yes. The check runs in your browser: the page makes no network request with what you paste and stores nothing. Policy definitions aren't secrets, but keys are, so don't paste them. If a Supabase secret or service_role key does end up in the box, the checker flags it so you know to rotate it.
Where do I find the RLS policies for a Lovable app?
Run the read-only snapshot query on this page in a SQL editor: Supabase's SQL Editor if the app uses your own Supabase project, or Database → Manage → SQL editor in Lovable Cloud. It returns one cell listing every public table's RLS state and every policy. You can also paste the migration files from your synced repository: supabase/migrations in older projects, drizzle/migrations in newer ones.
If RLS is enabled, is my Lovable app's data safe?
Not necessarily. RLS on with a policy like using (true) still lets everyone read or write every row, and a role check that reads user_metadata can be passed by any signed-in user. Enabled is the first step; the policies decide who sees what. This checker looks at both.
Why does the checker want auth.uid() wrapped in (select …)?
Supabase's database linter (lint 0003) warns that auth.uid(), auth.jwt(), auth.role() and auth.email() called directly in a policy can run once per row. Wrapping the call as (select auth.uid()) lets Postgres run it once per query and reuse the result, and Supabase says there is no downside. The checker gives you the rewritten policy to paste.
What does “infinite recursion detected in policy for relation” mean?
A policy on a table queries that same table, so checking the policy triggers the policy again. The checker flags any policy that selects from its own table and gives you a security definer helper to replace the subquery. Our step-by-step guide walks through both fixes.
Does a clean result mean my app is secure?
No. It means none of the rules on this page fired for the SQL you pasted. Grants, storage buckets, Edge Functions, exposed keys in your frontend and business-logic flaws are outside it. For a human review of all of those, see the Lovable security audit.