In short
Open your database's policies and confirm that RLS is enabled on every exposed table, then read each policy. Next, test for real: using two user accounts, try to read and change the other's records through the API, then repeat with no login. Lovable's security scan is a useful start, but only a real test shows whether the rules do what your business needs.
Why this matters
Lovable apps commonly let the browser query the database directly, using a public key. That's a normal design, and Supabase says that public key is safe to expose because it “only reaches what Row Level Security allows”. So those rules are doing all the work. A gap here was behind CVE-2025-48757, which described unauthenticated reads and writes on Lovable-generated projects.
If policies are new to you, read what Row Level Security is first. Do these checks on a staging copy where possible, and use test accounts you've created yourself.
Step 1: run the built-in scan
Lovable's Security Center runs a Quick scan at publish, which looks for things like tables without per-record access control, and a Deep scan that reviews code for access control problems. Run both, and read the findings. It's quick, and it catches obvious holes.
But Lovable itself says that these tools “cannot guarantee complete security”. A scanner can tell that a rule exists. It can't tell whether that rule fits your business. So keep going.
Step 2: list your tables and check that RLS is on
In your Supabase project, open the SQL editor and run this:
select schemaname, tablename, rowsecurity
from pg_tables
where schemaname = 'public'
order by tablename;
Any table with rowsecurity as false in an exposed schema is a serious concern. Supabase's docs state that such a table is “readable and writable by any role with a grant on it”, and that new tables on existing projects may start with those privileges granted. Check the tables the AI added late, including logs, settings and join tables. They're often forgotten.
If you use Lovable's built-in backend, look for the equivalent view in its database and security tools. Exact screens change, so follow the current docs.
Step 3: read every policy
List your policies:
select tablename, policyname, cmd, roles, qual, with_check
from pg_policies
where schemaname = 'public'
order by tablename;
You don't need to be a database expert to spot the worst problems:
| You see | What it means | Usually |
|---|---|---|
using (true) for select | Anyone in that role can read all rows | Fine for public content; wrong for private data |
with check (true) for insert | Anyone in that role can add any row | Rarely right, unless it's a public form with limits |
Role is anon | Applies to people who aren't logged in | Check that it's really meant to be public |
auth.uid() = user_id | Users reach only their own rows | A good common pattern |
| No policies, with RLS on | Nothing through the API | Safe, though your app may not work |
Note that select, insert, update and delete are separate. A common mistake is to protect reading while leaving updates wide open, or an update policy that lets a user change the user_id on their own row and so take over other records. Check that update policies have a with check clause.
Step 4: test as a stranger
This is the important part. Open your app in a private window, then open the browser's developer tools and the Network tab. Find a request to your database, and copy your project URL and public key from it. Then, without logging in, try this from a terminal, swapping in your own values:
curl "https://YOUR-PROJECT.supabase.co/rest/v1/YOUR_TABLE?select=*" \
-H "apikey: YOUR_PUBLIC_KEY"
Run it for each table. A private table should return nothing, or a permissions error, not your data. Only test your own app.
// or a permission error
"phone": "…"},
…]
Step 5: test as another user
Create two test accounts, A and B, and add some data to each. While signed in as A, copy the access token from your browser's storage or from a request's Authorization header. Then try these:
- Read B's rows by filtering on B's record ID
- Change one of B's rows with a
PATCHrequest - Delete one of B's rows
- Insert a row that claims to belong to B
All of those should fail. Also test roles: can a regular user reach admin tables? Can someone in one organisation see another's data? For teams and multi-tenant apps, see how to model multi-tenancy.
| Signed in as A, try to | Should |
|---|---|
| Read B's rows | Fail |
| Change one of B's rows | Fail |
| Delete one of B's rows | Fail |
| Insert a row claiming to belong to B | Fail |
Step 6: check your files
Storage buckets have their own rules. Is a “private” bucket really private? Can you open a file's URL in a private window? Are file names guessable? Also test whether one user can list or overwrite another's uploads.
Step 7: check functions
Edge functions and database functions can use elevated access. Supabase's secret keys bypass RLS, and database functions marked security definer run with their creator's rights, so they can bypass policies as well. Any of those must check who's calling them, on their own. Also confirm that no secret key appears in your front-end code. See how to find exposed API keys.
How to fix what you find
- Turn on RLS for the table. Note that with no policies, nothing works through the API, so your app may break until you add them.
- Add narrow policies, one per action, using the signed-in user's ID.
- Be careful what you ask the AI. Prompts like “fix the permissions error” can lead to a tool adding a broad
using (true)rule that makes the error disappear and leaves your data exposed. Ask instead: “Only the owner can read and update their rows. Show me the policy, and explain it.” - Retest with both accounts and with no account. Test after every change.
- Keep your policies in migrations, so they stay in version control.
If you find that private data has been exposed on a live app, rotate your keys and consider who might have had access. You may have legal duties if personal data is involved. See what GDPR means in practice.
Make it a habit
Each new table or feature is a new opportunity for a gap. Add the two-account test to your release routine, and consider automated tests for your access rules. Then work through the rest of the security checklist.
Want a professional to check this for you? Book a call.
Common questions
Is my Lovable app secure if the scan passes?
Not necessarily. A scan is a useful first pass, but Lovable's own documentation says its tools can't guarantee complete security. A scanner can't know your business rules, so also test by hand using two user accounts and no account.
What happens if I enable RLS without policies?
Nothing is accessible through the API using the public key until you add policies, which is safe but may break your app. Add narrow policies straight after enabling it, then test each feature and each role again.
Can users see my Supabase public key?
Yes, and that's expected. Supabase says that it's safe to expose in web pages, as it only reaches what RLS allows. Secret or service-role keys are different: they bypass RLS and must never appear in your browser code.
How often should I check my RLS policies?
Check every time you add a table, a role or a feature that touches data, and before each major release. AI tools can add tables and rules quickly, so make access tests part of your normal release routine.