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 1oDtoM-0001mi-0h for pgsql-hackers@arkaria.postgresql.org; Tue, 19 Jul 2022 20:27:18 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.92) (envelope-from ) id 1oDtoK-0006ML-Oq for pgsql-hackers@arkaria.postgresql.org; Tue, 19 Jul 2022 20:27:16 +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 1oDtoK-0006GV-BH for pgsql-hackers@lists.postgresql.org; Tue, 19 Jul 2022 20:27:16 +0000 Received: from sss.pgh.pa.us ([66.207.139.130]) by makus.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1oDtoH-0006bV-UI for pgsql-hackers@postgresql.org; Tue, 19 Jul 2022 20:27:15 +0000 Received: from sss1.sss.pgh.pa.us (localhost [127.0.0.1]) by sss.pgh.pa.us (8.15.2/8.15.2) with ESMTP id 26JKR8Ea1356978; Tue, 19 Jul 2022 16:27:08 -0400 From: Tom Lane To: Nathan Bossart cc: Michael Paquier , pgsql-hackers@postgresql.org Subject: Re: pg_parameter_aclcheck() and trusted extensions In-reply-to: <20220718215649.GA3699123@nathanxps13> References: <20220706224727.GA2158260@nathanxps13> <2995921.1657212060@sss.pgh.pa.us> <3126292.1657828950@sss.pgh.pa.us> <20220714215225.GA3173833@nathanxps13> <3159281.1657836225@sss.pgh.pa.us> <20220714225735.GB3173833@nathanxps13> <20220718215649.GA3699123@nathanxps13> Comments: In-reply-to Nathan Bossart message dated "Mon, 18 Jul 2022 14:56:49 -0700" MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-ID: <1356976.1658262428.1@sss.pgh.pa.us> Date: Tue, 19 Jul 2022 16:27:08 -0400 Message-ID: <1356977.1658262428@sss.pgh.pa.us> List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk Nathan Bossart writes: >> I think this is because GUCArrayReset() is the only caller of >> validate_option_array_item() that sets skipIfNoPermissions to true. The >> others fall through to set_config_option(), which does a >> pg_parameter_aclcheck(). So, you are right. > Here's a small patch that seems to fix this case. Yeah, this is more or less what I was thinking of. > However, I wonder if a > better way to fix this is to provide a way to stop set_config_option() from > throwing errors (e.g., setting elevel to -1). That way, we could remove > the manual permissions checks in favor of always using the real ones, which > might help prevent similar bugs in the future. I thought about that for a bit. You could almost do it today if you passed elevel == DEBUG5; the ensuing log chatter for failures would be down in the noise compared to everything else you would see with min_messages cranked down that far. However, (1) As things stand, set_config_option()'s result does not distinguish no-permissions failures from other problems, so we'd need some rejiggering of its API anyway. (2) As you mused upthread, it's possible that ACL_SET isn't what we should be checking here, but some more-specific privilege. So I'd just as soon keep this privilege check separate from set_config_option's. I'll push ahead with fixing it like this. regards, tom lane