AI & Agent Dev Bug Sandbox logo
AI & Agent Dev Bug Sandbox
Back to Radar

Unexpected Default EXECUTE Privileges On Functions In API Schema

Supabase automatically grants EXECUTE on newly created functions in exposed schemas to anon, authenticated, and service_role, even when ALTER DEFAULT PRIVILEGES revokes execution, leading to unauthorized function execution via PostgREST.

highConfidence 78%Supabase@supabase/supabase-jsPostgreSQL

Origin Analysis

Supabase's bootstrap migrations set default privileges for a role (likely supabase_admin or the role used to create objects) that grant EXECUTE to anon, authenticated, and service_role on all functions, overriding user-specified ALTER DEFAULT PRIVILEGES because the objects are created by that role, not the role executing the user's command. Additionally, PostgreSQL's built-in PUBLIC execute default is not properly revoked when the creating role differs.
1. Create schema api_test and grant USAGE to anon, authenticated, service_role. 2. Run ALTER DEFAULT PRIVILEGES IN SCHEMA api_test REVOKE EXECUTE ON FUNCTIONS FROM public, anon, authenticated, service_role. 3. Create function api_test.return_null(). 4. Call POST /rest/v1/rpc/return_null with anon key. Function executes successfully.

Fixing Code Block

Edge Case Audit

The event trigger may inadvertently revoke EXECUTE on functions used internally by Supabase if those functions are created after the trigger and reside in exposed schemas. The REVOKE inside the trigger may fail if executed by a non-superuser, causing the original CREATE FUNCTION to be rolled back. Rollback: drop the event trigger and re-grant EXECUTE as needed. Ensure this runs as a superuser (e.g., postgres).

Ecosystem Topology

Agent Frameworks

LangChain, LlamaIndex, and Pydantic

  1. highProperty graph relation keys collide when entity IDs or labels contain underscores
  2. highCodeActAgent drops assistant tool-call metadata during handoff, leaving an orphan tool response
  3. high[Bug]: HierarchicalNodeParser async methods return the documents unsplit
  4. highLLM.predict_and_call fails with ValidationError for non-function-calling models when react_chat_formatter is omitted
  5. highAnthropic streaming server-tool input_json_delta overwrites completed client tool_use arguments due to stale cur_tool_call state