Let mdb_admin manage resource groups#1804
Conversation
3cf18f1 to
c429871
Compare
|
I 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
2e1505d
Compare
|
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
2ea6898
Compare
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 :) |
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
086283f
Compare
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 |
c9f288f to
d721774
Compare
In Greenplum/Cloudberry only a superuser may CREATE/ALTER/DROP resource groups. In managed-service deployments the client never gets superuser, so a cloud admin can't tune their own CPU/memory limits. Instead of pinning a predefined role OID (which bumps CATALOG_VERSION_NO and needs a fresh initdb), gate the four entry points on membership of the mdb_admin role, resolved by name at runtime. mdb_admin is an ordinary role created by the control plane with CREATE ROLE. If it doesn't exist, the check falls back to superuser-only, so a stock cluster is unchanged. admin_group stays superuser-only for ALTER/DROP. Since mdb_admin and mdb_superuser gate privileges by name, also restrict their CREATE/ALTER/RENAME/DROP to superusers, so a CREATEROLE user can't hijack them to escalate. Adapted from open-gpdb/gpdb 3ac99962ad2. Tests from apache/cloudberry apache#1763.
d721774 to
7da8638
Compare
Let mdb_admin manage resource groups
In Greenplum/Cloudberry only a superuser may CREATE/ALTER/DROP resource
groups. In managed-service deployments the client never gets superuser,
so a cloud admin can't tune their own CPU/memory limits.
Instead of pinning a predefined role OID (which bumps CATALOG_VERSION_NO
and needs a fresh initdb), gate the four entry points on membership of
the mdb_admin role, resolved by name at runtime. mdb_admin is an ordinary
role created by the control plane with CREATE ROLE. If it doesn't exist,
the check falls back to superuser-only, so a stock cluster is unchanged.
admin_group stays superuser-only for ALTER/DROP.
Since mdb_admin and mdb_superuser gate privileges by name, also restrict
their CREATE/ALTER/RENAME/DROP to superusers, so a CREATEROLE
user can't hijack them to escalate.
Adapted from open-gpdb/gpdb 3ac99962ad2. Tests from apache/cloudberry #1763.
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