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.
| Check | Severity | Why it matters |
|---|---|---|
| A public table with Row Level Security off | Critical | Anyone 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 true | Critical (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_metadata | Critical | Users 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 text | Critical | Those keys bypass every RLS policy and must never reach a browser. Source |
| Read policies whose condition is true | Warning (anon) / Info (signed-in) | Fine for public content, a leak for anything personal or per-user. Source |
| Policies with no TO role | Warning | Without 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 table | Warning | The 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 policy | Warning | Supabase 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 policies | Info | The 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?
Where do I find the RLS policies for a Lovable app?
If RLS is enabled, is my Lovable app's data safe?
Why does the checker want auth.uid() wrapped in (select …)?
What does “infinite recursion detected in policy for relation” mean?
Does a clean result mean my app is secure?
Sources
- Supabase database linter 0013: RLS Disabled in Public
- Supabase database linter 0007: Policy Exists RLS Disabled
- Supabase database linter 0008: RLS Enabled No Policy
- Supabase database linter 0003: Auth RLS InitPlan
- Supabase database linter 0015: RLS References user_metadata
- Supabase docs: Row Level Security
- Supabase docs: API keys
- PostgreSQL docs: CREATE POLICY