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 1o9Ugz-0000JD-VT for pgsql-hackers@arkaria.postgresql.org; Thu, 07 Jul 2022 16:49:29 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.92) (envelope-from ) id 1o9Ugy-0005zI-Iz for pgsql-hackers@arkaria.postgresql.org; Thu, 07 Jul 2022 16:49:28 +0000 Received: from magus.postgresql.org ([2a02:c0:301:0:ffff::29]) by malur.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1o9Ugy-0005z8-8S for pgsql-hackers@lists.postgresql.org; Thu, 07 Jul 2022 16:49:28 +0000 Received: from mail-pf1-x433.google.com ([2607:f8b0:4864:20::433]) by magus.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.92) (envelope-from ) id 1o9Ugv-0000Uu-HA for pgsql-hackers@postgresql.org; Thu, 07 Jul 2022 16:49:27 +0000 Received: by mail-pf1-x433.google.com with SMTP id y9so6316287pff.12 for ; Thu, 07 Jul 2022 09:49:25 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=date:from:to:cc:subject:message-id:references:mime-version :content-disposition:in-reply-to; bh=1V42XhilBKqkOH5iGFrgj0e/ZRfyvxMbKP7Yu0qO68A=; b=I0E1Fr6lVQcKpyriPfkIEpRbzsYCYqQQ1effxfIY1ebXIu4125dMA8mvcEU99KiJel 1BpMDW+htG075tCsvlbxZ39oGNB50eS0FjGlYph/KsuymNSVvNA9hv/67D65w8yWUCsR cworPXisFEPgczfj20aodqzx8REqp1YtCOEmueoaUaMBnH3ebzVOmG6WVJBfmPjPQ83p tPWFi7Koj8JJ5QGQXYV4vKTCldn8wrQsnQXel8Gky8W4jjhJOfVUB1UfrVfjgnnEZRmD 3Z8gVc6/CExmyGdzY+7xuhqOqPRfPK/SCXcrbQ52MK11T1Jm00jzPuxX6Q73eik7XYtc U/9Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:in-reply-to; bh=1V42XhilBKqkOH5iGFrgj0e/ZRfyvxMbKP7Yu0qO68A=; b=pp6TcpsR8oeXuuHvdPjCvdbMebendAlaA5x3FrKyw+ayS1c8t/hE2m1PcTwJtMWyEU 7JT7DGT/g3NkpvUHOxSoOhU7bRqW2grLWIicRLYkrHUStjs1fYkNe96XSmo/mjLGiK9S 5lmrqTcQBE3YxUvIb/mGaQPQt4F1PvG1p7aagF9eFwcuy5aCI4uZwVcv9Yt4m/ni4016 IzxUvT3kvl3tGD+kcrKYCeY8pphHVjVpb/r6w3SPP4uK/QOBZhiAoICCz3sEV/nfDStI h90I2MUDVMpm9DXoOASagqZLWUEl0xw3z0Bs+22flXtjSAwMUi91VJaTc/aSrvoSDCN0 g82w== X-Gm-Message-State: AJIora/BEJG+fvAapQpqwnvFar8MaTzSTz0qMTGtcAapjEjE/e6qVH6e Jp/yuASeMYVNCz9eCGJG+pE= X-Google-Smtp-Source: AGRyM1sSMVTtMUWoNhBp8TI++nvh/GguVy+PeCAfOOJQRGHxYL653UpujTpi62QgXcfhpZqyFyMSyw== X-Received: by 2002:a17:902:8644:b0:16b:ea77:a6cb with SMTP id y4-20020a170902864400b0016bea77a6cbmr19867627plt.59.1657212563169; Thu, 07 Jul 2022 09:49:23 -0700 (PDT) Received: from nathanxps13 ([50.54.155.70]) by smtp.gmail.com with ESMTPSA id n6-20020a63ee46000000b00411e700f615sm12025968pgk.36.2022.07.07.09.49.22 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 07 Jul 2022 09:49:22 -0700 (PDT) Date: Thu, 7 Jul 2022 09:49:21 -0700 From: Nathan Bossart To: Michael Paquier Cc: pgsql-hackers@postgresql.org Subject: Re: pg_parameter_aclcheck() and trusted extensions Message-ID: <20220707164921.GA2251016@nathanxps13> References: <20220706224727.GA2158260@nathanxps13> 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 Thu, Jul 07, 2022 at 10:04:18AM +0900, Michael Paquier wrote: > On Wed, Jul 06, 2022 at 03:47:27PM -0700, Nathan Bossart wrote: >> I think the call to superuser_arg() in pg_parameter_aclmask() is causing >> set_config_option() to bypass the normal privilege checks, as >> execute_extension_script() will have set the user ID to the bootstrap >> superuser for trusted extensions like plperl. I don't have a patch or a >> proposal at the moment, but I thought it was worth starting the discussion. > > Looks like a bug to me, so I have added an open item assigned to Tom. Thanks. I've been thinking about this one a bit. For simple cases like plperl, it would be easy enough to temporarily revert the superuser switch when calling _PG_init() or one of the DefineCustomXXXVariable functions. Unfortunately, I think there are more complicated scenarios. For example, what role should pg_parameter_aclmask() use when a trusted extension script loads a library after SET ROLE? The original user might not ordinarily be able to assume this role, so the trusted extension script could still be a way to set parameters you don't have privileges for. Should we just always use the role that's calling CREATE EXTENSION? -- Nathan Bossart Amazon Web Services: https://aws.amazon.com