DEV Community

AutoLab Systems
AutoLab Systems

Posted on

Supabase PostgreSQL RLS Security Checklist: Stop Leaking Tenant Data

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;
Enter fullscreen mode Exit fullscreen mode
  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);
Enter fullscreen mode Exit fullscreen mode
  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:

Top comments (0)