Lovable is a builder. How safe the app you built with it is depends mostly on two things you control:
- the rules in your database that decide who may read and change each record
- what your app hands to every visitor's browser
This guide covers the six checks that matter most for a Lovable app on Supabase. Each is done in a dashboard or a browser, with a prompt to paste into Lovable's chat to fix what you find.
What Lovable already checks for you
Lovable's documentation describes automatic checks that run before you publish. They look for:
- a table without per-row rules
- a rule that lets everyone in
- leaked-password protection turned off
- file storage rules
- code libraries with critical known flaws
It also describes advanced checks that read your app's code across sign-in, access permissions, private data, keys and passwords, user input, app actions and payments. You find both under More, then Security, in the project toolbar.
The same documentation is direct about the limits. The checks find common problems but cannot guarantee your app is secure or replace a full security review, and you stay responsible for your app's security. It recommends a review by a security professional for apps that handle sensitive data.
So run Lovable's checks first, fix what they find, then do the six checks below.
Check 1: Row Level Security is on for every table
Supabase keeps your data in tables. Row Level Security, or RLS, is the database's own set of rules about who may read or change each row (one row is one record, such as one order).
Your app's public key is in every visitor's browser by design, so the rules are what stand between a stranger and your data. Supabase's documentation says to enable RLS on every table in an exposed schema, and that a table there without RLS is readable and writable by any role with a grant on it.
How to check:
- Open your Supabase project, go to the Table Editor and look at each table. A table without RLS is marked as such.
- Or open the SQL editor and run this read-only query. It lists every table in the public schema with true or false for RLS.
Query
select tablename, rowsecurity from pg_tables where schemaname = 'public' order by tablename;Fix prompt for Lovable
Turn on Row Level Security for every table in the public schema that does not have it yet. For each table, add policies so that a signed-in user can only read, insert, update and delete their own rows (match on the column that holds the owner's user id, using auth.uid()). Do not add any policy that allows the anon role to read private data. List every table and policy you changed.Check 2: no policy lets everyone in
RLS on is half the job. A policy is one rule, and a rule can be too open.
Supabase's documentation gives the example of a policy for the anon role (visitors who are not signed in) that uses the condition true. It grants every unauthenticated visitor read access to every row, and the documentation says to use it only for data meant to be public. The same condition on the authenticated role means any signed-in user can read every row. That is the classic way one customer sees another customer's data.
How to check:
- In Supabase, open Authentication, then Policies, and read each policy in plain words.
- For every policy, ask two questions: who does it apply to, and which rows does it let them reach?
- A condition of true is fine for a table of public blog posts and a problem for a table of orders, messages or profiles.
- A condition that compares the row's owner column to auth.uid() (the id of the user making the request) is the usual safe shape.
Fix prompt for Lovable
Review every Row Level Security policy in the database. Replace any policy that uses "true" on a table holding user data with a policy that only allows access when the row's owner column equals auth.uid(). Keep "true" only on tables that are meant to be public, and tell me which tables those are so I can confirm.Check 3: the Supabase secret key is not in your app's public files
Supabase gives your project two kinds of keys:
- The publishable key (the anon key on older projects) is made for browsers and is limited by RLS.
- The secret key (the
service_rolekey on older projects) goes around RLS and reaches everything.
Supabase's documentation says secret keys must never reach a browser. Supabase refuses a secret key sent from a browser, but an attacker can still use a copied key from other tools.
How to check:
- Open your published app in Chrome and press F12 to open the developer tools.
- Open the Sources tab and search all files (Ctrl+Shift+F, or Cmd+Option+F on a Mac).
- Search for sb_secret_ and for
service_role. - Older keys are long strings that start with eyJ, and both the anon and the
service_rolekey look like that. So also copy the last ten characters of yourservice_rolekey from the Supabase dashboard and search for those.
If a secret key turns up, treat it as exposed.
Fix prompt for Lovable
Find every place the Supabase service_role or secret key is used in code that runs in the browser. Move each of those operations into a Supabase Edge Function that reads the key from a secret, checks that the caller is signed in and allowed to do the operation, and returns only what the page needs. The browser code must only ever use the publishable (anon) key. Show me the list of files you changed.If the key was exposed, fixing the code is not enough. Supabase's guide on leaked keys says to fix the cause first, then create a new secret key, move your app to it and delete or deactivate the old one.
Check 4: no other secret is in a VITE_ setting
Lovable apps are built with a tool called Vite. Vite's documentation explains that settings whose names start with VITE_ are packed into the code every visitor downloads, and warns that they must not hold sensitive information. A payment, email or AI provider key saved as a VITE_ setting is public, even if no page shows it.
How to check:
- In the same developer tools search, look for sk_live, sk_test and the words secret and Bearer.
- In your project's settings, read the name of every setting that starts with
VITE_and ask whether a stranger may see it.
Fix prompt for Lovable
List every environment variable whose name starts with VITE_. For each one that holds a private key (payment, email, AI or any other private service), move that call into an Edge Function that gets the key from Lovable's stored secrets, and remove the VITE_ variable. Do not change the publishable Supabase key or the project URL.Check 5: one user cannot open another user's records
Signing in answers who you are. It does not answer what you may see.
Broken access control, the top category in the OWASP Top 10 for 2025, is this gap: a signed-in person changes an id in an address or a request and reaches someone else's record. OWASP's advice is to deny by default.
How to check:
- Create two test accounts.
- Add a record in account A, such as an order or a note, and copy its address.
- Sign in as account B in a private window and open that address.
- Try the same with anything that has an id in it: invoices, files, settings pages.
If B sees A's data, you have found a real problem before a stranger did.
Fix prompt for Lovable
Make sure every page, query and Edge Function that reads or changes a record checks that the record belongs to the signed-in user, in the database policy or on the server, not only by hiding buttons on screen. Then add a short test plan I can follow with two accounts to confirm one account cannot see or change the other's records.Check 6: no view hands out what your rules hold back
A view is a saved query that looks like a table. Builders sometimes add one to make a page load faster.
Supabase's documentation says views bypass RLS by default, because they are usually created by the database's owner role. So a view over a protected table can hand out every row its policies were meant to withhold.
How to check:
- In the Supabase Table Editor, look for entries marked as views, or ask Lovable to list them.
- For each view that reads a table holding user data, confirm it is meant to be public.
Fix prompt for Lovable
List every database view in the public schema and the tables it reads from. For any view that reads user data, either remove it or recreate it so it respects the Row Level Security policies of the tables underneath (security_invoker), and tell me which views you changed.After every change, test again
A fix prompt changes your app, and a rule that is now tight may make a page go empty. That is the rule working.
- Re-run the two-account test after every change.
- Run Lovable's own security checks again before you publish.
- Keep this routine for every release, because each new feature can add a table, a rule or a key.
What these checks do not cover
These six checks cover the leaks that most often show up in Lovable and Supabase apps, not every problem. They will not tell you whether a payment flow can be tricked, whether an uploaded file can be abused, or whether a library you depend on has a new flaw. They also depend on reading each rule correctly.
Get a second read
Want an outside check of your published app first? The free scan looks at your public pages for a Supabase secret key in your scripts, other secret keys, tables readable without signing in, sign-in settings and storage buckets. It cannot see your code or the rules for signed-in users.
The full audit goes deepest on apps built on Supabase. It reads your code and database rules, never runs them, and each finding comes with a prompt like the ones above, written for your app.