Supabase database
Can Supabase RLS hide a column, like email on a public profile?
No. Row level security decides which rows a user sees, and every column of a visible row comes with it, so a public profiles table also publishes its email and phone columns. Move the private columns to their own owner-only table, or use column grants, which Postgres enforces but Supabase calls an advanced feature.
TL;DR
- In our lab a “Public profiles are viewable by everyone” policy returned every email and phone number to a logged-out visitor.
- Option B, which Supabase’s docs point to: keep public columns in
profilesand move email and phone to an owner-only table. Visitors saw names; each user saw only their own email. - Option A, column grants, blocked the email for visitors, but
select=*then failed with 42501, and the owner couldn’t read their own email either. - Hiding a column in the app’s JavaScript hides nothing: the API still returns it.
Why the email comes with the row
A policy is a yes or no per row. If a directory page needs every profile, the read policy says yes to every row, and the API returns whatever columns the query asks for. Supabase’s column-level security page says it plainly: RLS gives control over rows, not over which columns users can access within them.
Leaving a column out of your app’s query doesn’t help. Anyone with your public key can ask for select=* themselves.
What we saw in the lab
-- profiles(id, display_name, avatar_url, email, phone)
-- policy: for select to anon, authenticated using (true)
anon GET /profiles?select=*:
[{"id":"11111111-…","display_name":"Alice","avatar_url":"a.png","email":"alice@example.com","phone":"07700 900111"},
{"id":"22222222-…","display_name":"Bob","avatar_url":"b.png","email":"bob@example.com","phone":"07700 900222"}] [HTTP 200]Option B (recommended): a separate owner-only table
Supabase’s docs recommend RLS together with dedicated tables over column privileges for most apps. Keep what everyone may see in profiles, and move the rest:
create table public.profile_private (
user_id uuid primary key references public.profiles(id) on delete cascade,
email text,
phone text
);
alter table public.profile_private enable row level security;
insert into public.profile_private (user_id, email, phone)
select id, email, phone from public.profiles;
alter table public.profiles drop column email, drop column phone;
create policy "read own private profile" on public.profile_private
for select to authenticated using ((select auth.uid()) = user_id);
create policy "update own private profile" on public.profile_private
for update to authenticated
using ((select auth.uid()) = user_id) with check ((select auth.uid()) = user_id);
-- Tables created after 30 Oct 2026 also need: grant select, update on public.profile_private to authenticated;anon GET /profiles?select=*: [{"id":"11111111-…","display_name":"Alice","avatar_url":"a.png"}, {"id":"22222222-…",…}] [HTTP 200]
anon GET /profile_private: [] [HTTP 200]
bob GET /profile_private: [{"email":"bob@example.com"}] [HTTP 200]
alice GET /profile_private: [{"email":"alice@example.com"}] [HTTP 200]Drop the old columns only after the app reads from the new table. If you keep email in sync with sign-up, write it from the profile trigger, not from the browser.
Option A: column grants
revoke select on public.profiles from anon, authenticated;
grant select (id, display_name, avatar_url) on public.profiles to anon, authenticated;anon GET select=*: {"code":"42501","message":"permission denied for table profiles"} [HTTP 401]
anon GET select=id,display_name,avatar_url: [{"id":"11111111-…","display_name":"Alice","avatar_url":"a.png"}, …] [HTTP 200]
anon GET select=email: {"code":"42501", … } [HTTP 401]
alice GET her own email: {"code":"42501", … } [HTTP 403]It works, with two costs Supabase’s page warns about. Restricted roles can’t use *, so every .select('*') on that table breaks, and so can a .select() after an insert or update, until you list the columns. And the grant is per role, not per user, so the owner loses their own email too. Supabase calls column privileges an advanced feature it doesn’t recommend for most users. Option B avoids both.
A third route is a view that exposes only the public columns. A plain view runs as its owner and skips RLS (Security Advisor: “Security Definer View”), so if you take it, make sure the view selects only columns you would publish.
How to check it worked
Ask the API for everything, as a visitor, with only your public key, from a terminal:
curl "https://YOUR-PROJECT.supabase.co/rest/v1/profiles?select=*" \
-H "apikey: YOUR_PUBLISHABLE_OR_ANON_KEY"No email or phone may appear. Then sign in as two users and check each sees only their own private row. To list every exposed table with personal-looking columns, the read-only audit query covers it.
Ask your AI builder to fix it
My public.profiles table is readable by everyone (for the directory page), so its email and phone columns are public too. Create public.profile_private (user_id uuid primary key references public.profiles(id) on delete cascade, email text, phone text) with RLS on and owner-only select and update policies for the authenticated role using ((select auth.uid()) = user_id). Copy the data across, update the app to read email and phone from profile_private, and only then drop those columns from profiles. Don't add any using (true) policy to profile_private. Write it as migrations and show me the SQL and the code changes before you apply them.Questions people ask
Can Supabase RLS hide specific columns?
No. Row level security filters rows. Every column of a row the user may see is returned if the query asks for it. Use a separate owner-only table for private columns, or Postgres column grants.
Why does select * fail after I restrict columns in Supabase?
With column grants, a role can only select the columns granted to it, and * asks for all of them. In our lab select=* returned 42501 permission denied. List the allowed columns, or move private columns to their own table instead.
If my app doesn't show the email, is it safe?
No. Anyone with your public key can query the table directly and ask for every column. In our lab a logged-out visitor read every email and phone number that the page never displayed.
Should I use a view to hide columns?
It can work, but a normal view runs as its owner and skips row level security, and the Security Advisor flags it as a Security Definer View. A separate owner-only table is simpler to get right.
Sources and lab
- Supabase: Column Level Security, read 5 Dec 2026: RLS doesn’t control columns; column privileges are advanced and not recommended for most users; no wildcard for restricted roles.
- Supabase: Views and RLS.
- PostgreSQL: Privileges.
- Lab: Postgres 17.11 and 18.6 with PostgREST 12.2.12 and a Supabase role shim, real HTTP requests as a logged-out visitor and two signed-in users, 5 Dec 2026. Synthetic data only. Same results on both versions.
Related findings
The checks behind this guide, each with example code, a self-check and the fix.
Free check
Check your migrations for this, free.
Paste a public GitHub repo. The free RLS check reads its supabase/migrations and flags tables with RLS off or no policies, always-true policies, update policies with no WITH CHECK, SECURITY DEFINER functions anyone can call or with no fixed search_path, views that skip RLS and public buckets. It never connects to your database.
Written by Manraj Singh Dhillon. Last checked 5 Dec 2026. Code samples are synthetic and run against your own project; nothing here names a real app. Spotted a mistake? Tell us.