Lovable app security: RLS, keys, and auth
Lovable's own Supabase guide says missing row level security policies are the most common way app data gets exposed, and that secret keys must stay out of the client.
By ShipSecurely Editorial · Updated · How we make these guides
Shows up in: Supabase
What it is
Lovable's Supabase integration doc says the built-in backend uses Supabase's database, auth, storage, and edge functions, and that you can also connect your own Supabase project. The same page says Lovable checks Row Level Security coverage after schema changes, and that missing RLS policies are the most common way app data gets exposed.
Sign-in on that page is Supabase Auth: email and password, social login, and access control. A screen that hides a button is not that control. Supabase's securing-data guide says the publishable key is safe to put in the client only when RLS and grants are in place, and that a secret key bypasses RLS and must not be exposed.
Is my Lovable app missing row level security?
It can be. Lovable sets up basic row level security policies automatically, but Lovable's security guide says to review and adjust them yourself. Supabase's RLS guide says a table in an exposed schema without RLS is readable and writable by any role with a grant on it, and a to anon using ( true ) policy gives every signed-out visitor every row that role can reach.
If the app uses your own Supabase project, run these two checks in its SQL editor. The first lists tables in public with row level security off:
select tablename from pg_tables where schemaname = 'public' and rowsecurity = false;
The second lists policies whose USING expression (qual) or WITH CHECK expression (with_check) is just true:
select tablename, policyname, cmd, roles, qual, with_check from pg_policies where schemaname = 'public' and (qual = 'true' or with_check = 'true');
pg_tables.rowsecurity is true when row security is enabled on the table. In pg_policies, roles lists the roles the policy applies to and cmd is the command. Read every row either query returns. No rows does not prove the other policies are correct. The full audit, including grants, is in How to check if RLS is enabled on every Supabase table.
On Lovable's built-in backend, the policies view lists every policy: go to More > Database, select Manage, then Policies. Each row shows the command, who the policy applies to, and its rule expression. The view is read-only, so you change a policy by asking Lovable in the project chat. Lovable's Supabase doc says the in-editor Database view is for the built-in backend, and that with your own Supabase project you use the Supabase dashboard instead.
Lovable's Security view, under More > Security, runs two scans. The Quick scan, shown there as Quick security scan, runs on every publish and flags tables without row level security and access rules that let everyone through. The Deep scan, shown as Deep security scan, also reviews your app's code and does not run automatically as you work. Lovable says these scans cannot guarantee complete security.
CVE-2025-48757 describes an insufficient row level security policy in Lovable through 2025-04-15 that let remote unauthenticated attackers read or write arbitrary database tables of generated sites, and the record notes that the supplier disputes it because each Lovable customer accepts responsibility for protecting their application's data.
How to check in 5 minutes
In Lovable, open the database view and the Supabase dashboard. For each public table, confirm RLS is enabled and the policy names who can read and write a row. Lovable's doc says to verify this yourself, not only to trust the automated check.
Search the project for
VITE_and forSERVICE_ROLE. Lovable's secrets doc saysVITE_values are embedded in the client bundle, and thatSUPABASE_SERVICE_ROLE_KEYis injected into Edge Functions. It must not appear in frontend code.Sign out and send a SELECT request for a row you should not see, using the publishable key the client already has. A SELECT filtered out by RLS returns no rows, and a missing grant returns a permission error. Either is the pass. A row of someone else's data is the failure Supabase documents when RLS is off or the policy is open. An INSERT or UPDATE rejected by an RLS WITH CHECK policy can return 42501, per the 42501 troubleshooting page.
How to fix
Lovable
Ask Lovable to restrict each table to the signed-in user, then open the Supabase dashboard and read the policy. Lovable's integration doc gives the example prompt "Make sure users can only see and edit their own data." Put private keys in Secrets, not in .env under a VITE_ name. Lovable rejects a VITE_ name in Secrets and says those values belong in .env because they are browser-exposed.
Supabase
Enable RLS and add policies for anon and authenticated. Supabase's API key guide says policies never apply to a secret key, because service_role has BYPASSRLS. Keep that key in the Edge Function environment Lovable already populates. Do not prefix it with VITE_.
Copy the fix prompt
Paste this into Cursor, Lovable, Bolt, or Claude Code. Read the diff before you merge it.
You are fixing data access in a Lovable project. Do not add features. 1. List tables exposed to the client. Enable RLS and replace any policy that lets every caller read or write every row. 2. Search for VITE_ variables and for SERVICE_ROLE. Leave only publishable values in VITE_. Move secret keys into Lovable Secrets or Supabase edge-function secrets. 3. Show me the policy SQL and the file where the browser client is created. Do not claim the app is safe.
Questions
Is my Lovable app missing row level security?
It can be. Lovable sets up basic row level security policies automatically, but Lovable's security guide says to review and adjust them yourself. Supabase's RLS guide says a table in an exposed schema without RLS is readable and writable by any role with a grant on it, and a to anon using ( true ) policy gives every signed-out visitor every row that role can reach. On your own Supabase project, run select tablename from pg_tables where schemaname = 'public' and rowsecurity = false; and select tablename, policyname, cmd, roles, qual, with_check from pg_policies where schemaname = 'public' and (qual = 'true' or with_check = 'true'); in the SQL editor, and read every row they return. On Lovable's built-in backend, open the policies view under More > Database > Manage > Policies.
Does Lovable's publish scan replace reading the policies?
No. Lovable's security overview says the Quick scan runs on every publish, completes in seconds, and flags tables without row level security and access rules that let everyone through. The Deep scan is a separate pass that usually takes 3 to 13 minutes. Lovable says these scans cannot guarantee complete security, and its Supabase integration doc still says to verify policies yourself in the Supabase dashboard.
Are Lovable secrets copied when someone remixes the project?
Lovable's secrets doc says manually added secrets are not copied into a remix. Lovable-generated keys are recreated. A remixed app will not have your Stripe or model key unless someone pastes it again.
Sources
- Connect to Supabase
- Lovable secrets
- Security at Lovable
- Lovable security guide
- Control who can access your app's data
- Lovable security overview
- Project security view
- CVE-2025-48757 (NVD)
- Matt Palmer, CVE-2025-48757
- Securing your data
- Row Level Security
- PostgreSQL: pg_tables
- PostgreSQL: pg_policies
- PostgreSQL: CREATE POLICY
- Database API 42501 errors
Related
Guides
Need someone to fix it for you? See /help.
The weekly fix
The weekly fix: 3 real security mistakes in vibe-coded apps and how to fix them, every Tuesday.