fix(db): harden get_following_feed against impersonation#126
Conversation
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
|
Warning Review limit reached
More reviews will be available in 57 minutes and 4 seconds. Learn how PR review limits work. Your organization has reached its usage spending cap. Adjust your spending cap in the billing tab. ⌛ How to resolve this issue?After more reviews become available, a review can be triggered using the We recommend that you space out your commits to avoid hitting the rate limit. 🚦 How do rate limits work?CodeRabbit enforces hourly rate limits for each developer per organization. Our paid plans include higher PR review limits than trial, open-source, and free plans. In all cases, reviews become available again over time. During sustained high-volume PR review activity, CodeRabbit may temporarily slow when the next review becomes available. Please see our Fair Usage Limits Policy for further information. ℹ️ Review info⚙️ Run configurationConfiguration used: defaults Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (1)
✨ Finishing Touches🧪 Generate unit tests (beta)
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 |
Carries over the unbounded-limit hardening from the alternative fix so closing that PR loses no coverage. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
e6ae685 to
40bf709
Compare
|
Merged. Adds migration |
Motivation
public.get_following_feedRPC was declaredSECURITY DEFINERbut trusted the caller-suppliedp_user_id, allowing callers to impersonate other users and bypass RLS to read private posts anddaily_usageJSON.authenticatedwithout revokingPUBLIC.Description
supabase/migrations/20260504090000_harden_get_following_feed_rpc_auth.sqlthatCREATE OR REPLACE FUNCTION public.get_following_feed(...)and preserves the original signature and result shape.v_caller_id := auth.uid(), rejects unauthenticated callers, and raisesForbiddenifp_user_idis distinct fromv_caller_id, then usesv_caller_idin the feed predicate.REVOKE EXECUTE ON FUNCTION public.get_following_feed(...) FROM PUBLIC;and thenGRANT EXECUTE ... TO authenticated;.Testing
rg -n "get_following_feed|harden_get_feed" supabase/migrations, which succeeded.nl -ba supabase/migrations/20260504090000_harden_get_following_feed_rpc_auth.sqlto verify the checks and predicate changes, which succeeded.git addandgit commit -m "fix(db): harden get_following_feed auth checks", which produced a successful commit.Codex Task