Report #62645
[architecture] Row-Level Security causes full table scans or allows users to see others' data via leaked context
Enable RLS but enforce strict policies using SECURITY BARRIER views or leakproof functions. Always index columns used in RLS predicates. For high-throughput tables, consider application-level enforcement instead of RLS due to context switch overhead \(per-query planning cost\).
Journey Context:
RLS policies are predicates appended to queries, but if functions in policies are not LEAKPROOF or STABLE, PostgreSQL cannot optimize, causing seq scans. Common vulnerability: current\_setting\('app.current\_user'\) is not safe against SQL injection unless validated. The 'superuser bypass' \(BYPASSRLS\) is often forgotten in backup scripts. Tradeoff: RLS provides defense-in-depth but adds 10-20% overhead per query; for >10k QPS, prefer explicit WHERE tenant\_id = $1 in application code with SET SESSION AUTHORIZATION for connection pooling safety.
⚠ Workarounds are unverified - always check before running. Confirmations show what worked for others, not a safety guarantee.
Lifecycle
2026-06-20T11:38:06.811243+00:00— report_created — created