Skip to content

Commit 9427a4e

Browse files
committed
fix: prevent non-superuser roles from dropping supabase_privileged_role
Add supabase_privileged_role to supautils.reserved_roles so non-superusers with CREATEROLE cannot drop it on PG 15, where PG's native ADMIN OPTION check (introduced in PG 16) does not apply. PG 16+ requires ADMIN OPTION to drop a non-superuser role: https://github.com/postgres/postgres/blame/REL_16_STABLE/src/backend/commands/user.c#L1175 This check is absent in PG 15: https://github.com/postgres/postgres/blob/REL_15_STABLE/src/backend/commands/user.c#L986 Fixes: https://linear.app/supabase/issue/PSQL-1205
1 parent 438c36b commit 9427a4e

1 file changed

Lines changed: 24 additions & 0 deletions

File tree

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
BEGIN;
2+
3+
SELECT plan(2);
4+
5+
CREATE ROLE test_reserved_attacker CREATEROLE;
6+
GRANT test_reserved_attacker TO postgres;
7+
SET ROLE test_reserved_attacker;
8+
9+
SELECT throws_ok(
10+
$$ DROP ROLE supabase_privileged_role $$,
11+
'42501',
12+
'"supabase_privileged_role" is a reserved role, only superusers can modify it',
13+
'non-superuser with CREATEROLE cannot drop supabase_privileged_role'
14+
);
15+
16+
RESET ROLE;
17+
18+
SELECT ok(
19+
EXISTS(SELECT 1 FROM pg_roles WHERE rolname = 'supabase_privileged_role'),
20+
'supabase_privileged_role still exists after failed drop attempt'
21+
);
22+
23+
SELECT * FROM finish();
24+
ROLLBACK;

0 commit comments

Comments
 (0)