View bypasses Row Level Security
Scan rule · RSC-SEC-112
- Security
- Severity: High
- CWE-284
- OWASP A01-2021
Finds views and materialized views in the API schema without `security_invoker = true` that anon or authenticated may read.
Why this matters
By default, Postgres views run with their owner's privileges, in Supabase usually `postgres`. The RLS policies of the underlying tables then do not apply: whoever may read the view sees every row it shows — including other users' rows.
It rarely stands out, because the tables themselves are properly protected and every policy review comes back green. The view is a second, unprotected entrance to the same data. The Supabase Security Advisor reports it as “Security Definer View”; materialized views have no RLS at all.
Fix: create views with `security_invoker = true` so the table policies apply to the caller. Materialized views belong in a schema the API does not serve.
Scan tier
- Repo access (deep scan)
How to fix it
`alter view <view> set (security_invoker = true)` (Postgres 15+) — or move the view to a non-exposed schema or `revoke select … from anon, authenticated`.