Guides · Updated Nov 9, 2026 · By Lucy at KeySnare

Supabase RLS filters rows, not columns: stop leaking emails and private fields

You turned on Row Level Security, wrote a policy, and your Supabase app passes the "is RLS on?" check. It can still leak every user's email. RLS decides which rows someone can see. It says nothing about which columns. If a row is visible, every column in it comes along.

The short version. Supabase's own docs describe RLS as adding a WHERE clause to every query, and say plainly that it "doesn't give you control over which columns they can access within rows" (Column Level Security docs). So a public profiles table is only safe if every column in it is meant to be public. Keep private fields in a separate owner-only table, or lock columns with grants, and keep fields like is_admin, plan and credits out of anything users can update.

Here's the pattern AI tools write all the time:

create table public.profiles (
  id uuid primary key references auth.users,
  username text,
  avatar_url text,
  email text,                -- private
  phone text,                -- private
  stripe_customer_id text,   -- private
  is_admin boolean default false,  -- privileged
  credits int default 0            -- privileged
);
alter table public.profiles enable row level security;

create policy "Profiles are viewable by everyone" on public.profiles
  for select using (true);
create policy "Users can update own profile" on public.profiles
  for update using (auth.uid() = id);

RLS is on and there are policies, so it looks done. But the first policy hands every column of every row to anyone with your public key, emails and phone numbers included. The second lets each user update every column of their own row, including is_admin and credits. Two separate holes, both caused by thinking in rows when the data is in columns.

Step 1: Find the private columns anyone can read

Run this in the Supabase SQL Editor. It lists columns with risky-looking names and whether the browser roles can read or update them:

select c.table_name, c.column_name,
       has_column_privilege('anon', format('public.%I', c.table_name), c.column_name, 'select') as anon_read,
       has_column_privilege('authenticated', format('public.%I', c.table_name), c.column_name, 'select') as auth_read,
       has_column_privilege('authenticated', format('public.%I', c.table_name), c.column_name, 'update') as auth_update
from information_schema.columns c
where c.table_schema = 'public'
  and c.column_name ~* '(email|phone|address|birth|stripe|customer|token|secret|ip_|is_admin|role|plan|credit|balance|note)'
order by 1, 2;

Then find policies that let everyone see every row:

select tablename, policyname, roles, cmd, qual
from pg_policies
where schemaname = 'public' and (qual = 'true' or qual is null);

A table that shows up in both lists, with anon_read or auth_read true on a private column, is leaking that column to everyone the policy covers. (Rows with qual null are usually insert policies, which only use with check.)

Step 2: Sort every column into public, private or privileged

Mixing all three in one table with one set of row policies is what causes the leak. Supabase recommends RLS plus dedicated tables for most apps and calls column-level privileges an advanced feature, so the split in step 3 is the default fix.

Step 3: Move private fields to an owner-only table

create table public.profile_private (
  user_id uuid primary key references auth.users on delete cascade,
  phone text,
  stripe_customer_id text
);
alter table public.profile_private enable row level security;

-- since Oct 30, 2026 new tables need explicit grants; give only what the app uses
grant select, update on table public.profile_private to authenticated;

create policy "owner reads own private profile" on public.profile_private
  for select to authenticated using ((select auth.uid()) = user_id);
create policy "owner updates own private profile" on public.profile_private
  for update to authenticated
  using ((select auth.uid()) = user_id)
  with check ((select auth.uid()) = user_id);

-- copy the data over, then drop the private columns from the public table
insert into public.profile_private (user_id, phone, stripe_customer_id)
  select id, phone, stripe_customer_id from public.profiles;
-- (email already lives in auth.users, see below)
alter table public.profiles drop column phone, drop column stripe_customer_id, drop column email;

Do you need email in a table at all? Supabase Auth already stores it, and a signed-in user can read their own with supabase.auth.getUser(). If a signup trigger copies the email out of auth.users, point it at the private table or remove it. Data your server needs but users never touch (like stripe_customer_id) can live in a schema the Data API doesn't expose, read only by server code.

Changing the schema? Update the app's queries in the same pull request, and see the safe 42501 fix if a new table returns "permission denied".

Step 4: Or lock the columns with grants

If you can't split the table yet, Postgres column privileges hide columns from a role. You have to remove the table-level privilege first, because a table-level grant covers every column:

-- reads: anon and authenticated may only select the public columns
revoke select on table public.profiles from anon, authenticated;
grant select (id, username, avatar_url) on table public.profiles to anon, authenticated;

-- writes: users may only update their name and avatar
revoke update on table public.profiles from authenticated;
grant update (username, avatar_url) on table public.profiles to authenticated;

Two things to know (both from Supabase's docs): a role with column restrictions can't use select * on that table, so change .select('*') to .select('id, username, avatar_url'); and since the owner also lost access to the private columns, they'll need another way to read them (the private table from step 3, or a server route).

What about views?

A plain view runs with its owner's rights and skips RLS, so it can hand out rows your policies were meant to hide. A view created with (security_invoker = true) respects RLS (Postgres 15+), but the caller then needs read access to the underlying table, so they can skip the view and query the table directly. Views are a convenience, not a lock. Hide the data with a separate table or column grants first.

Step 5: Keep privileged fields server-written

If a user can update their own row, they can update every column in it they have an UPDATE grant on. A policy like auth.uid() = id, in using or with check, only checks who owns the row, not which columns changed. Move is_admin, plan and credits where users have no write access:

create table public.user_entitlements (
  user_id uuid primary key references auth.users on delete cascade,
  plan text not null default 'free',
  credits int not null default 0,
  is_admin boolean not null default false
);
alter table public.user_entitlements enable row level security;
grant select on table public.user_entitlements to authenticated;   -- read only
grant select, insert, update on table public.user_entitlements to service_role;

create policy "owner reads own entitlements" on public.user_entitlements
  for select to authenticated using ((select auth.uid()) = user_id);

Only trusted server code changes these rows, for example after a verified Stripe webhook, using the service_role or secret key on the server (never in the browser). For role checks inside RLS, prefer data users can't edit; Supabase warns that user_metadata in the JWT can be changed by the user.

Step 6: Test logged out and as a second user

Use your project URL and your public anon or publishable key only:

# logged out: look for private fields in the JSON. There should be none.
curl -s "https://YOUR-PROJECT.supabase.co/rest/v1/profiles?select=*&limit=3" \
  -H "apikey: YOUR_PUBLIC_ANON_KEY"

# logged out: asking for a private column by name must fail (or the column must be gone)
curl -s "https://YOUR-PROJECT.supabase.co/rest/v1/profiles?select=email&limit=3" \
  -H "apikey: YOUR_PUBLIC_ANON_KEY"

With column grants in place, the first call returns a 42501 permission error because of the *, which is what you want. Then sign in as a throwaway test user, copy its access token from your browser's local storage (supabase-js usually stores it under a key like sb-<project-ref>-auth-token), and try to give yourself admin:

curl -s -X PATCH "https://YOUR-PROJECT.supabase.co/rest/v1/user_entitlements?user_id=eq.YOUR_TEST_USER_ID" \
  -H "apikey: YOUR_PUBLIC_ANON_KEY" \
  -H "Authorization: Bearer TEST_USER_ACCESS_TOKEN" \
  -H "Content-Type: application/json" \
  -H "Prefer: return=representation" \
  -d '{"is_admin": true, "credits": 999999}'

This must fail with a permission error. Finally, with a second test account, query profile_private and check you only get your own row. Put these checks in your launch checklist and re-run them after every AI edit to the schema. How to check Row Level Security covers the row side.

What KeySnare checks. The free scan reads the SQL migrations in your public repo and flags tables created without Row Level Security turned on, flags the Supabase service_role key where it can reach the browser, and looks for hardcoded keys in your current code. It doesn't connect to your database, read your policies or check column grants yet, so it won't catch the column leak on this page. Run the tests above as well.

Copy-paste prompt for your AI coding tool

Paste this into Cursor, Claude, Lovable, Bolt or whichever AI built your app:

Audit my Supabase schema for column leaks. Row Level Security only filters rows, not columns. For every table in the public schema: 1) list each column and classify it as public, private (email, phone, address, Stripe ids, notes) or privileged (is_admin, role, plan, credits, limits), 2) list every policy and say which roles can see or update which columns as a result, flagging any using (true) policy on a table with private columns, 3) write one migration that moves private columns into an owner-only table (RLS on, policies with (select auth.uid()) = user_id, explicit grants only for what the app uses) and moves privileged columns into a table users can read but not write, 4) update every query in my code to list columns instead of select('*'), 5) make sure only server code using the service_role key changes privileged fields, and 6) give me curl commands using only the public anon key, plus one with a test user's token, that prove a logged-out user can't read private fields and a signed-in user can't make themselves admin. Don't disable RLS, don't bulk GRANT ALL, and don't print any secret keys.

Check your Supabase app in about a minute

Paste a public GitHub repo into KeySnare for a free grade and your top 3 issues, including tables created without RLS, the service_role key in browser code and hardcoded keys, each with a copy-paste AI fix prompt.

Run a free scan →

FAQ

Does Row Level Security hide columns in Supabase?

No. RLS works like a WHERE clause added to every query, so it only decides which rows a role can read or change. Once a row is visible, every column the role has privileges on comes with it. Hiding columns needs column privileges (GRANT on specific columns) or a separate table.

Is a using (true) select policy on profiles always a mistake?

Only if the table holds anything private. using (true) means every row is readable by the roles in the policy, which is fine for a table that only has public fields like username and avatar_url. It's a leak as soon as the same table also stores email, phone, address, Stripe ids or internal notes.

Can I hide private columns with a view?

Not on its own. A normal view runs with its owner's rights and skips RLS. A view created with security_invoker = true respects RLS, but the caller then needs read access to the underlying table, so they can skip the view and query the table directly. Use a separate table or column grants to actually hide the data, and add a security_invoker view only for convenience.

Why does select('*') fail after I add column grants?

Supabase's docs note that a role with column-level restrictions can't use * on that table. List the columns you need instead, for example select('id, username, avatar_url'). The error is a 42501 permission error, which also proves the lock works.

Where should a user's email live?

Usually nowhere in public. Supabase Auth already stores it, and a signed-in user can read their own with supabase.auth.getUser(). If you need it in a table, keep it in an owner-only table where the select policy is auth.uid() = user_id, or in a schema the Data API doesn't expose.

Can users make themselves admin or Pro?

Yes, if the same table holds is_admin, role, plan or credits and users can update their own row. A policy like auth.uid() = id lets the owner change every column they have an UPDATE grant on. Keep those fields in a table only your server writes to, or grant UPDATE only on the safe columns.

Does KeySnare check which columns are exposed?

Not yet. The free scan reads the SQL migrations in your public repo and flags tables created without Row Level Security turned on, flags the Supabase service_role key where it can reach the browser, and looks for hardcoded keys in your current code. It doesn't connect to your database, read policies or check column grants, so run the tests in this guide too.

Sources: Supabase Column Level Security docs · Supabase Row Level Security docs (views and security_invoker, user_metadata warning) · Securing your API

More guides: Supabase Storage: public buckets vs signed URLs · Is my Supabase app safe? How to check Row Level Security · Supabase "permission denied for table" (42501) after Oct 30: the safe fix · Leaked an API key? How to find, rotate and verify it · Vibe-coded app security checklist: 12 checks before you launch