Skip to content

Profiles table missing RLS policy, all user emails readable via anon Supabase key #1870

Description

@anshul23102

Bug Description

The profiles table in Supabase has no Row Level Security policy scoping reads to the authenticated user's own row. Using the publicly exposed VITE_SUPABASE_ANON_KEY, any visitor can retrieve the email address and profile data of every registered user.

Steps to Reproduce

  1. Extract VITE_SUPABASE_ANON_KEY from the browser bundle.
  2. Run:
curl 'https://<project>.supabase.co/rest/v1/profiles?select=id,email' \
  -H 'apikey: <anon_key>' -H 'Authorization: Bearer <anon_key>'
  1. Observe: all profile records returned without authentication.

Root Cause

RLS is not enabled on profiles, or the policy is missing the USING clause that restricts reads to the owner:

-- missing policy:
CREATE POLICY "users view own profile"
  ON profiles FOR SELECT
  USING (auth.uid() = id);

Impact

Mass PII exposure: names, emails, and profile metadata of all registered users harvested without any authentication.

Proposed Fix

ALTER TABLE profiles ENABLE ROW LEVEL SECURITY;
CREATE POLICY "owner_read" ON profiles
  FOR SELECT USING (auth.uid() = id);
CREATE POLICY "owner_update" ON profiles
  FOR UPDATE USING (auth.uid() = id);

Metadata

Metadata

Assignees

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions