Fix guides

Your Lovable app may be exposing user data: how to check and lock it down

Researchers found thousands of Lovable apps whose Supabase tables were readable without a login. How to test your own project, turn on Row Level Security, and close the usual gaps.

Free · no card

Paste your error. Get a free diagnosis by email.

Tell us what broke and we’ll email you a short diagnosis: the likely cause and what to try first. Usually within a day.

No passwords or secret keys, please. We only use your email to reply about this.

What you are seeing

Why it happens

  1. The Supabase anon (publishable) key is meant to be public. Table access depends on Row Level Security. Many AI-generated apps ship with RLS off, so anyone who has the project URL and that key can read or change the data. This is a configuration gap in the generated app, not a break-in at Lovable.
  2. In November 2026, Hamburg firm Crissy Field published research (with Handelsblatt) on 159,041 Lovable projects found in Common Crawl between December 2025 and September 2026. Of the 34,545 that used Supabase, 24,664 sent database records on page load; further read-only requests with the same public key found email-bearing records in 10,560 tables across 7,403 of those sites. The researchers say that 30% figure is not a confirmed leak rate (some emails may be public contacts or test data, and records without emails were missed). Serious cases they inspected included passport details, payment data, 80,000 forum profiles with 200,000 chat messages, and in one case 280,000 customer emails.
  3. Views run as the view owner by default and can skip RLS on the underlying tables. See the view guide linked below.
  4. The service role key ended up in frontend code or a NEXT_PUBLIC_ / VITE_ variable, which bypasses RLS entirely.
  5. Storage buckets are public, or storage policies are missing, so files uploaded by users are listed or downloaded without a login.

How to fix it

1. Check your live app while signed out

Open your production URL in a private/incognito window so you are not logged in. Click through any page that shows users, orders, messages, uploads, or an admin table. If you can see other people's data without signing in, stop and treat that table as public until you finish the steps below. This check is only for an app you own.

2. See which tables have RLS off

select n.nspname as schema, c.relname as table_name, c.relrowsecurity as rls_on
from pg_class c
join pg_namespace n on n.oid = c.relnamespace
where n.nspname not in ('pg_catalog', 'information_schema', 'pg_toast')
  and c.relkind = 'r'
order by n.nspname, c.relname;

-- rls_on = false means the table has no row-level filter.
-- Run this in the SQL editor of your own Supabase project.

3. Confirm what the public anon key can read on your project

curl -sS "https://YOUR_PROJECT.supabase.co/rest/v1/YOUR_TABLE?select=*&limit=5" \
  -H "apikey: YOUR_ANON_KEY" \
  -H "Authorization: Bearer YOUR_ANON_KEY"

# Use your own project URL and the anon key already in your app
# (it is designed to be public; look in the built JavaScript or
# Supabase Settings, then API Keys).
# Replace YOUR_TABLE with each user-data table.
# A JSON array of other people's rows means that table is public.
# An empty array [] or an RLS error means reads are blocked.

4. Turn RLS on, then add owner policies

alter table public.YOUR_TABLE enable row level security;

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

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

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

create policy "owner can delete" on public.YOUR_TABLE
  for delete to authenticated
  using ((select auth.uid()) = user_id);

-- Enabling RLS does not delete data. The SQL editor and the
-- service role key still see every row. Browser requests using
-- the anon key now only see what a policy allows.
-- If your owner column is not named user_id, change the comparison.
-- Repeat for every user-data table. Public content (a blog, a
-- published catalog) can keep a separate select policy.

5. Check views, storage, and leaked service-role keys

select viewname from pg_views where schemaname = 'public';

grep -rn "service_role\|SERVICE_ROLE\|SUPABASE_SERVICE" src/ app/ .env* 2>/dev/null

-- If a view sits on user data, set it to security_invoker
-- (see the view guide). Check Storage policies too: a public
-- bucket lists files without a login.
-- If the service role key is in frontend code, rotate it in
-- Supabase first, then remove it from the client and redeploy.

6. Re-run Supabase's Security Advisor

In the Supabase Dashboard, open Advisors, then Security Advisor, and run it again. The rls_disabled_in_public finding should be gone for each table you fixed. You can also run: supabase db advisors --linked --type security

How to know it is fixed

A private window cannot read other users' rows. Two test accounts each see only their own data. The curl check against your project, using only the anon key and no user session, returns an empty array (or only rows you intended to be public). Security Advisor no longer flags those tables. Sources: Crissy Field: Lovable apps exposing sensitive data (November 2026; they note the report updates figures from the Handelsblatt article of 2 November 2026), Supabase: Row Level Security, and Supabase Advisors (including rls_disabled_in_public). Related: Supabase RLS not working and views that bypass RLS.