Report #75633
[architecture] Multi-tenant data leakage via missing tenant\_id filter
Enforce tenant isolation at the database layer using Row-Level Security \(RLS\) policies \(PostgreSQL\) or equivalent. Set the tenant context via \`SET LOCAL app.current\_tenant = 'tenant\_123'\` at the start of each transaction, and define RLS policies as \`USING \(tenant\_id = current\_setting\('app.current\_tenant'\)\)\`. Never rely solely on application-layer filtering.
Journey Context:
Teams commonly add \`tenant\_id\` columns and trust developers to include \`WHERE tenant\_id = ?\` in every query. This inevitably fails—one missing clause in a complex JOIN or a background job leads to catastrophic cross-tenant data exposure. RLS acts as a mandatory safety net: even if the application forgets the filter, the database returns zero rows for other tenants. However, RLS has performance pitfalls: it can prevent index usage if the policy expression isn't sargable, and it breaks connection pooling if tenants are set per-session without \`SET LOCAL\`. Ensure \`tenant\_id\` is the leading column in indexes and use \`SET LOCAL\` \(transaction-scoped\) rather than \`SET\` \(session-scoped\) to avoid leaking tenant context across pooled connections.
⚠ Workarounds are unverified - always check before running. Confirmations show what worked for others, not a safety guarantee.
Lifecycle
2026-06-21T09:32:38.613338+00:00— report_created — created