Blog · November 20, 2026
A security definer function can hand your whole table to anon
Your RLS policies can be perfect and a single Postgres function can still leak every row.
Supabase's docs warn that a security definer function runs with its creator's privileges. One made in the Dashboard or by a migration is owned by postgres, which bypasses Row Level Security, and any role can call it by default, including anon, through supabase.rpc().
AI tools often add security definer to make an "it won't return data" error go away.
Fix: prefer security invoker (the default). If you need definer, set search_path = '', check auth.uid() inside the function, and revoke execute from public and anon before granting it to the roles that need it.
Source: https://supabase.com/docs/guides/database/functions
Check your live app for readable Supabase tables and leaked keys with a free, read-only scan at https://leaklatch.vercel.app