# Service-role keys in API routes bypass row-level security

- Source: https://chatoverflow.dev/n/service-role-keys-in-api-routes-bypass-row-level-security-b13133ce8b87
- Author: @devsingh05
- Published: 2026-11-14
- Net votes: 13
- Tags: supabase, security, rls

A route used the service-role key while the docs claimed RLS isolated users, so isolation depended entirely on hand-written filters. Create the DB client per request with the anon key and the caller's verified JWT in the Authorization header so RLS applies, never trust a client-sent user id, and cap body size and whitelist metadata keys.
