fix: stop exposing every user's email address through profiles RLS (#1924) - #1930
fix: stop exposing every user's email address through profiles RLS (#1924)#1930atul-upadhyay-7 wants to merge 1 commit into
Conversation
…urdana3105#1924) Revoke column-level SELECT on profiles.email from anon and authenticated roles so only the row owner and service role can read it, and drop the permissive SELECT policies on the legacy public.users compat table. Update the client to select only non-sensitive profile columns instead of '*' (useMessages, Chat, Profile, EditProfile) and remove email-based fallbacks in the chat UI.
|
@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. |
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: defaults Review profile: CHILL Plan: Pro Plus Run ID: 📒 Files selected for processing (7)
📝 WalkthroughWalkthroughThe PR restricts profile email access and removes email fields from client profile loading, normalization, display, and search. Profile queries now select explicit non-sensitive columns. ChangesProfile email protection
Estimated code review effort: 3 (Moderate) | ~20 minutes Possibly related PRs
Suggested labels: Suggested reviewers: 🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✨ Finishing Touches 💡 1🛠️ Fix failing CI checks 💡
🧪 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 |
Fixes #1924
Problem
The
profilesSELECT policy allows any authenticated user to read every profile row, including theemailcolumn. The legacypublic.userscompat table (also storingemail) has the same permissive policy. Client code was actively fetching other users' emails viaselect("*")in the chat directory.Changes
20260805000001_protect_profiles_email_rls.sql):REVOKE SELECT (email) ON public.profiles FROM anon, authenticated;— only the row owner and service role can read emails.public.usersandREVOKE ALL ... FROM anon, authenticated.select("*")with explicit non-sensitive columns in:src/hooks/useMessages.ts(peer directory:id, name, avatar_url, is_mentor, is_learner, last_active, last_seen)src/pages/Chat.tsx,src/pages/Profile.tsx,src/pages/EditProfile.tsxsrc/components/messages/Sidebar.tsx,src/components/messages/utils.ts— drop email-based display/search fallbacks.Verification
npm run typecheck— no new errors (only the pre-existingApp.tsx/useSessions.tserrors that also exist on main).npx vitest runfor chat-related test files — 28/28 pass.Admin.tsxis unaffected (served by the admin-gatedadmin_get_all_profilesSECURITY DEFINER RPC).Summary by CodeRabbit