One forgotten Row Level Security (RLS) policy on a Supabase table exposes every row in that table via the public anon key.
3 Rules Every Project Needs
Enable RLS Immediately on Creation :
ALTER TABLE projects ENABLE ROW LEVEL SECURITY ;
Enter fullscreen mode
Exit fullscreen mode
Never Trust Client-Supplied IDs : Reference auth.uid() directly inside the policy rather than trusting a column sent in the JSON body:
CREATE POLICY "Users manage own rows" ON projects FOR ALL USING ( auth . uid ( ) = owner_id ) WITH CHECK ( auth . uid ( ) = owner_id ) ;
Enter fullscreen mode
Exit fullscreen mode
Always Index Policy Columns : Every column used in an RLS USING clause ( owner_id , org_id ) needs a B-Tree index, or table scans will bottleneck under load.
Want Production-Ready .cursorrules & Boilerplates?
I'm a student developer in Japan funding my upcoming new life next spring by packaging strict, battle-tested AI coding setups:
Free Starter .cursorrules & Reviewer Prompts ($0+) : Download Free Starter Pack…