Lovable Supabase RLS Checklist: Table by Table
Updated 2026-10-26
A Lovable app usually calls Supabase straight from the browser: supabase.from("profiles").update(...). Every one of those calls is something any visitor can repeat with your public key, outside your UI. This checklist starts from the tables your bundle actually touches and walks through each one, so nothing added in a later prompt slips through.
1. Inventory the tables your browser code touches
Search your project (or the built assets/index-*.js) for .from(" and note each table with the operations used on it: select, insert, update, upsert, delete. Writes matter most, because a write the UI performs for the current user is a write anyone can attempt for any row.
A free ShipGuard scan does the same inventory passively from your public bundle and lists the tables with their operations. It never queries your database.
# from your project root
grep -RhoE "\.from\([\"'][a-zA-Z0-9_]+[\"']\)\.(select|insert|update|upsert|delete)" src | sort | uniq -c2. Confirm RLS is enabled on each one
Run this in the Supabase SQL editor. Every table your app touches should show true. A table with RLS off in an exposed schema is readable and writable by the anon and authenticated roles if they have the default grants.
select c.relname as table, 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 = 'r'
order by 2, 1;3. Match each table to a policy shape
Most app tables fall into a few patterns. Pick one per table instead of writing one-off policies.
- User-owned rows (notes, plans, streaks): every operation scoped with
auth.uid() = user_id, andwith checkon insert and update. - Team or org rows: a membership check such as
exists (select 1 from members m where m.org_id = org_id and m.user_id = auth.uid()). - Public read-only data (feature flags, plans, vocabulary lists): a select policy only, no insert/update/delete policy at all.
- Append-only logs (client error reports, feedback, consent events): insert only, with a
with checkthat pinsuser_idtoauth.uid()(or null for anonymous), and no select for clients. - Admin-only tables (roles, billing exemptions): no client policies. Change them from an Edge Function or server code with the secret key.
4. Close the role-escalation gap on profiles
A common mistake: an update policy on profiles that lets users edit their own row, while that row also holds role, plan or is_admin. The policy is correct and the user still promotes themselves. Keep privilege columns in a separate table without client write policies, or limit which columns clients may update.
-- allow clients to update only harmless columns
revoke update on table public.profiles from authenticated;
grant update (display_name, avatar_url, bio) on table public.profiles to authenticated;5. Check views and database functions too
Views run with their owner's rights by default, which can bypass RLS on the tables underneath. On Postgres 15+ create them with (security_invoker = true). Functions marked security definer in an exposed schema can be called through the API; revoke execute from anon and public unless they are meant to be public.
alter view public.profiles_public set (security_invoker = true);
revoke execute on function public.admin_reset(uuid) from public, anon;6. Test with two users and no user
Sign in as test user A and create data. Then, as test user B, try to select, update and delete A's rows through the API, not the UI. Finally try the same with only the public key. Each attempt should return nothing or an error. Only test your own project.
Checklist
- Every table from the
.from("...")inventory has RLS enabled - Each table has exactly the policies its pattern needs (no stray insert/update on read-only tables)
- Insert and update policies use
with check, not justusing - No
using (true)on private data; no policy that only checksauth.role() = 'authenticated'for per-user rows - Privilege columns (role, plan, is_admin) cannot be updated by clients
- Views use security_invoker; security definer functions are not callable by anon
- Two-user and anonymous tests pass through the API
Copy-paste fix prompt
List every Supabase table this app reads or writes from the browser (search for .from("...") calls) with the operations used. For each table, enable Row Level Security and write policies for its pattern: user-owned rows scoped by auth.uid() = user_id with WITH CHECK on insert/update, read-only reference tables with select only, append-only logs with insert only, and no client policies for admin tables. Move any role/plan/is_admin columns out of client-updatable tables. Output one SQL migration and a short test plan using two test users.FAQ
Lovable generated policies already. Do I still need this?
Yes. Generated policies are a starting point, and tables added in later prompts are the ones most often missing policies or using a too-broad one. Verify each table against the inventory.
My scan says client-side writes on 10 tables. Is that a vulnerability?
Not by itself. Client-side writes are a normal Supabase pattern. They are safe when each table has strict RLS. The finding is a review list: a passive scan cannot see your policies.
Can ShipGuard test my RLS for me?
No. The scanner is passive and never calls your Supabase API with a key it finds. Use the two-user test above on your own project.
Check your deployed app in seconds
Free passive scan: leaked keys, Supabase exposure, public config files and headers.
Run a free scan