Re: Preventing non-superusers from altering session authorization

Nathan Bossart <nathandbossart@gmail.com>

From: Nathan Bossart <nathandbossart@gmail.com>
To: Joseph Koshakow <koshy44@gmail.com>
Cc: PostgreSQL Hackers <pgsql-hackers@lists.postgresql.org>
Date: 2023-06-22T03:48:18Z
Lists: pgsql-hackers
On Wed, Jun 21, 2023 at 04:28:43PM -0400, Joseph Koshakow wrote:
> +	roleTup = SearchSysCache1(AUTHOID, ObjectIdGetDatum(AuthenticatedUserId));
> +	if (!HeapTupleIsValid(roleTup))
> +		ereport(FATAL,
> +				(errcode(ERRCODE_INVALID_AUTHORIZATION_SPECIFICATION),
> +						errmsg("role with OID %u does not exist", AuthenticatedUserId)));
> +	rform = (Form_pg_authid) GETSTRUCT(roleTup);

I think "superuser_arg(AuthenticatedUserId)" would work here.

-- 
Nathan Bossart
Amazon Web Services: https://aws.amazon.com



Commits

  1. Fix privilege check for SET SESSION AUTHORIZATION.

  2. Move privilege check for SET SESSION AUTHORIZATION.

  3. Rename session_auth_is_superuser to current_role_is_superuser.