Row-level security (RLS) is the setting that decides whether a stranger can read your Supabase database. Apps built with Lovable, Bolt, v0 and similar tools usually query Supabase straight from the browser with a public key, and that key can reach every table in the public schema. With RLS on and a sensible policy on each table, a visitor sees only the rows they are allowed to see. With RLS off, or a policy that allows everyone, they can read and often change the lot. You can check every table in your project in under an hour.
This post is for founders and product leads whose AI-built app runs on Supabase. It explains what RLS does, the policy mistakes we see most in generated apps, the checks to run, and when to get help.
The short answer
Open the Security Advisor in your Supabase dashboard and fix every error. Then list every table in the public schema and confirm RLS is on for each. Read each policy and look for conditions that are simply true. Finally, open your app in a private window and query a private table with the public key from your page source. You should get an empty list.
Why AI-built apps depend on RLS
A traditional web app has a server between the browser and the database, and the server decides what each user may see. Most apps from AI builders skip that server for reads and simple writes. The browser holds the Supabase project URL and the publishable key (called the anon key on older projects) and sends queries directly.
Supabase designed it this way, and its documentation says the publishable key is safe to expose in browsers and in source code, because RLS controls what it can reach. The same documentation says that once RLS is enabled, nothing is readable through the API with the publishable key until you write a policy that allows it. The reverse is the problem. A table in the public schema without RLS is open to anyone holding that public key, and the key is in your page source.
This is how the Lovable incident in 2025 happened. We covered it, and the CVE that followed, in Your Lovable app is probably public. The same mechanism applies to Bolt apps on Supabase or Bolt Database, which we cover in Is my Bolt.new app secure?, and to v0 apps that use Supabase from the browser, covered in Taking a v0 app to production.
What a good policy looks like
A policy is a condition Postgres checks for each row. For a table of orders that belong to users, a select policy might read:
alter table orders enable row level security;
create policy "Users read their own orders"
on orders for select
to authenticated
using ( (select auth.uid()) = user_id );
Three details in that example matter. to authenticated limits the policy to signed-in users. auth.uid() returns the signed-in user’s id, and it returns null for visitors who are not signed in, which Supabase’s documentation points out. Wrapping it in (select ...) lets Postgres compute it once per query, which Supabase recommends for performance along with an index on user_id.
Inserts and updates need their own policies with a with check condition, which decides what a new or changed row may contain. Without it, a user allowed to update their own row may be able to set user_id to someone else’s. Most apps need no delete policy at all, and leaving one out means nobody can delete through the API.
The mistakes we see in generated policies
AI builders write policies quickly, and the common errors repeat.
- RLS switched off on tables added later. Bolt’s documentation says it enables RLS on tables it creates and that tables you add need it switched on by you. Tables created by a migration, a SQL snippet or a second tool are easy to miss.
- Policies that allow everyone. A condition of
truepasses every row. Bolt’s Security page flags these as “RLS Policy Always True”, and Supabase’s Security Advisor reports the same pattern. Builders often write them when the app has no sign-in yet, and they stay after sign-in is added. - Roles read from user metadata. A policy that checks
auth.jwt() -> 'user_metadata' ->> 'role' = 'admin'looks right, but Supabase’s documentation warns that signed-in users can change their own user metadata. Anyone could make themselves an admin. Store roles in app metadata or in a table users cannot write to. - Views that skip the rules. Supabase’s documentation says views bypass RLS by default, because they are usually created by the postgres user. On Postgres 15 and later, create them with
security_invoker = trueso they obey the underlying table’s policies. - The secret key in the browser. The secret key (the service role key on older projects) bypasses RLS entirely. If it appears in front-end code, every policy is irrelevant. We cover how to find it in Exposed API keys in AI-built apps.
- Storage buckets left public. File uploads live in Supabase Storage, which has its own policies. A private table with a public bucket of invoices next to it still leaks.
The checks to run yourself
Set aside an hour. You need owner access to the Supabase project and a test user account in your app.
- Run the Security Advisor. In the Supabase dashboard, open Advisors, then Security Advisor. Fix every error, read every warning, and run it again after each change. Bolt’s database Security page runs the same checks, and Lovable’s publish scan includes a database review.
- List every table. Run
select tablename, rowsecurity from pg_tables where schemaname = 'public';in the SQL editor. Every row should showtruein the second column. - Read every policy. Run
select tablename, policyname, cmd, roles, qual, with_check from pg_policies where schemaname = 'public';. Look fortruein thequalorwith_checkcolumns, forpublicoranonroles on private tables, and for any mention ofuser_metadata. - Check views. Run
select table_name from information_schema.views where table_schema = 'public';and confirm each view either usessecurity_invokeror holds nothing private. - Test logged out. Open the live app in a private window. Copy the Supabase URL and publishable key from the page source or the network tab, create a client in the browser console and select from each private table. You should get an empty list.
- Test as a user. Sign in as your test user and repeat. You should see only that user’s rows. Then try to update a row that belongs to someone else, and try to insert a row with another user’s id.
- Check storage. In Storage, confirm private buckets are marked private and have policies that limit each user to their own folder.
What the checks do not cover
RLS stops the largest leak with the least effort. It does not check whether edge functions verify the caller, whether sign-up can be abused, whether forms and AI calls have rate limits, or whether you have backups you have tried restoring. It also cannot decide your business rules for you. Whether a team manager may see another team’s records is a question for the business, and the policy has to encode the answer.
When to get a second pair of eyes
If the app holds customer data or takes payments, a review of the policies by someone who writes them every week is worth an afternoon of your time. Our vibe-coded app audit starts at $500, and you get a written report within a week covering RLS, keys, auth, storage, rate limits and backups, ranked by risk. Harden starts at $1,000 if you want us to make the fixes, and Rebuild starts at $8,000 for apps whose logic needs to move onto a server.
For tool-specific checks, see Replit app to production and Cursor app security review. For how we use Supabase on client builds, see the Supabase integration page, or go straight to the audit page.
Questions we get asked
Is the anon or publishable key in my page source a leak?
No. Supabase designed it to be public. It becomes a problem when a table has RLS off or a policy that lets everyone in.
I turned on RLS and now my app shows nothing. What happened?
That is RLS working. With RLS on and no policy, the public key can read nothing. Add a select policy for the rows each user should see, then test again.
Can I keep RLS off if my app has no sign-in?
Only for data you are happy for anyone to read and change. If visitors submit forms, give the table an insert policy and no select policy, so they can add rows and cannot read anyone else’s.
Does using the secret key on the server make RLS unnecessary?
If every query goes through your own server with the secret key, RLS is a second line of defence. Most AI-built apps also query from the browser, so it is the first line.
Sources and further reading
- Row Level Security, Supabase docs, checked 21 November 2026: behaviour with no policy,
auth.uid()returning null,with check, views,user_metadatawarning, performance advice - Understanding API keys, Supabase docs, checked 21 November 2026: publishable and secret keys, RLS bypass
- Advisors, Supabase docs, checked 21 November 2026
- Database security in Bolt, Bolt support, checked 21 November 2026: RLS on Bolt-created tables, “RLS Policy Always True”
- Your Lovable app is probably public, SBD, on CVE-2025-48757
- vibe-coded app audit, the SBD service this post describes















