Uh oh!
There was an error while loading. Please reload this page.
Let mdb_admin manage resource groups - #1804
Conversation
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
3cf18f1 to
c429871CompareI rewrote the patch completely because a new bootstrap catalog entry bumps CATALOG_VERSION_NO and incompatible with minor gpupgrade - I adapted the commit from open-gpdb 3ac99962ad2 and added my tests. |
de4b7f8 to
2e1505dComparemy-ship-it
commented
Jun 5, 2026
This PR's permission check looks up the role by name, not by a fixed OID: This means: members of any role that happens to be named mdb_admin can manage resource groups. The code doesn't care who created that role or when. Where the hole is: This assumption overlooks CREATEROLE users. Suppose a DBA has granted some user CREATEROLE (quite common on self-hosted clusters, Three SQL statements, and a user who was only supposed to "manage accounts" has self-granted resource group administration rights. |
Agree, I have fixed it by checking that it is included in admin and system group. |
2e1505d to
2ea6898Comparereshke
commented
Jun 5, 2026
for our use in Cloud we just do not consider this as privilege escalation, because we grant this role to cloud users(non-superuser) by request (you just click in UI like that this role to this role) Anyway issue looks valid in general use |
Yep, exactly :) We only care about rolsuper or not, if mdb-admin patch does not allow to gain superuser priviledge - we consider it safe :) |
my-ship-it
commented
Jun 5, 2026
Thanks for the iterations on this. I agree with the constraint driving the current design — a How about Proposal: use a reserved-prefix role name Rename the role to e.g. pg_manage_resgroup and keep the same runtime get_role_oid() lookup. The
One caveat: DROP is not name-protected |
2ea6898 to
086283fCompare
We can't use a pg_ name because creating it requires changes in pg_authid.dat (a bootstrap role), which bumps CATALOG_VERSION_NO and breaks in-place minor upgrades. postgres=# CREATE ROLE pg_manage_resgroup; I added in the last commit a check in user.c that restricts CREATE/ALTER/RENAME/DROP/GRANT/REVOKE of the mdb_admin and mdb_superuser roles to superusers only, so an ordinary CREATEROLE user cannot hijack the by-name privilege gate (create, rename, reset the password of, or self-grant the role) and thereby escalate privileges. CREATE ROLE rg_attacker CREATEROLE; CREATE ROLE |
ac27b8c to
6876db7CompareAlena0704
commented
Jun 11, 2026
Reworked the patch following the pg_aux commit - moved the mdb_admin role into a contrib extension, pg_aux_catalog: it's created via pg_create_mdb_admin_role() (fixed OID 8067, superuser-only). Resource-group operations are gated on mdb_admin membership, identified by that fixed OID. Because the role is created at a single fixed OID and only by a superuser, it cannot be re-created or taken over by another user - a CREATEROLE user can neither establish mdb_admin nor recreate it at that OID: Tests were moved into the extension as well. |
6876db7 to
ae95005Comparemy-ship-it
commented
Jun 11, 2026
Thanks for the rework — moving to a fixed-OID role provisioned through contrib/pg_aux_catalog is the right call, Security model — LGTM. The original concern (a CREATEROLE user forging a role named mdb_admin and
|
Alena0704
commented
Jun 11, 2026
Thanks! Yes, that's the intent - the check is on membership in OID 8067, and only a superuser can create the role, so a plain CREATE ROLE mdb_admin is harmless. It's all in the current commit (ae95005). |
5f98f86 to
83e2a4fCompare83e2a4f to
6d12887Compare
leborchuk
left a comment
There was a problem hiding this comment.
LGTM, checked on internal Cloudberry clusters
fairyfar
commented
Jul 14, 2026
It seems unnecessary to add the new extension |
6d12887 to
acf5c11CompareAlena0704
commented
Jul 14, 2026
Agree. I moved it there and updated commit message |
Add gp_toolkit.pg_create_mdb_admin_role() (gp_toolkit 1.7) to provision the role with its fixed OID. Allow members of mdb_admin — not just superusers — to CREATE/ALTER/DROP resource groups and run pg_resgroup_move_query(), so a cloud admin can tune their own CPU/memory limits. Based on pg-sharding/cpg 7b8c912. Some tests are adapted from open-gpdb/gpdb 3ac99962ad2. Co-authored-by: reshke<reshke@double.cloud> Co-authored-by: Andrey Borodin <x4mmm@yandex-team.ru>
acf5c11 to
22805c1Compare
Let mdb_admin manage resource groups
Add gp_toolkit.pg_create_mdb_admin_role() (gp_toolkit 1.7) to provision the
role with its fixed OID.
Allow members of mdb_admin — not just superusers — to CREATE/ALTER/DROP
resource groups and run pg_resgroup_move_query(), so a cloud admin can tune
their own CPU/memory limits.
Based on pg-sharding/cpg 7b8c912. Some tests are adapted from
open-gpdb/gpdb 3ac99962ad2.
Co-authored-by: reshkereshke@double.cloud
Co-authored-by: Andrey Borodin x4mmm@yandex-team.ru
Fixes #ISSUE_Number
What does this PR do?
Type of Change
Breaking Changes
Test Plan
make installcheckmake -C src/test installcheck-cbdb-parallelImpact
Performance:
User-facing changes:
Dependencies:
Checklist
Additional Context
CI Skip Instructions