Repository navigation
Fix security review findings: anonymous rating leak, Data API lockdown - #26
Merged
Merged
Conversation
POST /api/ratings/flag returned the full PageRating row, including the author's real userId. Any signed-in user could flag an anonymous review and match that id against the public Crew Wall to de-anonymize the author. Return only a success message.
Prisma creates tables in the public schema, which Supabase exposes over PostgREST to the anon and authenticated roles by default. Enable row level security and revoke those grants (including default privileges for future tables) so the public anon key can't read or write them. Prisma connects as the table owner and is unaffected. Document running it in the README.
Contributor
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
This branch was successfully deployed
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.
Fixes both findings from the full-project security review.
1. Anonymous reviewers could be identified (Medium, confirmed)
POST /api/ratings/flagreturned the wholePageRatingrow, including the author's realuserId.GET /api/members) shows that same id next to a name, so the author was identified.{ success, message }. The rating UI only checks whether the request succeeded, so nothing else changes.2. App tables open through Supabase's public Data API (High if the project uses Supabase defaults)
Prisma creates every table in
public. By default, Supabase exposespublicover its REST API and grants theanonrole access. So the public anon key could read or write tables directly, for example inserting a row intoAdminEmailto become an admin.New file
prisma/security/lock-down-data-api.sql:public, with no policies.anonandauthenticatedaccess, including for tables created later.Prisma connects as the table owner, so the app isn't affected. The browser only uses Auth, Storage and a Realtime presence channel, none of which touch these tables. The README setup steps now include running this script.
Test plan
tsc --noEmit,npm run lintlock-down-data-api.sqlin Supabase and confirm the verification output