Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1qCBJ4-000710-73 for pgsql-hackers@arkaria.postgresql.org; Thu, 22 Jun 2023 03:48:26 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.92) (envelope-from ) id 1qCBJ3-0003fL-3p for pgsql-hackers@arkaria.postgresql.org; Thu, 22 Jun 2023 03:48:25 +0000 Received: from makus.postgresql.org ([2001:4800:3e1:1::229]) by malur.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1qCBJ2-0003fC-R6 for pgsql-hackers@lists.postgresql.org; Thu, 22 Jun 2023 03:48:24 +0000 Received: from mail-pl1-x62e.google.com ([2607:f8b0:4864:20::62e]) by makus.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256 (Exim 4.94.2) (envelope-from ) id 1qCBJ0-003Y5q-9i for pgsql-hackers@lists.postgresql.org; Thu, 22 Jun 2023 03:48:23 +0000 Received: by mail-pl1-x62e.google.com with SMTP id d9443c01a7336-1b52fd56b7aso30230015ad.2 for ; Wed, 21 Jun 2023 20:48:22 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20221208; t=1687405701; x=1689997701; h=in-reply-to:content-disposition:mime-version:references:message-id :subject:cc:to:from:date:from:to:cc:subject:date:message-id:reply-to; bh=ZuHmurF1O2katfWL5KZ6d4+pxK4HmVXIJUV0KrfMVBA=; b=NRHYNtnDiA3F9wby8J2nQ/EtYd37uiIHmgD7DqYHmEKFX0ANpSoFGIuBtbAPD2agvg PJjNcurm5UhXazWflmqrwUftF2XKdMTbUdmGa5sgwUtpTkv4RIyvSYSSTcw4ryi3II87 pFv+0X4PJdWm150bCeqhJMdgApGPTYI9crOaZCRYHKcRUVTs3em7NvZrFqXImoDVIZ3E L/WmiaVA8ZM1LgzFEca9JR3ycCkB2yTsvYyBlgFOC7JdGb5Q1E7N6yJVZKcVv7k+dswu iI0L0LToRjUrC21dnUjJ5QlyRX6uJ1VNYCwiNkRz5oTj/6Y1OrGM3+KIdwFHwvFO+lSP edEQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1687405701; x=1689997701; h=in-reply-to:content-disposition:mime-version:references:message-id :subject:cc:to:from:date:x-gm-message-state:from:to:cc:subject:date :message-id:reply-to; bh=ZuHmurF1O2katfWL5KZ6d4+pxK4HmVXIJUV0KrfMVBA=; b=TG3pZNvwQ04kklKX06ENFe/1BylVyd/OFwGyTDw8o716EOiq2kYzfGs6ENoz2j3ZSG SfnGWEv6Ynnmp3xRJi+cclzXKM9dDL5kFaUYZzugtSefeZRYkh0/VKOUCIa4eFuKdLKS 5sj8PI8738ahL2ROTSSVYS9ar65ucRvRAaH1n2t6jPKt4ey7xpD/URzrgAnTlayOtkoz Cxwr6ilCKasbkQ8lAvYkpk4viKf5G32OOZDzz9cx3tQIoabMelbADI3H01gLsXklSAZn YhSlAIRsO30LLBKeYuIKZ+y3cHR6ONwVDWJJGzZHfaFM5CzWK0O9L2r98LESNvMls0Kx DjqQ== X-Gm-Message-State: AC+VfDyFw+5MZp8YEWs4yPiZfN+WhfogQbytqhQnzQDuhjO5jhwt2KMl dB7xwWfadJLuonIDm562VCA= X-Google-Smtp-Source: ACHHUZ70kCsC8RudZOrEW9z57fn7VnLPeM91OujgRAnKGil+ID6lnv38Ciau5JAK/dGTPnoB+BCRtg== X-Received: by 2002:a17:903:1c7:b0:1b6:9bf3:616b with SMTP id e7-20020a17090301c700b001b69bf3616bmr3124788plh.23.1687405700914; Wed, 21 Jun 2023 20:48:20 -0700 (PDT) Received: from nathanxps13 ([50.47.162.83]) by smtp.gmail.com with ESMTPSA id v17-20020a1709028d9100b001b06361a38dsm4194418plo.116.2023.06.21.20.48.20 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 21 Jun 2023 20:48:20 -0700 (PDT) Date: Wed, 21 Jun 2023 20:48:18 -0700 From: Nathan Bossart To: Joseph Koshakow Cc: PostgreSQL Hackers Subject: Re: Preventing non-superusers from altering session authorization Message-ID: <20230622034818.GA1077640@nathanxps13> References: MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk 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