Skip to content

Commit b6dc5a0

Browse files
committed
fix: security of get_orgs_v6/v7
1 parent 278e0d1 commit b6dc5a0

1 file changed

Lines changed: 18 additions & 3 deletions

File tree

supabase/migrations/20251224103713_2fa_enforcement.sql

Lines changed: 18 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -325,9 +325,14 @@ $$;
325325

326326
ALTER FUNCTION public.get_orgs_v7(uuid) OWNER TO "postgres";
327327

328-
GRANT ALL ON FUNCTION public.get_orgs_v7(uuid) TO "anon";
329-
GRANT ALL ON FUNCTION public.get_orgs_v7(uuid) TO "authenticated";
330-
GRANT ALL ON FUNCTION public.get_orgs_v7(uuid) TO "service_role";
328+
-- Revoke from public roles (security: prevents users from querying other users' orgs)
329+
REVOKE ALL ON FUNCTION public.get_orgs_v7(uuid) FROM PUBLIC;
330+
REVOKE ALL ON FUNCTION public.get_orgs_v7(uuid) FROM "anon";
331+
REVOKE ALL ON FUNCTION public.get_orgs_v7(uuid) FROM "authenticated";
332+
333+
-- Grant only to postgres and service_role (private function)
334+
GRANT EXECUTE ON FUNCTION public.get_orgs_v7(uuid) TO "postgres";
335+
GRANT EXECUTE ON FUNCTION public.get_orgs_v7(uuid) TO "service_role";
331336

332337
-- Create get_orgs_v7() - wrapper function
333338
CREATE OR REPLACE FUNCTION public.get_orgs_v7()
@@ -538,6 +543,16 @@ BEGIN
538543
END;
539544
$$;
540545

546+
ALTER FUNCTION public.get_orgs_v6(uuid) OWNER TO "postgres";
547+
548+
-- Revoke from public roles (security: prevents users from querying other users' orgs)
549+
REVOKE ALL ON FUNCTION public.get_orgs_v6(uuid) FROM PUBLIC;
550+
REVOKE ALL ON FUNCTION public.get_orgs_v6(uuid) FROM "anon";
551+
REVOKE ALL ON FUNCTION public.get_orgs_v6(uuid) FROM "authenticated";
552+
553+
-- Grant only to postgres and service_role (private function)
554+
GRANT EXECUTE ON FUNCTION public.get_orgs_v6(uuid) TO "postgres";
555+
GRANT EXECUTE ON FUNCTION public.get_orgs_v6(uuid) TO "service_role";
541556

542557
-- ============================================================================
543558
-- Section 5: reject_access_due_to_2fa function

0 commit comments

Comments
 (0)