From a0363ab7aafda7d16ae59e72d86866c02ad3d657 Mon Sep 17 00:00:00 2001 From: Nathan Bossart Date: Thu, 13 Jul 2023 21:13:45 -0700 Subject: Fix privilege check for SET SESSION AUTHORIZATION. Presently, the privilege check for SET SESSION AUTHORIZATION checks whether the original authenticated role was a superuser at connection start time. Even if the role loses the superuser attribute, its existing sessions are permitted to change session authorization to any role. This commit modifies this privilege check to verify the original authenticated role currently has superuser. In the event that the authenticated role loses superuser within a session authorization change, the authorization change will remain in effect, which means the user can still take advantage of the target role's privileges. However, [RE]SET SESSION AUTHORIZATION will only permit switching to the original authenticated role. Author: Joseph Koshakow Discussion: https://postgr.es/m/CAAvxfHc-HHzONQ2oXdvhFF9ayRnidPwK%2BfVBhRzaBWYYLVQL-g%40mail.gmail.com --- src/backend/commands/variable.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src/backend/commands/variable.c') diff --git a/src/backend/commands/variable.c b/src/backend/commands/variable.c index 071bef63754..a88cf5f118f 100644 --- a/src/backend/commands/variable.c +++ b/src/backend/commands/variable.c @@ -854,7 +854,7 @@ check_session_authorization(char **newval, void **extra, GucSource source) * authenticated user's superuserness is what matters. */ if (roleid != GetAuthenticatedUserId() && - !GetAuthenticatedUserIsSuperuser()) + !superuser_arg(GetAuthenticatedUserId())) { if (source == PGC_S_TEST) { -- cgit v1.2.3