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

  1. Enable RLS Immediately on Creation:
ALTER TABLE projects ENABLE ROW LEVEL SECURITY; 
  1. 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); 
  1. 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: