critical · M6 · MASVS-PRIVACY-1 · PTKD-BACKEND-SUPABASE-AUTH-USERS-EXPOSED
Supabase view in the public schema exposes auth.users
A view (or materialized view) in the public schema selects from auth.users. Views run with their owner's rights and the public schema is served by the Data API, so the app's anon key can read every user's email, phone, sign-in times and metadata through it.
How it is exploited
A migration adds `create view public.user_list as select id, email, raw_user_meta_data from auth.users;` so the admin screen can show names. Anyone with the app's anon key calls `GET /rest/v1/user_list` and downloads every account.
Why it matters
Every user's email, phone and profile data leaks; a GDPR breach and a ready phishing list.
How to fix it
- Drop the view: `drop view public.user_list;`.
- Keep public fields in public.profiles with RLS, filled by an `after insert on auth.users` trigger.
- If an admin screen needs it, read auth.users from an Edge Function that checks the admin role.
Does your app have this?
PTKD checks your build or your source project for PTKD-BACKEND-SUPABASE-AUTH-USERS-EXPOSED and every other check in this knowledge base.
Scan your appReferences
Related checks (M6)
- PII in a response over a cacheable/first-party channel
- Ads start before the user's consent (text search)
- Device/user PII sent to a third party
- Google Play restricted or sensitive permission
- Privacy manifest has invalid keys or values
- Missing Apple privacy manifest (PrivacyInfo.xcprivacy)
- Required-reason API used without a declared reason
- Third-party tracker not disclosed in the privacy manifest