fix: block client INSERT/DELETE on leaderboard to prevent score forgery (#1925) - #1931
fix: block client INSERT/DELETE on leaderboard to prevent score forgery (#1925)#1931atul-upadhyay-7 wants to merge 1 commit into
Conversation
…ry (durdana3105#1925) Authenticated users could delete their own leaderboard row and re-insert it with arbitrary xp/streak/badges values, bypassing the UPDATE hardening from previous migrations. Drop the permissive INSERT/DELETE RLS policies and revoke those privileges from anon + authenticated; join_leaderboard() remains the only row-creation path.
|
@atul-upadhyay-7 is attempting to deploy a commit to the durdana3105's projects Team on Vercel. A member of the Team first needs to authorize it. |
|
Warning Review limit reached
Next review available in: 58 minutes You've used all free OSS reviews for now. Wait for the free limit to reset to keep reviewing this public repository. How can I continue?After more reviews become available, a review can be triggered using the To avoid repeated limits, reduce automatic review volume by pausing incremental auto-reviews earlier, using label-based review opt-in, excluding WIP or generated PR titles, or requesting reviews manually when the PR is ready. If your team needs uninterrupted high-volume reviews, an organization admin can enable usage-based reviews. How do review limits work?CodeRabbit enforces per-developer PR review limits for each organization. Most developers receive the normal plan review availability. For paid Pro and Pro+ PR reviews, CodeRabbit uses adaptive limits for sustained high-volume activity. When a developer's recent PR review activity reaches the 95th percentile or higher among CodeRabbit users, additional reviews become available more gradually as earlier reviews age out of the rolling window. Please refer docs for additional details. Review details⚙️ Run configurationConfiguration used: defaults Review profile: CHILL Plan: Pro Plus Run ID: 📒 Files selected for processing (1)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
Fixes #1925
Problem
The consolidated RLS policies let any authenticated user INSERT their own leaderboard row with arbitrary
xp/streak/sessions_joined/badgesvalues and DELETE it (to re-insert with fabricated scores). Prior hardening only restricted UPDATE, so score forgery was still possible:Changes
New migration
20260805000002_block_leaderboard_client_insert_delete.sql:"Users can insert leaderboard entry"and"Users can delete leaderboard entry"policies.REVOKE INSERT, DELETE ON public.leaderboard FROM anon, authenticated;The SECURITY DEFINER
join_leaderboard()RPC (zero-initializes scores, used byLeaderboard.tsx) remains the only legitimate row-creation path and is unaffected by the revoke.Verification
rpc("join_leaderboard").