How to secure a Lovable app before you ship
Short answer
Secure a Lovable app by treating the Supabase publishable key as public, enabling Row Level Security with per-user policies on every table that holds user data, keeping the sb_secret_ or service_role key only in Edge Function secrets, and then testing the deployed site while signed out. Lovable’s Quick Scan and Deep Scan check the project source; they do not replace a request against the live URL. The October 30, 2026 Supabase Data API change stops new tables from being exposed automatically, and it does not close tables that are already readable.
Last updated · Sekrd Research
- The publishable (anon) key is supposed to be in the Lovable frontend. The secret key must not be.
- Lovable’s own docs say its scans cannot guarantee security and do not cover runtime behavior. Details: what Quick Scan and Deep Scan check.
- CVE-2025-48757 described missing or permissive RLS on generated apps. The class of bug is still the one to test.
Do this before the first public URL
- Separate the two Supabase keys. The browser may hold
sb_publishable_(or the legacy anon key).sb_secret_and the legacy service_role JWT bypass RLS. If either secret is in a chat with the Lovable agent, in a client component, or in aVITE_variable, rotate it in the Supabase dashboard and put the new value only in Edge Function secrets. Migration steps are in the key deprecation guide. - Turn on RLS and write a policy per command. In the SQL editor, list tables that are still open and policies that allow everyone:
select tablename from pg_tables
where schemaname = 'public' and rowsecurity = false;
select tablename, policyname, cmd, qual, with_check
from pg_policies
where schemaname = 'public'
and (qual = 'true' or with_check = 'true');
For user-owned rows, the policy has to mention the caller. A starting point Supabase documents:
alter table public.notes enable row level security;
create policy "read own notes" on public.notes
for select to authenticated
using ((select auth.uid()) = user_id);
create policy "insert own notes" on public.notes
for insert to authenticated
with check ((select auth.uid()) = user_id);
USING (true) makes the dashboard look green and still returns every row to the publishable key. That pattern has its own write-up. A fuller pass is the RLS checklist.
- Storage and realtime use the same idea. A public bucket is fine for marketing images. A bucket of user uploads needs a policy on
storage.objectsthat restrictsownertoauth.uid(). If you do not intend anonymous reads, do not add a public SELECT policy. - Edge Functions that call an LLM or a payment API. Keep
verify_jwton for user-facing functions. For a webhook, you usually disableverify_jwtbecause the provider cannot send a Supabase JWT — and then you must verify that provider’s signature instead. Rate-limit before the model call. The pattern is in protecting Edge Functions that call LLMs. - Run Lovable’s scan, then scan the deployed URL signed out. Fix Quick Scan findings before publish. Run Deep Scan when you touch auth, payments, or user data. Then open the production URL in a private window and run a free Sekrd scan. Headers, the shipped bundle, and a secret key in JavaScript are properties of the deploy, not of the Lovable project view.
What “it works when I am logged in” hides
The Lovable preview sends your session. A stranger sends the publishable key and nothing else. Repeat the important read — profiles, orders, messages — in a private window, with only the key that is already in the page source. If rows come back, the policy is not doing what the UI implies.
New tables created after Supabase’s October 30, 2026 Data API change are not granted to the API until you add GRANTs. That failure is safe. The tempting fix, GRANT ALL to anon without RLS, recreates the old bug. Add the grant and the policy in the same change.
After launch
Re-scan the production URL after every publish that touches the database, auth, or a new integration. A one-time audit goes stale the next time the agent adds a table. Pre-Launch and Continuous Pro add the deep scan and scheduled rescans; the comparison is on /pricing.
Frequently asked questions
How do I secure a Lovable app?
Keep only the Supabase publishable key in the client, enable Row Level Security with policies that check auth.uid() on user data, store the secret key only in Edge Function secrets, run Lovable’s Quick Scan and Deep Scan, and then test the deployed URL while signed out.
Is Lovable’s built-in security scan enough?
Lovable’s documentation says the scans cannot guarantee complete security and do not replace a review for apps that handle sensitive data. They analyze the project. You still need to test what the deployed site returns.
Can I put my Supabase anon key in a Lovable app?
Yes. The anon or publishable key is public by design. Protection comes from Row Level Security. The service_role or sb_secret_ key bypasses those policies and must never be in the client.
Sources
Don't ship until you're sekrd
Run a free scan to find the vulnerabilities your AI missed.
Scan Your App Free