DEV Community

Discussion on: Supabase Stops Auto-Exposing New Tables on Oct 30: The Checklist to Run This Week

Collapse
 
mattbusel profile image
Matt Busel •

One gap I'd add to the checklist: functions. The Oct 30 change, as the changelog words it, is about tables. Postgres grants EXECUTE on new functions to PUBLIC by default, and anything in public is callable at /rest/v1/rpc/<name> with the anon key. A security definer function runs as its owner, so it skips RLS and every grant you just revoked on the table it reads.

select p.oid::regprocedure
from pg_proc p join pg_namespace n on n.oid = p.pronamespace
where n.nspname = 'public' and p.prosecdef
  and has_function_privilege('anon', p.oid, 'execute');
Enter fullscreen mode Exit fullscreen mode

Fix per function: revoke execute on function public.fn(args) from public, anon;. For future ones you need two statements, because per-schema default privileges can only add, never remove the PUBLIC default:

alter default privileges for role postgres in schema public revoke execute on functions from anon, authenticated;
alter default privileges for role postgres revoke execute on functions from public;
Enter fullscreen mode Exit fullscreen mode

Same trap with views: they run as the owner unless created with (security_invoker = true) (PG15+), so a view over an RLS table can still hand out every row.

Have you seen the Security Advisor flag definer functions anon can call, or only tables?