fix(supabase): revoke PUBLIC EXECUTE on private helpers, audited visibility RPC, input caps, authz-first RPCs, +32 pgTAP checks

This commit is contained in:
bchanot committed 2026-10-08 23:59:39 +02:00
1 parent 6966c54a2e
commit d3fa65af29
15 files changed
+682 -221

No files matched your search

+16 -1
View File
@@ -1,6 +1,6 @@
-- Schema contract: objects exist, RLS is on, API roles start from zero.
begin;
select plan(24);
select plan(26);
-- Schemas
select has_schema('private', 'schema private exists');
@@ -51,5 +51,20 @@ select ok(not has_column_privilege('authenticated', 'public.profiles', 'active',
select ok(not has_schema_privilege('anon', 'private', 'usage'), 'anon has no usage on schema private');
select ok(not has_function_privilege('anon', 'public.grant_platform_role(uuid, public.platform_role)', 'execute'), 'anon cannot execute grant_platform_role');
-- Private helpers: EXECUTE revoked from everyone except the predicates the policies evaluate.
-- (has_function_privilege is true for any role while proacl is null, i.e. the built-in PUBLIC default.)
select is(
(select count(*) from pg_proc p join pg_namespace n on n.oid = p.pronamespace
where n.nspname in ('private', 'audit') and has_function_privilege('anon', p.oid, 'execute')),
0::bigint, 'anon can execute nothing in private/audit'
);
select is(
(select string_agg(p.proname::text, ',' order by p.proname::text collate "C")
from pg_proc p join pg_namespace n on n.oid = p.pronamespace
where n.nspname in ('private', 'audit') and has_function_privilege('authenticated', p.oid, 'execute')),
'can_edit_sheet,can_use_sheet,has_platform_role,is_platform_admin,is_platform_moderator,is_platform_owner,is_support',
'authenticated executes only the policy predicates in private'
);
select * from finish();
rollback;