Skip to content
← All articles

Your Lovable app isn't secure until you've checked these things

Row Level Security, auth, keys in the frontend and storage buckets: what to check in your Supabase-backed app before real users arrive.

Rachid · 15 Nov 2026 · 8 min read

Your app works. You can sign up, sign in and see your own data. That feels secure, but 'it works for me' says nothing about what someone else can do. Most security problems in AI-built apps aren't clever hacks. They're doors that were left open because the app worked fine with them open.

This article is about apps with Supabase underneath, which is common with Lovable and similar tools. The ideas apply to other setups too.

Why this matters more with Supabase

In a classic app, the browser talks to your own server, and the server decides what you're allowed to see. With Supabase, your frontend often talks to the database directly, using a public key that ships with your app. Anyone can find that key in the browser. That's by design, and it's fine, as long as the database itself decides who may read and change what.

That decision lives in Row Level Security, RLS for short. If RLS is off on a table, or the policies are too broad, the public key is enough to read or change that table. No login needed, no app needed, just a few lines in the browser console.

1. Turn on RLS for every table

Open your Supabase dashboard and go through every table. Each one should have RLS enabled. Pay extra attention to tables that were added later, like a reviews or invoices table you asked for last week. Those are the ones that slip through.

Enabling RLS without any policy closes the table completely. That's a safe starting point. Then you add policies that open exactly what's needed.

2. Write policies that say 'only your own'

A typical policy for an orders table, where each order has a customer_id pointing to the user:

alter table orders enable row level security;

create policy "Customers read their own orders"
on orders for select
to authenticated
using ( (select auth.uid()) = customer_id );

create policy "Customers create orders for themselves"
on orders for insert
to authenticated
with check ( (select auth.uid()) = customer_id );

Two things to notice. using decides which existing rows someone can see or touch. with check decides which new or changed rows are allowed. An insert policy without with check on the owner column lets a user create orders in someone else's name.

Watch out for policies with using (true). That means: everyone can do this to every row. Sometimes that's right, for example for a public product catalogue that's read only. For anything personal, it's a leak.

3. Test with two accounts

Reading policies is not enough. Test them. Create two test users, A and B, and give each some data of their own. Sign in as A and try to get B's data:

  • Through the app: change an id in the URL, like /orders/123 to /orders/124.
  • Through the browser console, with the Supabase client your app already loads: query the table without a filter and see what comes back.
  • Try to update or delete one of B's rows, not just read it.

If A sees or changes anything of B's, you've found a leak before your users do. That's a good day.

4. No secret keys in the frontend

Supabase has two kinds of keys. The anon or publishable key is meant for the browser and is limited by RLS. The service role or secret key ignores RLS completely. It must never end up in frontend code, because anyone who opens your site can read it.

The same goes for Stripe: the publishable key is fine in the browser, the secret key is not. And for API keys of AI services, email services and anything else that costs money or holds data.

Search your project for service_role, sk_live, sk_test and the names of the services you use. If a secret key ever ended up in your code or in GitHub, replace it in that service's dashboard. Deleting it from the code doesn't help: old versions and copies may still contain it.

5. Check your storage buckets

Files often get less attention than tables. Profile photos, uploaded documents, generated invoices. A bucket set to public means anyone with the link can open a file, and links are easier to guess or leak than you'd think.

  • List your buckets and decide per bucket: does this really need to be public? Product images, yes. Customer uploads, no.
  • Set private buckets to private and add storage policies, so users only reach their own files.
  • Show private files through short-lived signed links instead of permanent public links.

6. Auth settings that bite later

  • Email confirmation. Without it, people can sign up with any address.
  • Redirect URLs. Make sure only your own domains are allowed as redirect after sign in or password reset.
  • Roles. If your app has admins, check that admin rights are checked in the database or a server function, not just by hiding buttons.
  • Sign-up open or closed. If your app is invite only, make sure open sign-up is actually off.

7. Server functions are code too

Edge functions and other server code run with more rights than the browser. That's why you use them for things like payments. But it also means they have to check who's calling. A function that creates a refund, sends an email or calls an AI model should verify the user's session and their right to do that specific thing. Otherwise anyone who finds the URL can call it.

Ask the AI, but verify

You can ask your AI builder to review your policies. It's a useful start, and it often finds missing RLS. Ask it to list every table with its policies in plain language: who can read, who can create, who can change, who can delete. Then check that list against what you actually want, and test with two accounts. The AI is good at writing policies, and less good at knowing what your business needs to keep private.

Checklist

  1. RLS enabled on every table.
  2. Policies limit personal data to its owner, with with check on inserts and updates.
  3. Tested with two accounts, reading and writing.
  4. No service role or secret keys in the frontend or the repository.
  5. Private buckets are private, with storage policies.
  6. Email confirmation, redirect URLs and roles set correctly.
  7. Server functions check who's calling.

Want the full list for launch day? The free go-live checklist covers security, payments, domain and backups.

Open the checklist