| From: | Nathan Bossart <nathan(at)postgresql(dot)org> |
|---|---|
| To: | pgsql-committers(at)lists(dot)postgresql(dot)org |
| Subject: | pgsql: Fix authorization check for role membership changes. |
| Date: | 2026-08-13 21:36:02 |
| Message-ID: | E1wud5l-00000000Sdz-1Zw5@gemulon.postgresql.org |
| Views: | Whole Thread | Raw Message | Download mbox | Resend email |
| Thread: | |
| Lists: | pgsql-committers |
Fix authorization check for role membership changes.
Presently, check_role_membership_authorization() decides whether
the current user may grant or revoke membership in a role by
calling is_admin_of_role(), which recurses through all grants,
while it chooses the grantor to record for the resulting entry by
calling select_best_admin(), which recurses only through inherited
grants. When the two disagree, the permission check passes and the
grantor lookup then comes up empty, so the user sees an internal
"no possible grantors" error. ALTER GROUP ... ADD USER reaches the
same error through the separate check in AlterRole().
To fix, teach both checks to search the same way
select_best_admin() does via a new has_admin_privs_of_role(). The
new check passes exactly when the grantor lookup was going to
succeed, so nothing that works today starts failing; the internal
error simply becomes a proper permission error. Note that this
leaves the other callers of is_admin_of_role() alone, so a role
reachable only through a non-inherited grant can still be dropped,
renamed, or altered. Whether that ought to change as well is left
as a future exercise.
Oversight in commit ce6b672e44.
Reported-by: ChangAo Chen <cca5507(at)qq(dot)com>
Author: ChangAo Chen <cca5507(at)qq(dot)com>
Reviewed-by: Chao Li <li(dot)evan(dot)chao(at)gmail(dot)com>
Reviewed-by: Pretham <prezza672(at)gmail(dot)com>
Reviewed-by: Robert Haas <robertmhaas(at)gmail(dot)com>
Reviewed-by: Jacob Champion <jacob(dot)champion(at)enterprisedb(dot)com>
Discussion: https://postgr.es/m/tencent_ADCE2B34B230A9B631854806104FEF40C105%40qq.com
Discussion: https://postgr.es/m/CAJUn_kN%2BMhbb8fYP5xxQCq1KEziOinM6HgYx4ts_pPDnQ2y1nQ%40mail.gmail.com
Backpatch-through: 16
Branch
------
REL_18_STABLE
Details
-------
https://git.postgresql.org/pg/commitdiff/0468246f5dce721af1f0dd0c465f81c028128a98
Modified Files
--------------
src/backend/commands/user.c | 4 ++--
src/backend/utils/adt/acl.c | 27 +++++++++++++++++++++++++++
src/include/utils/acl.h | 1 +
src/test/regress/expected/privileges.out | 9 +++++++++
src/test/regress/sql/privileges.sql | 5 +++++
5 files changed, 44 insertions(+), 2 deletions(-)
| From | Date | Subject | |
|---|---|---|---|
| Next Message | Tomas Vondra | 2026-08-13 22:22:57 | Re: pgsql: Change wal_compression=on to the first of zstd, lz4, pglz |
| Previous Message | Nathan Bossart | 2026-08-13 20:31:09 | pgsql: Reject CLUSTER (ANALYZE). |