Supabase Security Audit for Lovable SaaS Apps: What to Check Before Onboarding Paying Customers
Audit your Lovable SaaS app on Supabase before paying customers arrive. Check RLS, keys, auth, storage, payments, backups and logging in one pass today.
Direct answer: A Supabase security audit for Lovable SaaS apps is a pass or block check before real customers pay. You inventory every table, prove Row Level Security (RLS) with two test users, remove secret keys from the browser and git history, lock auth and admin access, check Storage and Edge Functions, verify payments grant access from the webhook, and restore a backup once. If any Block item fails, do not onboard paying customers yet.
A Lovable app can look finished while its database is open. The screens work, login works, and the demo feels smooth. That smoothness is the trap. In a Lovable app, the browser talks directly to Supabase with a publishable key anyone can read. RLS is the gate that decides which rows that key may touch.
This guide gives you one audit order and one decision. It does not repeat the full RLS repair or the full Stripe webhook repair. Those live in the child guides linked below. Use this post to decide if you are ready, then use those guides to fix the two areas that most often block launch.
How to use this audit
Run the checks in order. Each section ends with a pass condition. Mark each item as Block, Fix before launch, Fix in 14 days, or Monitor.

One Block item blocks onboarding. Do not average the score.
Block means a stranger or another customer can read, change, or pay for access they should not have. Fix before launch means the app works but a real customer will hit a failure. Fix in 14 days means a hardening gap that does not expose data today. Monitor means a risk to watch after launch.
Do not average the score. One Block item blocks onboarding. A long list of Monitor items does not cancel a Block.
1. Inventory and RLS
Start with inventory. You cannot secure tables you have not listed.
List every table in public, every view, every Storage bucket, every Edge Function, and every table that holds customer data, tokens, logs, or uploads. Include tables Lovable created that you did not ask for. Profiles, tokens, invites, and logs are common surprises.
Then check RLS. Supabase's production checklist says to enable RLS on every table, and that a table without RLS and reasonable policies lets any client read and change its data. That is the first gate.
What to check
- RLS is on for every table in
public, including lookup and log tables. - Each private table has one policy per operation: SELECT, INSERT, UPDATE, DELETE. A single
FOR ALLpolicy hides which operation it was meant to cover. - Policies are scoped to the owner or to workspace membership, not to
USING (true). - UPDATE has both
USINGandWITH CHECK, so a user cannot reassign a row by changinguser_id. - Policies name a role with
TO authenticatedwhere the data is private. A policy with noTOclause can apply more broadly than intended. - Grants match policies. A role needs both a grant and a policy. A missing grant can return a permission error, while a missing policy can return an empty list.
- Columns used in policies, such as
user_idorworkspace_id, have indexes.
How to prove it
Run the audit queries from the child RLS guide, then run the two-account test. Create Account A and Account B. As A, create one item of each important type. As B, try lists, search, exports, and direct detail URLs from A. Then repeat logged out.

A hidden list is not proof. A direct API call with B's token is the evidence.
Pass condition: B sees none of A's private rows, a logged-out visitor sees none, and A still sees all of their own rows. A UI that hides rows is not proof. An API call with B's token that returns no rows is proof.
For the full repair steps, see the guide to Supabase RLS fixes for Lovable apps.
2. Keys, secrets, and git history
Keys are the second gate. The publishable key is meant to be public. The secret key is not.
Supabase uses a publishable key for browser code and a secret key, formerly called service_role, for server code. The secret key bypasses RLS. If it reaches a browser bundle, RLS no longer protects the data.

The browser gets the publishable key. The server gets the secret. Never the other way around.
What to check
- Browser code contains only the publishable key and project URL.
- No secret key, Stripe secret key, or AI provider key appears in any file the browser downloads. Search loaded files for
sb_secret_,service_role,sk_live_, andsk-proj-. - No environment variable with a
VITE_,NEXT_PUBLIC_, orEXPO_PUBLIC_prefix holds a secret. Those prefixes inline values into the client bundle by design. - No secret appears in the repo, in
.envfiles, in.claude/settings.local.json, in.cursor/mcp.json, or in other tool config files. - Git history is checked, not just the current working tree. A committed secret stays in history after the file is deleted.
- If a secret was ever exposed, it was rotated. Deleting the file does not un-leak the key.
- Lovable Secrets or Supabase Edge Function secrets hold server-only keys, and each secret is scoped to the job that needs it.
Pass condition: A browser search finds no secret, a repo search finds no secret, and any previously exposed secret has been rotated and redeployed.
3. Auth, sessions, and admin access
Auth proves who the user is. RLS decides what that user may touch. Both must be checked.
What to check
- Email confirmation is on for production sign-ups.
- Site URL is the production domain, not localhost or a preview URL. Every redirect URL is an exact production URL, not a wildcard.
- One-time password and recovery link expiry is 3,600 seconds, one hour, or lower. Supabase's checklist recommends this.
- Password reset works end to end on the live domain.
- Sessions persist after refresh. If the session clears on reload, every query becomes anonymous.
- OAuth providers use production redirect URLs.
- Auth emails use your own SMTP provider and domain, not a test sender.
- Admin actions are checked on the server, in a policy or an Edge Function. Hiding an admin button is not security.
- Roles are not stored in
user_metadata, which the signed-in user can edit. Use a protected role table orraw_app_meta_datafor permission data. - Supabase organization access has MFA on owner accounts, and more than one owner exists so one lost account does not lock the team out.
- Team members have the smallest role they need. No shared owner login is passed around in chat.
Pass condition: A new user can sign up, confirm, sign in, reset a password, and stay signed in on the production domain, while a non-admin cannot reach admin actions by URL or API call.
4. Storage, Realtime, views, and Edge Functions
Tables are only part of the surface. Files, live updates, views, and server functions each need their own check.
Storage
A public bucket means anyone with the file URL can open the file. A private bucket with no policy means no one can open it. Both failures look like a bug, but only the first is a leak.
Check each bucket: is it meant to be world-readable or private? For private uploads such as invoices or ID documents, confirm the storage.objects policy scopes access to the owner folder and to authenticated. Confirm uploads and downloads have separate policies. A bucket readable by everyone should not be writable by everyone.
Pass condition: A private file URL opened in a private browsing window does not display.
Realtime
Realtime needs a separate check. Supabase's checklist notes that RLS does not filter Postgres Changes DELETE events the same way as table queries. If your app streams row changes, confirm replicated tables have RLS and policies, and confirm private changes use broadcast with Realtime authorization where needed.
Pass condition: A second user does not receive another user's Realtime updates.
Views and functions
Views can bypass RLS by default when created with security definer. On Postgres 15 and above, create views with security_invoker = true so they follow the underlying tables' RLS. On older versions, revoke client-role access or move the view to an unexposed schema.
SECURITY DEFINER functions also bypass RLS. Use them only for narrow checks, such as workspace membership, with a fixed search_path, a stable result, and a grant only to the role that needs it. A broad SECURITY DEFINER function that returns whole rows can undo RLS.
Pass condition: Every view and function was listed, and each one either follows RLS or has a written reason for bypassing it.
Edge Functions
Edge Functions are server code, but they still need checks. Confirm each function has the right verify_jwt setting. A public webhook function that expects a third-party signature must not also require a Supabase user token, or the provider will get a 401. A private function must require auth and must not accept an anonymous call.
Confirm each function uses only the keys it needs. A function that only reads public data should not hold the secret key. A function that writes subscription state needs the secret key, but must keep it in Edge Function secrets.
Pass condition: Each Edge Function was called as anonymous, as a normal user, and as its intended caller, and only the intended caller succeeded.
5. Payments and access mapping
Payments are a security area, not just a billing area. The question is not whether Stripe shows paid. The question is whether the webhook is the only source of truth for access.
What to check
- The live webhook endpoint points to the production Edge Function URL, not a preview URL.
- The signing secret belongs to that exact live endpoint, not to test mode.
- The webhook handler verifies the raw body signature before doing any work.
- Access is granted from the webhook, not from the success page redirect, which a user can visit directly.
- The handler maps every lifecycle event, not just checkout: renewal, failed payment, refund, plan change, and cancellation.
- The handler writes to the exact table and column the pricing gate reads. If the webhook writes
subscriptionsbut the UI readsprofiles.is_pro, the write is theatre. - The handler is idempotent. A retried event must not create a duplicate row or overwrite a newer state with an older one.
- The Checkout Session carries the Supabase user ID, so the webhook can join payment to user without relying on email alone.
Pass condition: A test checkout flips the exact gate row to active, a cancellation flips it back, and a forged webhook without a valid signature is rejected. For full repair steps, see the Lovable Stripe webhook fix.
6. Backups, environments, logging, and limits
A secure app still fails if it cannot recover, cannot separate test data from customer data, or cannot tell what happened after an incident.
Backups
First, confirm where the database lives. The backup story differs for Lovable Cloud and for your own Supabase project.

Lovable Cloud keeps daily backups for about 14 days, database only. Test the restore beside production.
| Setup | What to confirm |
|---|---|
| Lovable Cloud | Daily database backup, about 14 days retained, restore procedure tested beside production, Storage files exported separately |
| Own Supabase, paid plan | Daily backup retention for the plan, point-in-time recovery setting if needed, restore procedure tested beside production |
| Own Supabase, free plan | Manual export schedule, copies stored outside Supabase, restore procedure tested |
Pass condition: You restored a backup beside production, compared row counts, signed in with a test account, and wrote down duration and obstacles in a one-page procedure. The restore did not run on top of production.
Lovable's backup documentation confirms the backup covers the database only, not Storage files, and that restoring replaces the same project's database. Export your database before you restore.
Environments
Lovable retired its separate Test and Live databases on 23 October 2026. Every project on the built-in backend now runs on a single database. Drafts use the same database as the published app. That means test edits can change customer data.
If you stay on the built-in backend, run experiments with test accounts only, and export before every major change. For real separation, use a second Supabase project for tests. For hosting handover, see the Lovable external hosting handover guide.
Logging, rate limits, and monitoring
- Error tracking is installed, so errors reach you before customers report them.
- Uptime monitoring pings the app and alerts you when it is down.
- Audit logs exist for sensitive actions, such as admin changes, role changes, refunds, and data exports.
- Rate limits exist for login, signup, password reset, and public API calls.
- Lists are paginated. No screen loads a whole table.
- A one-page incident note exists: who owns the decision, how to rotate keys, how to revoke access, and how to tell affected customers.
Pass condition: You can answer, in one minute, who changed a sensitive row, when, and from which account.
Illustrative example: Harbor Notes
This example is illustrative, not a verified client case.
Harbor Notes is a fictional US notes SaaS built in Lovable on Supabase. Founder A created 40 notes. Founder B signed up and saw all 40 notes. The audit found RLS off on notes, a public bucket for uploads, and a Stripe webhook that granted access from the success page.
The fix order followed this audit: enable RLS and owner policies, make the bucket private with an owner-folder policy, move access granting to the webhook, rotate a secret that had reached a preview env file, and restore a backup beside production. After the fix, B saw zero notes, a logged-out curl call returned no rows, a private file URL did not open, and a test checkout and cancellation flipped the gate row correctly.
Use this scorecard for your own audit:
| Area | Result | Decision |
|---|---|---|
| RLS and inventory | Pass | Ready |
| Keys and git history | One secret rotated | Fix before launch, then re-check |
| Auth and admin | Pass | Ready |
| Storage, Realtime, views, Edge Functions | One public bucket fixed | Fix before launch, then re-check |
| Payments | Webhook fixed | Fix before launch, then re-check |
| Backups and logging | Restore tested | Ready |
A note on evidence
No first-hand JUHENZA client audit is claimed in this guide. The checks come from Supabase's production security checklist, Lovable's backup and built-in backend documentation, and the child fix guides. Harbor Notes is illustrative. If you want proof for a specific app, ask for the table inventory, the two-account API results, the key scan, the restore log, and the webhook test. A scan with no evidence is not an audit.
Common mistakes
- Fixing a permission error with
USING (true)or by turning RLS off. - Fixing a grant error with
GRANT ALLtoanon. - Trusting the success page for access.
- Turning off JWT verification for a webhook and skipping the signature check.
- Assuming a backup exists because the plan mentions backups.
- Testing only as the founder, who often has broader access than a new customer.
- Treating Lovable's built-in scan as a full audit. Lovable's own docs say its security checks are not a full audit. Run the scans, fix what they flag, then run the two-account test.
Limitations and when to involve a specialist
This audit covers the common Lovable and Supabase failure modes. It is not a penetration test, a compliance audit, or legal advice. It does not prove compliance with any US state privacy law, health data rule, or payment rule. For those, consult a qualified professional and cite the official source for the rule you must meet.
Involve a specialist if: you handle health, financial, or children's data, you need a buyer security questionnaire answered, you found a secret in a public repo, you suspect a breach already happened, or the audit finds Block items in more than two areas. A specialist review costs far less than an incident after paying customers arrive.
FAQ
What is a Supabase security audit for a Lovable SaaS app?
It is a structured check of the database, keys, auth, Storage, Edge Functions, payments, backups, and logging before paying customers arrive. The audit ends with a pass or block decision, not just a list of tips.
Is the publishable key a leak if I can see it in the browser?
No. The publishable key is meant to ship in browser code. The leak is missing or permissive RLS. If RLS is correct, the publishable key alone cannot read another customer's private rows.
How do I prove RLS works?
Use two test accounts and a logged-out check. Account B must see none of Account A's private rows, and a logged-out API call must return no private rows. A UI that hides rows is not proof.
Does Lovable's security scan replace this audit?
No. Built-in scans are a useful first filter. They do not test payments, backups, admin access, or a restore. Run the scans, then run this audit.
What blocks onboarding paying customers?
Any Block item blocks onboarding. The most common Block items are RLS off, a USING (true) policy on private data, a secret key in the browser or repo, a public bucket for private files, and access granted from a success page instead of a webhook.
How long does the audit take?
For a small SaaS app with one workspace model, allow about 90 minutes for checks and about half a day for fixes. For a multi-tenant app with teams, admin roles, and many Edge Functions, allow a full day for checks and a scoped fix sprint.
What should I send a US buyer who asks for security proof?
Send a short audit note: what was checked, what passed, what was fixed, the date of the restore test, and who owns security. Do not send secret keys, raw logs, or customer data. Confirm the buyer's exact questionnaire format before you send anything.
Where this fits
This post sits in Startups and SaaS, under AI-Built SaaS Hardening. It links up to the Startups and SaaS industry page and down to two child fixes: the Supabase RLS fix for Lovable apps and the Lovable Stripe webhook fix. For application foundations and tenant isolation, see application development and custom software development.
Conclusion
Do not onboard paying customers on a hope. Run the audit, fix every Block item, restore a backup once, and keep the scorecard with the release note.
Send your project brief and ask for a pre-launch Supabase security audit for your Lovable SaaS app. Include your table count, auth model, payment flow, and where the database lives.