The short answer
Row Level Security (RLS) is the set of rules in your Supabase database that decides which rows each visitor can read or change. In a Lovable or Bolt app it is the only real lock on your data, because the key your app uses to reach the database ships to every browser. To check it, list every table, read every policy, and try to fetch another user’s data with the public key. To fix it, turn RLS on everywhere and write policies tied to the signed-in user.
Most founders treat RLS as a setting. It is closer to a contract: a short piece of SQL per table that states who owns a row and who may touch it. The platforms now switch RLS on for the tables they create, and both ship security scans. Those help. But a scan can confirm that a policy exists; it cannot tell you whether the policy says the right thing about your business.
If you do three things this week
- Run the database scan in your builder and in Supabase’s Security Advisor, and clear every error.
- Open each policy and ask one question: does this rule mention the signed-in user, or does it let everyone through?
- Sign in as a second test user and try to read the first user’s records. If you can, so can anyone.
Why this matters now
One in ten apps in the first public scan of Lovable projects exposed data through missing or weak RLS. In March 2025 a researcher checked 1,645 sites listed on Lovable’s showcase and found 170 of them, about 10.3%, leaking data through 303 database endpoints. The exposed records included names, email addresses, phone numbers, payment details and the developers’ own API keys (Matt Palmer, statement on CVE-2025-48757). The issue was filed as CVE-2025-48757 with a severity score of 9.3 out of 10.
The most useful line in the record is the vendor’s response. Lovable disputed the CVE on the grounds that each customer accepts responsibility for protecting their own app’s data. Whatever you think of that position, it is the operating reality for every founder on these platforms: the builder writes the code, and the data risk stays with you.
Three things have changed since then, and they shift where the remaining risk sits:
- The platforms scan now. Lovable’s Security center runs a quick scan of database access rules and a deeper review of application code (Lovable docs). Bolt’s database Security tab runs the same checks as Supabase’s Security Advisor, covers the database only, and offers an “Ask Bolt to fix” button (Bolt docs). Since July 2026 Bolt also audits access control and database policies when you publish (Bolt blog).
- Supabase made the safe path the default. Tables created in the dashboard get RLS on from the start, owners get an email when a table is created without it, and event triggers can enforce RLS on tables created by migrations or outside tools (Supabase security retro, January 2026).
- The keys are changing. Supabase is replacing the legacy
anonandservice_rolekeys with publishable and secret keys, and the legacy keys are being deprecated by the end of 2026 (Supabase API keys). Any app still running on the old keys will need touching anyway, which makes this a good moment to review the rules behind them.
The net effect: the obvious failure, a table with RLS switched off, is getting rarer. The failure that remains is quieter. RLS is on, a policy exists, the scanner is green, and the policy still lets the wrong person in. The researcher behind the CVE made the same point about Lovable’s first scanner, which in his words checked whether a policy existed rather than whether it was correct. That is the gap this guide is about.
How your data is actually reached
In a Lovable or Bolt app, the browser talks to the database directly. There is no server of your own in between checking each request. The app carries a Supabase key, the publishable key (called the anon key in older projects), and that key is visible to anyone who opens the browser’s developer tools. Supabase designed it that way: the docs describe the publishable key as safe to expose, provided RLS is enabled on every table (Supabase API keys).
The picture explains most RLS incidents. Your interface is one client among many; a script with the same key can ask the API for any table and any column. The API then runs the request as the anon role (no one signed in) or the authenticated role (someone signed in), and RLS policies decide which rows that role and that user may see. If a table has no policy, or a policy that says true, the database answers the script exactly as it would answer your app.
The second path matters just as much. Server code, such as an Edge Function or a scheduled job, often uses the secret key (service_role in older projects). That key bypasses every policy. It belongs only on a server, and every function that uses it needs its own checks on who is calling and what they asked for.
Six ways RLS fails in AI-built apps
RLS problems in builder-made apps cluster into six patterns. The first two are the ones scanners catch. The other four are logic errors: the policy exists, the tool is satisfied, and the data is still open.
| # | Pattern | What it looks like | Why AI builders produce it | Caught by scanners? |
|---|---|---|---|---|
| 1 | RLS switched off | A table in the public schema with RLS disabled. Anyone with the project URL can read, insert, change and delete rows. |
Builders enable RLS on tables they create, but a table added later by hand, by SQL or by a migration may skip it. | Yes: Supabase lint 0013, “RLS disabled in public” |
| 2 | A policy that lets everyone in | using (true) on a table of private data, or a select policy granted to anon. |
RLS on with no policy blocks everything, the app breaks, and the quickest prompt-level fix is a rule that allows all. | Partly: Bolt flags “RLS policy always true”, which can be legitimate for public data |
| 3 | The rule checks the wrong thing | Admin rights read from user_metadata, or ownership checked against an id the browser sends. |
The generated code stores a role where it was easiest to reach. Users can edit their own user_metadata through the auth API. |
Partly: lint 0015 flags policies that reference user_metadata |
| 4 | Reads are locked, writes are not | A user cannot read other people’s orders but can insert one in their name, or change user_id on an update. |
USING and WITH CHECK do different jobs, and generated policies often set only the first. |
No |
| 5 | Side doors | A view that returns another user’s rows, a security definer function in an exposed schema, a storage bucket marked public. |
Views and some functions run with their owner’s rights and skip the caller’s policies unless set up otherwise. | Partly: lint 0010 flags security definer views |
| 6 | The secret key in the wrong place | The service_role or sb_secret_ key in front-end code, or an Edge Function that uses it and trusts whatever the browser sends. |
Moving a failing query to the secret key makes the error go away. | Partly: code scans may find a leaked key; trust in a function’s input needs a person to read it |
Sources for the checks: Supabase splinter lints, Supabase RLS guide, Bolt database security.
Two of these deserve a closer look because they are invisible in normal use.
Pattern 3 hides behind a working admin screen. If your policy says “admins can read everything” and decides who is an admin by reading user_metadata, any signed-in user can promote themselves with a single call to the auth API. Supabase’s own guidance is to keep authorization data in app_metadata, which users cannot edit.
Pattern 4 hides behind correct reads. On an update, USING decides which existing rows a user may touch and WITH CHECK decides what the row may look like afterwards. A policy with only USING (auth.uid() = user_id) lets a user edit their own row and set its user_id to someone else, which can move data between accounts. Every insert and update policy needs a WITH CHECK.
How to check your app in an hour
You can audit RLS in about an hour with the Supabase SQL editor, two test accounts and a terminal. Run every step against your own project only, and do it in a staging copy if you have one. Steps 1 to 3 read your setup; steps 4 and 5 test it the way an outsider would.
Step 1. Run the scanners, and treat green as the starting line
Open Supabase’s Security Advisor (Dashboard → Advisors → Security), your builder’s scan (Lovable: Security center, quick and deep scan; Bolt: database icon → Security) and clear every item marked Error. These catch patterns 1 and 2 reliably. They do not tell you whether a policy matches who should see what.
Step 2. List every table and whether RLS is on
In the Supabase SQL editor:
select c.relname as table_name,
c.relrowsecurity as rls_enabled
from pg_class c
join pg_namespace n on n.oid = c.relnamespace
where n.nspname = 'public'
and c.relkind in ('r', 'p')
order by rls_enabled, table_name;
Every row should say true. Any false is pattern 1. Note which tables hold personal, financial or business data; you will test those first.
Step 3. Read every policy as a sentence
select tablename, policyname, cmd, roles,
qual as using_rule,
with_check
from pg_policies
where schemaname = 'public'
order by tablename, cmd;
Read each row aloud as “For [command], [roles] may touch rows where [using_rule]”. Flag four things:
using_ruleistrueon a table that is not meant to be public (pattern 2).rolesincludesanonorpublicon private data.cmdisINSERT,UPDATEorALLandwith_checkis empty (pattern 4).- The rule mentions
user_metadataorraw_user_meta_data(pattern 3).
Step 4. Try the front door without signing in
This is the test that matters most, because it is what an outsider does. Copy your project URL and publishable key from the app’s settings, then from a terminal:
curl "https://YOUR-PROJECT.supabase.co/rest/v1/YOUR_TABLE?select=*&limit=5" \
-H "apikey: YOUR_PUBLISHABLE_KEY"
For a private table the answer should be an empty list [] or an error. Rows coming back means anyone on the internet can read that table. Repeat for each table on your step 2 list.
Step 5. Sign in as someone else
Create two test users, A and B, and give A some records. Then simulate B in the SQL editor. The transaction rolls back, so nothing is changed:
begin;
set local role authenticated;
select set_config('request.jwt.claims',
'{"sub":"USER-B-UUID","role":"authenticated"}', true);
select * from public.orders where user_id = 'USER-A-UUID'; -- expect 0 rows
update public.orders set user_id = 'USER-B-UUID'
where user_id = 'USER-A-UUID'; -- expect 0 rows updated
rollback;
Run the same pair of statements for each private table. Any row returned or updated is a leak between customers, which in a B2B product is usually the most expensive kind.
Step 6. Check the side doors and the keys
-- views that may bypass RLS
select table_name from information_schema.views where table_schema = 'public';
-- functions that run with their owner's rights
select p.proname from pg_proc p
join pg_namespace n on n.oid = p.pronamespace
where n.nspname = 'public' and p.prosecdef;
-- storage buckets open to the world
select id, public from storage.buckets;
A view over private data needs security_invoker = true (Postgres 15 and later). A security definer function should not sit in the public schema. A public bucket should hold only files you would put on your homepage.
Finally, search your front-end code and your deployed JavaScript for service_role, sb_secret_ and any long token beginning eyJ (the legacy public key also starts with eyJ, so decode any you find and check whether its role says service_role). If you find a secret key there, treat it as leaked: rotate it the same day.
What good looks like at the end of the hour: every table has RLS on, every private table returns nothing to the curl test, user B cannot read or rewrite user A’s rows, and no secret key exists outside your server.
How to fix it: four policy patterns
Most apps need only four policy shapes. Pick the one that matches how each table is owned, write it once, and test it with step 5 above. The examples use a table called notes; change the names to yours.
Pattern A. Each row belongs to one user
Use this for profiles, personal documents, orders in a consumer app.
alter table public.notes enable row level security;
create policy "owner reads" on public.notes
for select to authenticated
using ((select auth.uid()) = user_id);
create policy "owner creates" on public.notes
for insert to authenticated
with check ((select auth.uid()) = user_id);
create policy "owner edits" on public.notes
for update to authenticated
using ((select auth.uid()) = user_id)
with check ((select auth.uid()) = user_id);
create policy "owner deletes" on public.notes
for delete to authenticated
using ((select auth.uid()) = user_id);
create index on public.notes (user_id);
Three details do the work. to authenticated keeps signed-out visitors out entirely. with check on insert and update stops users writing rows in someone else’s name. Wrapping auth.uid() in (select ...) lets Postgres work it out once per query instead of once per row, and the index on user_id keeps the check fast as the table grows. Both are Supabase’s own recommendations (RLS guide).
Pattern B. Rows belong to a team or a customer account
Use this for any B2B app where several people share an account. Put the membership check in one helper function, outside the exposed schema, and call it from every policy:
create schema if not exists private;
create or replace function private.is_member(org uuid)
returns boolean
language sql stable security definer
set search_path = ''
as $$
select exists (
select 1 from public.memberships m
where m.org_id = org
and m.user_id = (select auth.uid())
);
$$;
create policy "members read" on public.projects
for select to authenticated
using (private.is_member(org_id));
create policy "members write" on public.projects
for insert to authenticated
with check (private.is_member(org_id));
The function lives in a private schema so the API cannot call it directly, and set search_path = '' closes a known way to hijack security definer functions. The memberships table needs its own policies too, or users can add themselves to any team.
Pattern C. Public to read, private to change
Use this for listings, published profiles, blog content.
create policy "anyone reads published" on public.listings
for select to anon, authenticated
using (status = 'published');
Then add Pattern A policies for insert, update and delete. A using (true) read is acceptable only when every row and every column in the table is genuinely public. If one column is private, such as an email or a phone number, move it to a separate table.
Pattern D. Admin rights
Read the role from app_metadata, which only your server can set, never from user_metadata:
create policy "admins read all" on public.orders
for select to authenticated
using ((select auth.jwt() -> 'app_metadata' ->> 'role') = 'admin');
Roll it out without breaking production
The classic failure after a fix is an app that suddenly shows empty screens, because RLS now blocks a query the app relied on. Sequence the work to avoid that:
- Back up the database, or work in a branch or staging copy.
- Write all policies for a table in one migration, then enable RLS in the same migration.
- Test with two users (step 5), then click through the app’s main journeys as each user.
- Watch the API logs for a day for requests that now return nothing.
- If the audit found a secret key in the browser or open tables, rotate the keys once the policies are live, and check the logs for reads you did not expect.
If personal data was exposed, take advice on your duty to report it. Under GDPR, for example, a controller must notify the supervisory authority within 72 hours of becoming aware of a personal data breach, unless it is unlikely to put people at risk. We are engineers, not lawyers; your counsel should make that call.
Prompt it, or bring in an engineer?
You do not need an engineer to secure every Lovable or Bolt app. You need one when two things are true at once: the data would hurt someone if it leaked, and access is shared in ways a single user_id column cannot express.
A waitlist that stores email addresses sits bottom left: let the builder write owner-only policies and run the one-hour check. A B2B product where customers invite colleagues, assign roles and share records sits top right: one wrong join in a membership policy exposes one customer’s data to another, and the builder cannot test that for you.
Three signals say you have crossed into the top right, whatever the chart says:
- You have fixed the same access bug more than twice with a prompt.
- A policy is longer than three lines or calls another table.
- A customer, investor or auditor has asked how tenant data is separated.
A prompt that gets better policies from your builder
If you stay in the builder, be specific. Vague prompts such as “make it secure” tend to produce using (true). Paste this instead and fill in the brackets:
Review Row Level Security on every table in the public schema.
For each table, state who owns a row: [one user / a team via memberships / public read].
Write separate select, insert, update and delete policies.
Use TO authenticated unless the table is meant to be public.
Use (select auth.uid()) and add WITH CHECK to every insert and update policy.
Never read roles from user_metadata; use app_metadata.
Do not use the service role key in front-end code.
List the policies you created and the tables still without RLS.
Then run steps 2 to 5 yourself. The builder’s summary tells you what it intended; the tests tell you what it did.
Frequently asked questions
Is it safe that my Supabase key is visible in the browser?
Yes, for the publishable key (the anon key in older projects), as long as RLS is on for every table and the policies are correct. That key is designed to be public. The secret key (service_role) is different: it bypasses all policies and must never reach the browser.
Do Lovable and Bolt turn on RLS automatically?
For tables they create, generally yes, and Supabase now enables RLS on tables created in its dashboard. Tables added later by hand, by SQL or by a migration can still be created without it, so check the full list (step 2) rather than assuming.
Is the built-in security scan enough?
It is a necessary first pass, not a sign-off. Scans reliably catch tables without RLS and rules that allow everything. They cannot judge whether a policy matches your business rules, such as which team member may see which customer’s records. That takes the two-user test in step 5.
My table has RLS on but no policies. Is that a problem?
Not a security problem: with RLS on and no policy, the API returns nothing to anyone. It is usually a functional problem, because the app stops showing data. The risk is the next step, when someone fixes the empty screen with a policy that lets everyone in.
What is the difference between USING and WITH CHECK?
USING decides which existing rows a user can see, change or delete. WITH CHECK decides whether a new or changed row is allowed. Insert and update policies need WITH CHECK; without it, a user can create or rewrite rows in another user’s name.
Does RLS slow the app down?
It can on large tables if every row triggers a function call or an unindexed lookup. Wrapping auth.uid() as (select auth.uid()), indexing the columns your policies filter on and keeping membership checks in one helper function keep the overhead small.
What should I do if my data was already exposed?
Close the gap first: enable RLS and correct the policies. Then rotate any key that leaked, review the API logs for unexpected reads, and take legal advice on notification. Under GDPR, a personal data breach must generally be reported to the regulator within 72 hours of becoming aware of it.
How Assystant can help
If your app sits in the right half of the decision guide, or the one-hour check turned up something you do not want to fix by prompt, we can take it from there. Our rescue audit for Lovable apps and Bolt apps covers every table’s policies, the keys, sign-in, payments and Edge Functions, and rates each area red, amber or green with a fixed-price plan. You can keep building in your builder afterwards; we make sure what it writes holds up.
For the wider list of checks before launch, see Lovable & Bolt app security checklist: 12 checks before real users. To talk it through, book a free 20-minute rescue review.
Sources
- Supabase, Row Level Security: roles, USING and WITH CHECK, performance, views, security definer functions, user_metadata.
- Supabase, Understanding API keys: publishable and secret keys, legacy key deprecation by end of 2026.
- Supabase, Security retro 2025 (January 2026): RLS on by default in the dashboard, event triggers, alerts.
- Supabase splinter lints: 0013 RLS disabled in public, with related lints 0007, 0008, 0010 and 0015.
- Matt Palmer, Statement on CVE-2025-48757: 1,645 sites checked, 170 exposed, 303 endpoints.
- NVD, CVE-2025-48757: CVSS 9.3, vendor dispute.
- Lovable, Security center and insights.
- Bolt, Database security and Security audit on publish (July 2026).
- European Union, GDPR Article 33: notification of a personal data breach to the supervisory authority.
Saket Shukla