Published / 7 min read / Auth & Database Security

Supabase RLS, Access Control, and Multi-Tenant Isolation: What Scanners Miss

Static code scanners excel at flagging outdated npm packages and regex-matching API keys. Where they routinely fail is authorization business logic—specifically whether User A in Organization 1 can read or mutate Organization 2’s records. In multi-tenant SaaS apps built with Next.js, FastAPI, and Supabase, those bugs are critical launch blockers.

1. Missing or Permissive RLS Policies

During rapid MVP builds, developers often disable Row-Level Security to unblock UI testing or add a temporary policy like:

CREATE POLICY "allow_authenticated_read"
ON public.invoices
FOR SELECT
TO authenticated
USING (true);

Because the policy exists and syntax-checks cleanly, automated scanners stay silent. Yet any authenticated user with your public anon key can query every customer’s invoices directly via PostgREST. Policies must scope access explicitly to auth.uid() or verified organization membership.

2. Exposed service_role Keys

The Supabase service_role key bypasses Row-Level Security completely. If an AI assistant places it inside a client component or prefixes it with NEXT_PUBLIC_, every RLS policy in your database becomes irrelevant.

3. Broken Object-Level Authorization (BOLA / IDOR)

Even when backend routes require a valid login token, AI-generated handlers often query by id alone:

// Vulnerable: checks session exists, never checks tenant ownership
const project = await db.projects.findUnique({ where: { id: req.params.id } });

Every sensitive read, update, and delete query must filter by both the resource ID and the authenticated user’s verified org_id or membership check.

4. Client-Side-Only Route Guards

Hiding an /admin link in React or redirecting inside a useEffect hook does not protect the underlying API route or Next.js Server Action. Server-side role checks must run inside every endpoint and server action.

How Our 72-Hour Audit Validates Isolation

In every 72-hour Pre-Launch Readiness Audit, automated checks run first, followed by dedicated senior engineering review tracing SQL migrations, RLS policies, API handlers, and multi-tenant boundaries—plus live runtime verification between two separate test tenants when staging access is in scope.

Audit Your Multi-Tenant & RLS Setup