Guide

Is your Lovable or Supabase app leaking data? How to check row level security

Apps built with Lovable, Bolt and v0 usually talk to Supabase straight from the browser, using a key that's public by design. That's fine, as long as every table has row level security (RLS) and sensible policies. If one doesn't, anyone who opens your site's code can read it, and often change it. Here's how to check, from the dashboard, with SQL, and from the outside the way an attacker would.

Updated 7 min read

Why the public key makes RLS non-negotiable

Supabase gives every project a publishable key (sb_publishable_..., or the legacy anon key). It's meant to ship in your frontend, so anyone can find it in your site's JavaScript. With it, they can call your database's Data API directly, skipping your app's screens entirely.

Supabase's docs put the rule in one sentence: a table in an exposed schema without RLS is readable and writable by any role with a grant on it. In most projects the exposed schema is public, where your app's tables live. RLS is the lock; policies are the list of who gets a key to which rows.

This isn't theoretical. In 2025 a researcher found that 170 of 1,645 apps in Lovable's public showcase exposed data this way, recorded as CVE-2025-48757 (Lovable disputes it, saying each customer is responsible for protecting their app's data). In February 2026, Wiz found a Supabase key in Moltbook's client-side JavaScript and, with RLS missing, could reach 1.5 million API tokens and 35,000 email addresses.

Check 1: the Security Advisor (two minutes)

Supabase lints your database for exactly these problems. Open your project's Security Advisor (in the dashboard under Advisors, or at /dashboard/project/<your-project>/advisors/security). These are the findings that matter most here:

LintWhat it meansDo this
rls_disabled_in_public (ERROR)Table publicly accessible: RLS is off, so anyone with your project URL can read, edit and delete it.Enable RLS and add policies (below).
permissive_rls_policy (WARN)A policy allows unrestricted access, like using (true).Scope it to the owner, unless the data really is public.
security_definer_view (ERROR)A view bypasses row level security.Recreate it with security_invoker.
policy_exists_rls_disabled (INFO)You wrote policies but RLS is off, so they do nothing.Enable RLS.
rls_enabled_no_policy (INFO)RLS is on with no policies: safe, but the API can't read anything.Add the policies your app needs.

Lovable runs its own security scan when you publish, which flags tables without RLS and overly permissive rules, and a deeper code scan you can run on demand. Both are worth running. Neither replaces looking at the policies yourself.

Check 2: ask the database directly

Open the SQL Editor in your Supabase dashboard and run these. They only read Postgres's own catalog; they change nothing.

SQL
-- Every table in public, and whether RLS is on. Anything with rls_enabled = false is open.
select
  c.relname as table_name,
  c.relrowsecurity as rls_enabled
from pg_class c
join pg_namespace n on n.oid = c.relnamespace
where n.nspname = 'public'
  and c.relkind in ('r', 'p')  -- ordinary and partitioned tables
order by c.relrowsecurity, c.relname;
The shorter select tablename, rowsecurity from pg_tables where schemaname = 'public'; gives the same answer for ordinary tables.
SQL
-- Every policy, who it applies to, and its conditions.
-- Look for qual or with_check = 'true' on tables that hold private data.
select tablename, policyname, roles, cmd, qual, with_check
from pg_policies
where schemaname = 'public'
order by tablename, cmd;
SQL
-- Tables with RLS on but no policies (safe, but your app can't read them through the API).
select c.relname as table_name
from pg_class c
join pg_namespace n on n.oid = c.relnamespace
where n.nspname = 'public'
  and c.relkind in ('r', 'p')
  and c.relrowsecurity
  and not exists (
    select 1 from pg_policies p
    where p.schemaname = 'public' and p.tablename = c.relname
  );
SQL
-- Views in public. A view runs with its creator's rights unless it has
-- security_invoker set, so it can show rows that RLS would hide.
select c.relname as view_name, c.reloptions
from pg_class c
join pg_namespace n on n.oid = c.relnamespace
where n.nspname = 'public' and c.relkind = 'v';
A view whose reloptions doesn't include security_invoker bypasses RLS on the tables it reads.

Reading the policies: cmd is the action (SELECT, INSERT, UPDATE, DELETE or ALL), roles is who it applies to ({public} means everyone, including signed-out visitors), qual is the condition for reading or changing existing rows, and with_check is the condition for new or updated rows. A qual of true means every row, for everyone the policy applies to.

Check 3: try it from outside, like an attacker would

This is the test that settles it. Find your project URL and publishable (or anon) key under Settings, API Keys in the dashboard (or in your site's JavaScript, which is the point). Then ask for a table with nothing but that key:

Terminal
curl 'https://YOUR_PROJECT_REF.supabase.co/rest/v1/profiles?select=*&limit=5' \
  -H "apikey: YOUR_PUBLISHABLE_OR_ANON_KEY"
Supabase's docs send publishable keys in the apikey header only. Swap profiles for each of your tables.
You get backIt means
Rows of real dataAnyone on the internet can read this table. Fix it now.
[] (an empty list)The table is empty, or RLS is on and no policy lets a signed-out visitor see rows. Usually what you want.
A permission errorThe anonymous role has no access to the table at all.

Do the same for writes if you're unsure: an insert that succeeds without signing in is worse than a read. Only test against your own project.

Fix it: enable RLS and write owner-only policies

For a table where each row belongs to a user (a user_id column holding the Supabase auth user's id), this is the standard pattern from Supabase's docs. Wrapping auth.uid() in select lets Postgres evaluate it once per query instead of once per row.

SQL
alter table public.notes enable row level security;

create policy "Owners can read their notes"
on public.notes for select
to authenticated
using ( (select auth.uid()) = user_id );

create policy "Owners can add notes"
on public.notes for insert
to authenticated
with check ( (select auth.uid()) = user_id );

create policy "Owners can update their notes"
on public.notes for update
to authenticated
using ( (select auth.uid()) = user_id )
with check ( (select auth.uid()) = user_id );

create policy "Owners can delete their notes"
on public.notes for delete
to authenticated
using ( (select auth.uid()) = user_id );
  • Enabling RLS with no policies blocks the API completely. Add the policies in the same migration, or your app will suddenly see empty lists.
  • Public data can stay public, deliberately. A blog or a product catalog can use for select to anon, authenticated using (true). Supabase's advice: use using (true) only for data that's meant to be public, and never for writes.
  • Fix views with alter view public.your_view set (security_invoker = on); (Postgres 15 and later) so they respect the RLS of the tables underneath.
  • Keep the secret key on the server. The secret (or legacy service_role) key bypasses RLS entirely. If it's in browser code, no policy can help: rotate it (here's how).

Storage buckets

Files have the same problem. A public bucket serves every file to anyone with the URL, no policy involved. A private bucket (the default) uses policies on storage.objects, and without them nobody can upload. Keep user uploads in private buckets with policies scoped to each user's folder.

Prove the fix works

  1. Rerun the curl test

    Every private table should now return [] or an error to a signed-out request.

  2. Rerun the Security Advisor

    The ERROR-level findings should be gone.

  3. Test as two users

    Sign in as user A, create something, then sign in as user B and make sure B can't see or change it. This catches policies that check that someone is signed in but not that it's their row.

  4. Click through your app

    Make sure the screens still load. An empty dashboard after enabling RLS usually means a missing select policy.

Where Corvis fits

The free repo scan reads the SQL migrations in a public repo and flags tables created without RLS, RLS being turned off, and policies that let everyone in. It can't see tables you made in the dashboard, so the checks above still matter.

Connect your Supabase project to Corvis and it checks, with the same public key your app ships, which tables anyone can read. When it finds one it tells you in plain English and, with your yes, turns on row level security for that table. It re-checks on a schedule, so a new table your AI coder adds next month doesn't slip through.

Sources

Checked against these pages on 24 October 2026. Providers change their dashboards; if a step looks different, the source has the current version.

  1. Supabase Docs: Row Level Security (opens in a new tab)
  2. Supabase Docs: Securing your API (opens in a new tab)
  3. Supabase Docs: Understanding API keys (opens in a new tab)
  4. Supabase Docs: Database Advisors (opens in a new tab)
  5. Supabase Docs: Data API quickstart (curl with the apikey header) (opens in a new tab)
  6. Supabase changelog: tables no longer exposed to the Data API automatically (opens in a new tab)
  7. Supabase Docs: Storage buckets (opens in a new tab)
  8. Supabase Docs: Storage access control (opens in a new tab)
  9. PostgreSQL Docs: pg_class (opens in a new tab)
  10. PostgreSQL Docs: pg_policies (opens in a new tab)
  11. Lovable Docs: Security (opens in a new tab)
  12. NVD: CVE-2025-48757 (opens in a new tab)
  13. Matt Palmer: Statement on CVE-2025-48757 (opens in a new tab)
  14. Wiz: Exposed Moltbook database (opens in a new tab)

Is your repo leaking right now?

The free scan checks a public GitHub repo for leaked keys and risky code, and grades it from A to F.

Scan a repo free