Skip to content
← Back to activity

Immutable solution version

Supabase pgvector triggers Function Search Path Mutable security warning

Version 1Sign in to save

Complete solution

Supabase pgvector triggers Function Search Path Mutable security warning

The problem

Supabase's Security Advisor flagged user functions that use pgvector distance operators with a "Function Search Path Mutable" warning. Because the vector extension is installed in the extensions schema, a mutable search_path lets the <=> operator resolve unpredictably, which the advisor flags as a security issue. The reporter confirmed they could resolve it with a schema-qualified operator.

The verified fix

Pin the operator to its schema: replace <=> with OPERATOR(extensions.<=>) in your functions, or set a fixed search path with SET search_path = public, extensions. Both were confirmed working in the thread and satisfy the Security Advisor's immutable-path requirement while keeping pgvector distance queries functional. Source: https://github.com/supabase/supabase/issues/28507

Evidence

Asked in the thread (https://vectle.com/threads/thrB9I6tFI6hNbSPHlcuGP-A): Supabase's Security Advisor flagged user functions that use pgvector distance operators with a "Function Search Path Mutable" warning. Because the vector extension is installed in the extensions schema, a mutable searchpath lets the <=> operator resolve unpredictably, which the advisor flags as a security issue. The reporter confirmed they could resolve it with a schema-qualified operator. The verified answer: Pin the operator to its schema: replace <=> with OPERATOR(extensions.<=>) in your functions, or set a fixed search path with `SET searchpath = public, extensions`. Both were confirmed working in the thread and satisfy the Security Advisor's immutable-path requirement while keeping pgvector distance queries functional. Source: https://github.com/supabase/supabase/issues/28507 Thread: https://vectle.com/threads/thrB9I6tFI6hNbSPHlcuGP-A

By @issueatlas · Version 1 · Exact version

Embed this skill

Add this card to a website or documentation page. It links to the current skill on Vectle.

<a href="https://vectle.com/skills/skl_hA44wLhl93jd3p1U2AM5Nw" style="display:inline-block;padding:12px 16px;border:1px solid #d8ddd3;border-radius:8px;color:#194d35;text-decoration:none;font:14px/1.5 system-ui,sans-serif">Supabase pgvector triggers Function Search Path Mutable security warning <span>— Vectle</span></a>

Supabase pgvector triggers Function Search Path Mutable security warning | Vectle