Tighten RLS boundaries for user profile data#188
Open
legalverb wants to merge 1 commit into
Open
Conversation
This was referenced May 12, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
userstable reads to the authenticated owner instead of exposing every row through the existingOR truepolicy.public_user_profilesprojection for profile pages so public rendering can use a safe subset of columns.Security impact
The current schema enables RLS on user-scoped tables, but
users_self_selectcurrently evaluates to public access for every row. Theuserstable includes fields such as email, reader preferences, location, reading stats, supporter flags, timestamps, and profile metadata. Public profile pages should not require exposing the full table.The old
FOR ALLpolicies onreading_lists,reading_list_books, andannotationsalso mix public-read conditions with write/delete policy definitions. Splitting read and write paths avoids public rows becoming eligible for mutation if table grants are present.Validation
git diff --check.public_user_profilesview are present.corepack pnpm --filter @librarfree/db exec prisma validatereportsCommand "prisma" not found).Related to #100.