From 5d6213af3a03c6def9ef19dd19f261d0a5823bf1 Mon Sep 17 00:00:00 2001 From: Anshul Jain Date: Wed, 29 Jul 2026 18:00:18 +0530 Subject: [PATCH] Fix overly-permissive RLS policy on profiles table Drop 'Public profiles are viewable by everyone' policy Replace with secure 'profiles_select_own' policy Restrict reads to authenticated user's own profile (auth.uid() = id) Prevents unauthorized email and profile metadata exposure via anon API key --- .../20260729000000_add_profiles_rls_policy.sql | 13 +++++++++++++ 1 file changed, 13 insertions(+) create mode 100644 supabase/migrations/20260729000000_add_profiles_rls_policy.sql diff --git a/supabase/migrations/20260729000000_add_profiles_rls_policy.sql b/supabase/migrations/20260729000000_add_profiles_rls_policy.sql new file mode 100644 index 00000000..60ba8b20 --- /dev/null +++ b/supabase/migrations/20260729000000_add_profiles_rls_policy.sql @@ -0,0 +1,13 @@ +-- Fix overly-permissive profiles table RLS policy (#1870) +-- Restrict profile reads to only the authenticated user's own profile +-- Prevents unauthorized email and profile metadata exposure via anon key + +-- Drop the overly-permissive public read policy +DROP POLICY IF EXISTS "Public profiles are viewable by everyone." ON public.profiles; + +-- Replace with secure policy: Users can only read their own profile +CREATE POLICY "profiles_select_own" + ON public.profiles + FOR SELECT + USING (auth.uid() = id); +