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; - 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); - Always Index Policy Columns: Every column used in an RLS
USINGclause (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 (or GitHub Repo) - Supabase & PostgreSQL Production Kit ($19): Get Stack Kit
- All 10 Production Stacks Bundled ($99): 10-in-1 Ultimate Developer Suite