---
title: "Discussion on \"How `OR` in a Postgres RLS policy leaked every flagged row to every user\" | Hashnode"
description: "Discussion on \"How `OR` in a Postgres RLS policy leaked every flagged row to every user\". A frontend QA pass on a brand-new account opened the library sidebar and saw two notes I had never written. They were public seed entries from a different user. Same UUIDs across every fresh account I tested.\nThis is a post-mortem of how multiple Pos..."
url: "https://hashnode.com/posts/how-or-in-a-postgres-rls-policy-leaked-every-flagged-row-to-every-user/69f344e1aa6209bb6cc03061"
---

[Feed](https://hashnode.com/feed) /

Discussion

# [How \`OR\` in a Postgres RLS policy leaked every flagged row to every user](https://divenrastdus.hashnode.dev/how-or-in-a-postgres-rls-policy-leaked-every-flagged-row-to-every-user?utm_source=hashnode&utm_medium=feed)

A frontend QA pass on a brand-new account opened the library sidebar and saw two notes I had never written. They were public seed entries from a different user. Same UUIDs across every fresh account I tested. This is a post-mortem of how multiple Pos...

Apr 30 · 7 min read · divenrastdus.hashnode.dev  
Read the article

-   [#postgres](https://hashnode.com/tag/postgres)
-   [#security](https://hashnode.com/tag/security)
-   [#supabase](https://hashnode.com/tag/supabase)
-   [#webdev](https://hashnode.com/tag/webdev)

## Written by

[Diven Rastdus](https://hashnode.com/@divenrastdus)

@divenrastdus

  
[View profile](https://hashnode.com/@divenrastdus)

Senior Full-Stack Developer & AI Engineer. Building production AI agents and SaaS tools.

Senior Full-Stack Developer & AI Engineer. Building production AI agents and SaaS tools. Open source contributor and technical blogger.

## Responses 1

Markdown supported · ⌘↵ to post

[BaoDev Studio](https://hashnode.com/@baodev-studio)

[May 19](https://hashnode.com/posts/how-or-in-a-postgres-rls-policy-leaked-every-flagged-row-to-every-user/69f344e1aa6209bb6cc03061/comment/6a0c676f883727741155827f)

This catches almost everyone the first time. The mental model "each policy is a check" is wrong — Postgres treats multiple PERMISSIVE policies as OR (any policy granting access = access granted).

For cross-cutting constraints that must always hold, RESTRICTIVE policies are the right tool because they're AND'd with everything else:

`CREATE POLICY user_isolation ON journal_entries AS RESTRICTIVE FOR ALL USING (auth.uid() = user_id);`

That lives alongside your existing permissive policies and short-circuits the OR-leak case. If a public-features schema ships before the feature is launched, the RESTRICTIVE policy still enforces ownership.

The app-layer filter you added is the right belt-and-braces fix. Combining both — explicit filters + RESTRICTIVE policy — gives two failure surfaces that both have to fail before data leaks. RESTRICTIVE in particular is underused because the docs mention it almost as a footnote.
