Postgres Row-Level Security Has Silent Failure Modes That Green Tests Can Miss
A developer publishing findings on DEV Community discovered that Postgres row-level security (RLS) tests can pass as green even on databases with no active policy, if the test fixture contains only one tenant's data. The investigation found that ENABLE ROW LEVEL SECURITY exempts the table owner by default, while FORCE ROW LEVEL SECURITY does not — a distinction that can mask broken isolation. Testing revealed that reused database connections can silently return zero rows instead of raising an error when tenant context is lost, making failures invisible until a customer notices. A seemingly safe fix — using NULLIF to tolerate empty strings in the policy — was shown to convert loud errors into silent data leaks. The author concludes that a query which raises an exception is preferable to one that quietly returns nothing, as silent failures are far harder to detect in production.
This is an AI-generated summary. ShortSingh links to the original source for the complete article.
Discussion (0)
Log in to join the discussion and vote.
Log in