Security basics
Supabase "Function Search Path Mutable": what the warning means
"Function Search Path Mutable" means a Supabase function looks names up in the caller's search path. Which ones matter, and the fix.

In short
- "Function Search Path Mutable" means a function in your Supabase database has no search_path of its own, so a table it names without a schema is looked up in the search path of whoever calls it. The Security Advisor lists every such function.
- It matters most on a security definer function, which runs as its owner and skips Row Level Security. The fix is set search_path = '' on the function, with the schema written in front of every table it names: public.profiles.
- The setting changes nothing about who can call the function. A security definer function in public answers any visitor through your API until you revoke execute from public and anon.
You opened the Security Advisor in your Supabase dashboard and found a column of warnings, all with the same title: Function Search Path Mutable. Under each one is a line in this shape, one per function:
Function `public.set_updated_at` has a role mutable search_path
Function `public.is_admin` has a role mutable search_path
Your app works. Your AI builder wrote those functions for you, and the warning names a setting you have probably never seen.
Here is the part the quick answers get wrong: adding set search_path = '' to
every function on that list is half a fix. It empties the list. It also breaks
any function that names a table without its schema, and on the riskiest
functions it leaves open the question of who is allowed to call them.
What does "Function Search Path Mutable" mean?
It means a function in your database has no search path of its own, so every name inside it that has no schema in front is looked up in the search path of whoever calls it.
A schema is a named section of your database: public holds your app's
tables, auth holds Supabase's accounts. A search path is the list of
schemas Postgres checks, in order, when a query names a table or a function
without saying which schema it is in. The default list, in
Postgres's documentation,
is "$user", public. Postgres's built-in functions live in pg_catalog, and
that schema is searched every time, whatever the list says.
Picture a function as a clerk you send on errands by name. "Fetch the invoices" is a complete instruction only if the clerk knows which cabinets to try, and in what order. The search path is that list of cabinets. A function with no path of its own has no list, so the clerk borrows the list of whoever sent them. That is the "role mutable" in the warning: the role or session calling the function decides where its names lead.
Supabase's linter is open source, and
its rule for this warning, function_search_path_mutable (lint 0011), is short:
- it looks at every function outside the schemas Supabase manages itself, such
as
auth,storageandextensions, and skips functions that belong to an extension - it reports any of those whose settings hold no
search_pathat all, at level WARN, in the Security category - it reads only that one setting, so a function that runs with extra rights and one that only stamps a date get the same line
So the list in your dashboard is every function your builder wrote without that one setting, the harmless and the risky together. The rule's own page gives the reason it exists: without a fixed search path, a function "could behave unpredictably or be exploited to reference unintended database objects."
The same linter reports a table with Row Level Security switched off one level higher, as an error, and that entry is "RLS disabled in public".
Is "Function Search Path Mutable" dangerous?
On most functions it is a loose end. On a security definer function it is the
one to fix first, because that function runs with its owner's rights.
A function runs in one of two ways. security invoker, the default, runs
with the rights of whoever calls it. A caller who steers a name inside it to a
different table changes what their own call reads, using rights they already
had. The clerk is fetching with the visitor's own keys.
security definer runs with the rights of the function's owner. Supabase's
guide to database functions
says what that means on a Supabase project: a function created in the Dashboard
or by a migration "is owned by postgres, which bypasses Row Level Security".
Row Level Security is the set of per-row rules that decides what each visitor
may read. This clerk carries a master key that opens every drawer, whatever
those rules say.
That is the case Postgres writes its warning about. Its section on
writing SECURITY DEFINER functions safely
says the search path "should be set to exclude any schemas writable by untrusted
users", so that nobody can create an object that masks one the function meant
to use. It adds that the temporary-table schema "is searched first by default,
and is normally writable by anyone", and its own example is a password check
that "could be subverted by creating a temporary table named pwds". In the
clerk's terms, somebody slips a folder with the right name into a cabinet the
clerk checks first, and the clerk reads it with the master key in hand.
Supabase's guide turns that into one rule: "When you use security definer, you
must set the search_path."
Two security definer functions appear in Supabase's own guides and in posts
on this blog. One is the trigger that copies a new sign-up
into a profiles table, which is how
"Database error saving new user" is
usually fixed. The other is a small helper such as is_admin() that a Row
Level Security rule calls, which is the fix for
infinite recursion in a policy.
Both posts pin the search path in their examples. A copy your builder wrote
from memory may have left it out.
To see which of your functions are which, run this in the SQL Editor:
select p.oid::regprocedure as function,
p.prosecdef as runs_as_owner,
p.proconfig as settings,
has_function_privilege('anon', p.oid, 'execute') as visitors_can_call
from pg_proc p
where p.pronamespace = 'public'::regnamespace
and not exists (
select 1 from pg_depend d
where d.classid = 'pg_proc'::regclass
and d.objid = p.oid
and d.deptype = 'e'
)
order by p.prosecdef desc, p.proname;
Each row is one function in public, with its arguments. runs_as_owner is
true for a security definer function. settings is empty when the function
has no search path of its own, which is what the warning reports.
visitors_can_call answers a question the warning never asks, and the last
section of this post is about it. Start with the rows where runs_as_owner is
true.
How do you fix "Function Search Path Mutable"?
Give the function an empty search path, and write the schema in front of every
table, view and function of yours inside it: public.profiles, never a bare
profiles.
The rule's page recommends "pinning functions' search_path to an empty
string", and Supabase's guide says the same: "With an empty search path,
search_path = '', name the schema for every relation in the function body".
An empty list means the clerk takes full addresses only, so a caller has no
list to slip a cabinet into. Postgres's built-ins keep working without a
prefix, because pg_catalog is searched whatever the path says, so now(),
count() and coalesce() need no change.
If the body names nothing of yours, one line does it, using the name and
arguments the query above printed. The trigger that stamps updated_at on a row
is the usual example, since all it calls is now():
alter function public.set_updated_at() set search_path = '';
If the body names your tables, replace the function with the schema written in and the setting beside it:
create or replace function public.is_admin()
returns boolean
language sql
security definer
set search_path = ''
stable
as $$
select exists (
select 1 from public.profiles
where id = (select auth.uid()) and role = 'admin'
);
$$;
create or replace has to carry the whole function again, arguments and return
type included, so copy the current definition before you start.
select pg_get_functiondef('public.is_admin()'::regprocedure); prints it in the
SQL Editor. A function that comes from an extension needs that extension's
schema in front as well. Supabase's
extensions guide says
most of them are installed under the extensions schema, so
uuid_generate_v4() becomes extensions.uuid_generate_v4().
One shortcut clears the warning without any of this. The rule checks only that
some search_path is set, so set search_path = public turns the line green
too. For a function that runs as the caller, that is a fair choice. For a
security definer function, Postgres's example puts pg_temp at the end of its
list on purpose, because a temporary schema left out of the list is searched
first. An empty path makes every name in the body carry its schema, so a
temporary table has no bare name to match.
Why did my function break after setting search_path?
Because a name with no schema in front now finds nothing, so the next call to the function fails on it.
The error is relation "profiles" does not exist, code 42P01, and it can look
unrelated to the warning you just fixed. The rule's page says so in its last
line: "once you set the search_path = '' all references to
tables/functions/views/etc in your function's body must be qualified with a
schema name."
The post on "relation does not exist"
walks through that case and the three other causes of the same message.
alter function changes the setting without reading the body. The line runs
cleanly, and the error waits until the function is next called. For a trigger,
that is the next time the row it watches changes. For the sign-up trigger, it is
the next person who signs up, and they see
"Database error saving new user". After
each change, call the function once yourself, or do the thing that fires its
trigger.
What the warning leaves open: who can call the function
Anyone your database lets run it, and the search path has no say in that.
Supabase's guide puts it in one line: "Pinning the search_path doesn't change
who can call the function."
Who can call a function is a separate permission, execute. Postgres grants it
to every role by default, and Supabase's linter documentation adds that Supabase
"additionally grants default privileges for new functions to anon, authenticated, service_role". anon is the role behind every request from
someone who has not signed in. So a security definer function in public can
be called by anyone holding your app's public key, at /rest/v1/rpc/ followed
by the function's name, and it answers with the owner's rights. Supabase's page
for this case says such a call returns rows the caller could never read with a
direct query.
The clerk with the master key takes requests from anyone who walks up to the desk, and pinning the list of cabinets changes only which folder they bring back.
Supabase's linter has a warning for this as well, added in April 2026: Public Can Execute SECURITY DEFINER Function (lint 0028), with a twin for signed-in users (lint 0029). Where your advisor shows it, the line reads like this:
Function `public.monthly_totals()` can be executed by the `anon` role as a `SECURITY DEFINER` function via `/rest/v1/rpc/monthly_totals`.
The visitors_can_call column in the query above answers the same question for
every function at once. For each security definer function where it says
true, choose one of the three answers the
linter's page
gives:
- Take
executeaway from visitors. Revoke it frompublicas well, because that is where Postgres's default grant lives:revoke execute on function public.monthly_totals() from public, anon;
If signed-in users never call it either, addauthenticatedto that line. - Make it run as the caller, when it needs no rights beyond theirs. Row
Level Security then applies to it as it does to any other query:
alter function public.monthly_totals() security invoker; - Move it out of
publicinto a schema missing from the Exposed schemas list in your API settings, such asprivate. The role check in the infinite-recursion post lives there, withexecutegiven back toauthenticatedbecause its rules run for signed-in users.
A function you mean every visitor to call, such as one behind a contact form, can stay as it is. The linter's page says to check its inputs, keep what it does small, and then dismiss the warning. Calling a Supabase function from your app covers the grants for ordinary functions.
A function is one way past your Row Level Security rules. A table those rules leave open is the other, and that one you can check from outside: our free scan reads your live app with the same public key a visitor gets, reports which tables hand back rows, and needs no account.
Keeping a copy before you rewrite your functions
Take one before you replace functions on a live project, because
create or replace overwrites the old definition and Postgres keeps no history
of it.
Reeve Care keeps a copy of your Supabase database:
- an encrypted copy on a schedule, on Reeve's own storage in the EU, outside your Supabase account
- every function in the copy as it was written then, body and settings included, beside your tables and rows
- each copy verified before it counts, by counting the rows in every table
- your uploaded files as well, once you connect a Storage credential
- a one-click restore, with a safety copy of the current state taken first
- everything Monitor does
Reeve Monitor keeps checking your app from outside:
- whether your app is up, every 60 seconds
- our full security check against the live app, every hour, so a migration that leaves a table answering strangers shows up without you going to look
- a monthly report, in plain language, of what it saw
What to do now
What to do
- Run the query above and start with the functions where
runs_as_owneristrue. - On those, set
search_path = ''and write the schema in front of every table they name. - On the rest, the one
alter functionline is enough when the body names nothing of yours. - Copy each definition with
pg_get_functiondefbefore you replace it. - Call each function once after the change, or fire its trigger, and look for
relation does not exist. - For every security definer function visitors can call, revoke
executefrompublicandanon, switch it tosecurity invoker, or move it out ofpublic.
Start with the sign-up trigger and any helper your Row Level Security rules call, because those are the two that run as the owner in Supabase's own examples. Before you replace a function your app depends on, keep a copy of the database from before the change.
FAQ
What does "Function Search Path Mutable" mean in Supabase?
It means a function in your database has no search_path setting of its own, so any table or function named inside it without a schema is looked up in the search path of whoever calls it. Supabase's linter reports it as a warning on every such function outside the schemas Supabase manages, whatever the function does.
Is the "Function Search Path Mutable" warning dangerous?
On an ordinary function, which runs with the caller's own rights, it is a loose end. On a security definer function it is the one to fix first. That function runs as its owner, which on Supabase is postgres and bypasses Row Level Security, and Postgres's documentation says such a function needs a search path that leaves out every schema untrusted users can write to.
How do I fix "Function Search Path Mutable"?
Set search_path to an empty string on the function and write the schema in front of every table, view and function of yours inside it, as public.profiles. When the body names nothing of yours, alter function public.name() set search_path = '' is enough. Otherwise replace the function with create or replace, every name written in full.
Why did my function stop working after I set search_path to empty?
Because a table named without its schema is no longer found, so the function fails with relation does not exist the next time it runs. alter function changes the setting without reading the body, which is why the error turns up at the next call and the line itself runs cleanly. Write public. in front of the name and the function works again.
Does setting the search path stop visitors calling the function?
No. The search path decides what a function finds, and the execute permission decides who can run it. Postgres grants execute to everyone by default and Supabase grants it to anon as well, so a security definer function in public can be called through /rest/v1/rpc/ until you revoke execute from public and anon.