OneShot

All packsMulti-Tenant Auth & RBAC CoreSolve

postgres force row level security breaks security definer functions neon

FORCE RLS everywhere breaks the functions bootstrap depends on

Turning on FORCE ROW LEVEL SECURITY on every table sounds strictly safer, but it also binds the SECURITY DEFINER functions the app relies on for org creation and invites.

3 of 3 runs passedOne decision inside Multi-Tenant Auth & RBAC Core (nextjs-postgres).

What goes wrong

FORCE ROW LEVEL SECURITY subjects even the table owner to RLS policies -- which sounds like the maximally safe setting to reach for on every table. But this pack's bootstrap operations (creating an org, accepting an invite) run as SECURITY DEFINER functions that rely on the owner's normal RLS exemption to insert the very first membership row before any membership exists. FORCE it everywhere and those functions break on managed Postgres, where the connecting owner typically isn't a superuser either.

Why agents get it wrong

"More restrictive is safer" is a reasonable-sounding default when an agent is asked to harden RLS, and FORCE is the option that reads as the stricter one in Postgres's own documentation -- without visibility into which specific functions in the codebase depend on the owner-exemption behavior FORCE removes, applying it uniformly looks like a pure improvement.

What Multi-Tenant Auth & RBAC Core pre-decides

Core decision 9 applies FORCE only to notes (a table no definer function touches) and leaves orgs, org_members, and invites at plain ENABLE, precisely because is_org_member, accept_invite, and the last-owner trigger all run as definer functions relying on that exemption. The posture is enforced three ways rather than left as a convention: a migration creates the non-owner app_user role, the app refuses to boot on an owner connection, and iso-db-posture asserts it in the verify suite.

Source: ARCHITECTURE.md core decision 9

Coming soon — $149Full receipt and details for Multi-Tenant Auth & RBAC Core

Related problems