Short answer
Start with Lovable’s own security check: it reviews database rules, dependencies and your code before you publish. Then spend 25 more minutes on what only you can judge: list tables without row level security, find policies that let every user in, make sure no secret key reached the browser, check which functions anyone can call, and sign in as a second user to confirm you can’t see the first user’s data.
Ask an AI about this page:ChatGPTClaude
On this page
Key takeaways
- Start with Lovable’s own security check. It looks at database rules, dependencies and, with advanced checks, your code. Fix its critical findings first.
- A scanner can’t know what your app is supposed to allow. Whether members may see each other’s data is a decision only you can check.
- Five SQL queries and a few clicks in the browser cover the most common leaks in AI-built apps: missing RLS, “everyone may” policies, secret keys in the browser, privileged functions anyone can call and public buckets.
- The most convincing test is the simplest: a second account that tries to open the first account’s data.
- Repeat it whenever you add a table, a role, a function or a payment flow.
What does Lovable’s security check already do?
Lovable has a built-in security check, and it is the right place to start. This is what Lovable’s documentation describes, as we checked it on December 3, 2026:
- Automatic checks run before you publish and when relevant parts of the project change. They cover database security (row level security gaps, overly permissive rules and leaked-password protection being off), MCP servers that anyone can use without signing in, and dependencies with known critical vulnerabilities. They take a few seconds.
- Advanced checks read your app’s code for problems with sign-in, access permissions, private data, keys and passwords, user input, app actions and payments. You start them yourself, from the Security view, the workspace Security center or the project chat. They usually take 3 to 13 minutes.
- Findings are labelled Critical, Warning or Info. You can ask Lovable to fix them in the chat or use Fix all; auto-fix can handle critical database findings and vulnerable packages.
- Workspace admins can turn on “Block publishing with critical issues”.
- API keys you paste into the chat are detected and moved into Secrets, so they stay out of browser code.
Lovable is also clear about the limits. Its Security view documentation notes that “no check can catch every risk”, so a clean result doesn’t guarantee that an app is secure, and its security overview recommends a professional review for apps that handle sensitive data.
Why a self-audit on top of the scan?
A scanner is good at patterns: a table without RLS, a policy that says true, a package with a known CVE. Some of the most damaging bugs in AI-built apps aren’t patterns, though. They are mismatches between what the code allows and what you meant:
- A policy named “Members can view projects” that actually lets every signed-in user see every project. Whether that is a bug depends on who your members are, and only you know that.
- An invoice table that is correctly limited to “signed-in users”, when you meant “only the customer it belongs to”.
- A finding you ignored three weeks ago as “intended”, before you added real customer data.
- A function that was safe until you added a parameter.
None of this means the scan is weak. It means the final question, “can user B see user A’s data?”, is best answered by actually being user B for a few minutes. That is what the next 30 minutes are for.
What you need
- Thirty minutes and a note to write findings into.
- Two accounts in your app: your own, and a second one you create in a private browser window.
- A SQL editor for your database. With Lovable Cloud, Lovable’s documentation lists it under Database → Manage. If you connected your own Supabase project, open the SQL Editor in the Supabase dashboard.
The queries below only read table settings, so running them is safe. They don’t change data, except for one optional fix that is clearly marked.
Where to click depends on where your database lives. Lovable Cloud is Lovable’s built-in backend, built on Supabase; alternatively you may have connected your own Supabase project. For Lovable Cloud, Lovable’s documentation (checked December 3, 2026) lists these places:
| Task | Where in Lovable Cloud |
|---|---|
| Security check | More → Security |
| Tables | More → Database |
| SQL editor | Database → Manage |
| RLS policies | Database → Manage → Policies |
| Edge functions | More → Database → Manage → Edge functions |
| Secrets | More → Settings → Secrets |
| Logs | More → Settings → Logs |
With your own Supabase project, the security check is in the same place in Lovable, and everything else is in the Supabase dashboard.
The 30-minute self-audit
Minutes 0–5: Run Lovable's security check
Open your project, then More → Security, and click Run checks on the Security check card. This runs every automatic and advanced check that is out of date for your latest version. Advanced checks can take several minutes, so carry on with the next step while they run and come back to the results at the end.
When they are done, open Findings. Fix every Critical finding before anything else. Then open the Ignored tab: for each ignored finding, ask yourself whether the reason still holds now that the app has grown.
Minutes 5–10: Find tables without row level security
In a Supabase app, the browser talks to the database directly with a public key. Without row level security, every table that the public roles can reach is answered in full. Run this in the SQL editor:
select n.nspname as schema, c.relname as table_name
from pg_class c
join pg_namespace n on n.oid = c.relnamespace
where c.relkind in ('r', 'p')
and n.nspname = 'public'
and not c.relrowsecurity;Every row is a table that anyone with your app’s public key can read, change and delete. In our test, a visitor without an account read every row of such a table. The fix is on table without RLS; the background is in our Supabase row level security guide. If you use your own Supabase project, also open Advisors → Security Advisor in its dashboard: it flags these tables as lint 0013.
Minutes 10–15: Find policies that let everyone in
RLS can be on and still protect nothing. This query lists policies that allow every row (true) or only check that someone is signed in:
select tablename, policyname, cmd, roles, qual, with_check
from pg_policies
where schemaname = 'public'
and (
qual = 'true'
or with_check = 'true'
or qual ilike '%auth.uid()%is not null%'
or with_check ilike '%auth.uid()%is not null%'
or qual ilike '%auth.role()%authenticated%'
or with_check ilike '%auth.role()%authenticated%'
);Read each row and ask: should every visitor or every signed-in user really be allowed to do this? A public list of blog posts with true is fine. An orders table where anyone may insert with with check (true) is not: in our test, a visitor inserted an order already marked as paid, for another user. A projects table with auth.uid() is not null lets every customer read every other customer’s projects.
The query only finds the most common shapes. Owner policies written as (select auth.uid()) = user_id don’t show up, which is correct. Fixes: USING (true) policies, and for apps with teams or workspaces our guide on multi-tenant data isolation.
Minutes 15–20: Make sure no secret reached the browser
Your app’s code contains a Supabase URL and a key. If that key is the publishable or anon key, all is well; it is designed to be public. A secret key (sb_secret_…) or a legacy service_role key bypasses row level security completely and must never be in the frontend.
- Open More → Settings → Secrets and check that every third-party key (OpenAI, Anthropic, Stripe and so on) is stored there.
- Ask the Lovable chat: “Search the frontend code for service_role, sb_secret_, sk_live_, whsec_ and any VITE_ variable that holds a secret, and list every match with its file.” Read the answer yourself.
- Open your published app, press F12, go to the Network tab and click through the main features. Responses must not contain any key or token for another service.
Our guide on API keys in the frontend has a full decision table of which keys are safe in the browser.
Minutes 20–25: Check who can call your functions
Two kinds of functions run with more rights than the user: edge functions that use the secret key, and database functions marked security definer. Both skip RLS, so each one must check who is calling.
For edge functions, open More → Database → Manage → Edge functions (with your own Supabase: Edge Functions in its dashboard) and, for each one, answer two questions: does it read the user from the verified token rather than from a userId in the request body? And does it check that this user may touch the record it loads? See edge function without auth check.
For database functions, this query lists security definer functions in public that visitors without an account can call:
select p.proname as function_name,
pg_get_function_identity_arguments(p.oid) as arguments
from pg_proc p
join pg_namespace n on n.oid = p.pronamespace
where n.nspname = 'public'
and p.prosecdef
and has_function_privilege('anon', p.oid, 'execute');In our test app, a visitor called a function like this and gave 1,000 credits to an account. If a function on the list is only meant for your server, remove execute rights from everyone but the server:
revoke execute on function public.add_credits(uuid, integer) from public, anon, authenticated;Replace the name and argument types with those from the query. Revoking only from public and anon is not enough: Supabase also grants execute to authenticated by default, and in our test a signed-in user could still call the function until we revoked that too. If signed-in users do need the function, keep their right and add a check inside it instead; see SECURITY DEFINER without checks.
While you’re here, also look for decisions that only happen in React. A page that hides the admin area unless role === "admin", or a button that only appears for paying users, is a convenience, not a protection: whoever calls the database or the function directly skips the page. The check must also exist in a policy or a function. See admin check only in the frontend and subscription check only in the frontend.
Minutes 25–30: Be the second user
Now the test that matters most. Open a private browser window, sign up with a second e-mail address and do the following:
- While signed in as user A in your normal window, open a record that belongs to A, such as a project, an invoice or a document, and copy its URL.
- Paste that URL into the private window, where you are user B. You should see “not found” or an empty page, never A’s data.
- In B’s window, open the Network tab, reload a list page and read the response of the request to
/rest/v1/…. It may only contain B’s rows.
You can do the same in SQL. This block pretends to be one user inside a transaction and rolls back at the end, so nothing is saved:
begin;
set local role authenticated;
set local request.jwt.claims = '{"sub": "22222222-2222-2222-2222-222222222222", "role": "authenticated"}';
select count(*) from public.notes;
rollback;Replace the ID with user B’s ID (from your users list) and public.notes with one of your tables. The count should match B’s own rows. In our test it did for an owner-only table, and on a table without RLS the same block returned every user’s rows. If your SQL editor doesn’t allow switching roles, the browser test above gives you the same answer.
Last, check file storage. This lists buckets that are public, which means anyone with a file’s link can download it:
select id, name, public
from storage.buckets
where public;Avatars and marketing images can be public. Invoices, uploads and exports can’t; see public bucket with private files.
How to read what you found
Not everything on your list is equally urgent. Sort it like this:
| What you found | Severity | When to fix |
|---|---|---|
| Table without RLS that holds user data | Critical | Today, before anything else |
| Secret or service_role key in frontend code | Critical | Today, and rotate the key |
| User B can see user A’s data | Critical | Today |
with check (true) on a table with prices, credits or paid status | High | Before your next publish |
| Policy that only checks sign-in on private data | High | Before your next publish |
security definer function callable by visitors | High | Before your next publish |
| Public bucket with private files | High | Before your next publish |
using (true) on content that really is public | None | Note why it’s intended |
Our guide on how to read a security report explains the difference between severity (how bad it is if true) and confidence (how sure the finding is).
Fix prompts for Lovable
Lovable fixes most of these well when you describe the outcome precisely. Paste one prompt at a time, read the migration or code it proposes, and run the matching check from above again afterwards.
Create a new migration that enables row level security on every table in the public schema that has it disabled. For each of these tables, add policies for the authenticated role only, so that a user can select, insert, update and delete only rows where (select auth.uid()) = user_id (use the column that stores the owner). Replace every policy that uses true, auth.uid() is not null or auth.role() = ‘authenticated’ on private data with an owner or membership check, and keep true only on data that is meant to be public. Revoke execute from public, anon and authenticated on every SECURITY DEFINER function in the public schema that only the server should call.
Show me the full migration before applying it, and list every table and function you changed.
Search the frontend code for any Supabase secret or service_role key, any Stripe secret, restricted or webhook key, any OpenAI or Anthropic key and any VITE_ variable that holds a secret. Move every privileged call into an edge function that reads the key from Secrets, verifies the caller’s token and returns only the result. Do not return keys from any function. List every key that was exposed so I can rotate it.
What to repeat, and when
Security isn’t a one-off, but it doesn’t have to be a burden either. A rhythm that works for most Lovable apps:
- Before every publish: let Lovable’s automatic checks run and read any new finding. Consider asking a workspace admin to turn on blocking for critical issues.
- After every new table, role, edge function or payment flow: repeat steps 2 to 6 of this self-audit for the new parts.
- Before you invite real users or take payments: do the full 30 minutes, then go through our pre-launch security checklist.
Your checklist
Tick each item as you go. Your progress stays in this browser, so you can come back to it.
30-minute Lovable self-audit
0/10 done
Your progress is saved in this browser only.
Frequently asked questions
Does Lovable check my app’s security automatically?
Partly. According to Lovable’s documentation (checked December 3, 2026), automatic checks run before you publish and cover database rules, publicly reachable MCP servers and dependencies with known critical vulnerabilities. Advanced checks that read your code for problems with sign-in, permissions, private data, keys, input, actions and payments run when you start them from the Security view or the chat.
If Lovable’s security check finds no issues, is my app secure?
Not necessarily, and Lovable says so itself: its documentation states that no check can catch every risk and that a clean result is not a guarantee. A scanner can’t know whether two users of your app are supposed to share data. A two-account test and a look at your own policies answer that.
Is the Supabase key in my Lovable app’s code a problem?
Not if it’s the publishable or anon key. That key is designed to be public; what it can reach is decided by your row level security policies. It is a problem if a secret or service_role key appears anywhere in the frontend code.
Can I run SQL against a Lovable Cloud database?
Yes. Lovable’s documentation lists a SQL editor under Database → Manage for its built-in backend, which is built on Supabase. If you connected your own Supabase project, use the SQL Editor in the Supabase dashboard.
How often should I repeat this self-audit?
Run Lovable’s check before every publish, and repeat the full 30 minutes after any change that adds a table, a role, an edge function or a payment flow, and before you invite real users.
Sources
- 1.Security overview — Lovable Docs
- 2.Security view — Lovable Docs
- 3.Security best practices — Lovable Docs
- 4.Lovable Cloud — Lovable Docs
- 5.Row Level Security — Supabase Docs
- 6.Performance and Security Advisors — Supabase Docs
- 7.Understanding API keys — Supabase Docs