critical · M3 · MASVS-AUTH-2 · PTKD-BACKEND-SUPABASE-RLS-OFF
Supabase table without Row Level Security
A table in the public schema never gets Row Level Security enabled. Supabase exposes public tables through its REST API, and the anon key in your app is enough to read, change and delete every row.
How it is exploited
A vibe-coded app creates public.profiles and public.messages in a migration but never enables RLS. An attacker copies the anon key and project URL from the app, then calls GET https://<ref>.supabase.co/rest/v1/messages?select=* and downloads every user's private messages. A PATCH or DELETE on the same URL changes or wipes them.
Why it matters
Complete exposure of user data and loss of integrity: anyone can read, edit or delete every row. This is the most common breach in AI-built apps.
How to fix it
- Add `alter table public.<table> enable row level security;` for every public table in a new migration.
- Add policies per operation, keyed on the signed-in user (auth.uid()).
- Move tables that the app should never read directly into a private schema.
- Run Supabase's Security Advisor (Dashboard → Advisors) and rescan with PTKD.
migration
alter table public.messages enable row level security;
create policy "owner can read" on public.messages
for select to authenticated using ((select auth.uid()) = user_id);
create policy "owner can write" on public.messages
for insert to authenticated with check ((select auth.uid()) = user_id);Does your app have this?
PTKD checks your build or your source project for PTKD-BACKEND-SUPABASE-RLS-OFF and every other check in this knowledge base.
Scan your appReferences
Related checks (M3)
- Permissive CORS with credentials
- State-changing request succeeded without authentication
- Weak JWT observed on the wire
- Biometric authentication not bound to a cryptographic key
- Premium access is stored on the phone and trusted (heuristic)
- Firebase rules trust an email address nobody verified
- Firebase security rules open to everyone
- Users can make themselves admin or premium in Firestore