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 1o9Do5-0000V1-ES for pgsql-hackers@arkaria.postgresql.org; Wed, 06 Jul 2022 22:47:41 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.92) (envelope-from ) id 1o9Do3-0000cN-1o for pgsql-hackers@arkaria.postgresql.org; Wed, 06 Jul 2022 22:47:39 +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 1o9Do2-0000bf-M2 for pgsql-hackers@lists.postgresql.org; Wed, 06 Jul 2022 22:47:38 +0000 Received: from mail-pg1-x529.google.com ([2607:f8b0:4864:20::529]) by makus.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.92) (envelope-from ) id 1o9Dnz-0006FV-DV for pgsql-hackers@postgresql.org; Wed, 06 Jul 2022 22:47:37 +0000 Received: by mail-pg1-x529.google.com with SMTP id e132so15256052pgc.5 for ; Wed, 06 Jul 2022 15:47:35 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=date:from:to:subject:message-id:mime-version:content-disposition; bh=Lr+Igb2rUQTMst6uPuEVJ8vTu3iVQuVUvNQcU94g66U=; b=MwAoH88STszBtETLaaKWW/CviWWcSLI5NiMPADivDX0Jm5keZIVqFhe/Ik/swJU9P6 FuMm+6nS/VXQYzaSHLqILF1tFF6r4DOSzoB4S1Sw43J8HvJTXX1h3GKWQSQpw0M95c+D l6PCCSKT4wlW4LWk5BXP2jw6DB7/uUlOmZWbvZQsKLT7+nsjCQ7S57SNjhXcvivY1aEf 0iqgvpf1ut1X7Jt7njpA5SCnDg/m5BqpmWLayPmU5Ek9T9UWLk3sHKDnuDPjPuusEu+a lzKTdBF2AJbCMN0Yz7n16Kw7mqKCyH5KKr7pPBdJYM1wnJ8dv8OCoKa9fn26WqZ7zZVv U7tQ== 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:subject:message-id:mime-version :content-disposition; bh=Lr+Igb2rUQTMst6uPuEVJ8vTu3iVQuVUvNQcU94g66U=; b=sGOG3J3+9fCjUHU6Gha/yv4dLrtdoOYLeujBfyhVPlTzcm17myacAc82ENZBhtzPtp xkHZKZTrTPMOLY3t35si4v3gGO1EcZIieS5AoTr1KC6MmIezb2jgTHd+WfsUlp8IIoWJ 01V8sV/Z9tpaC9MCe3TFlOhOApb+bHRWvy2bRqWn0vFMqtU+bNbwiggnR0Gcr8/4MEpA 0G433zUoACIFkOMx4XZFKDBX2HBmUPar9oPrVt1HwcSiwIYvwmF9QHFogmVQPd/Z0fi6 zVGw/yjK8Rq5Cul8MKvQJ3MWHuLX+uYLbXY8Yc3xPY+Ff+YDU23BpPfV93EUlcERvtof WfbQ== X-Gm-Message-State: AJIora8fY2XUa0X1r1u6Ulj1NwiUbW72VvsLqdIWkQuODOKovCdiUL0V S6SVfgAK9dPtdftOMH8JauMeyB9wzPc= X-Google-Smtp-Source: AGRyM1uQzF+uNUDSgYqKC9XzkL7xoXjvhRWrdi0db1IpvzmEPbyXMb0irqcdHUBzcQysPIMtyuxJDg== X-Received: by 2002:a17:90b:4b02:b0:1ed:13eb:11c9 with SMTP id lx2-20020a17090b4b0200b001ed13eb11c9mr1245811pjb.76.1657147654172; Wed, 06 Jul 2022 15:47:34 -0700 (PDT) Received: from nathanxps13 ([50.54.155.70]) by smtp.gmail.com with ESMTPSA id c9-20020a170902c2c900b00163ffbc4f74sm26232744pla.49.2022.07.06.15.47.30 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 06 Jul 2022 15:47:33 -0700 (PDT) Date: Wed, 6 Jul 2022 15:47:27 -0700 From: Nathan Bossart To: pgsql-hackers@postgresql.org Subject: pg_parameter_aclcheck() and trusted extensions Message-ID: <20220706224727.GA2158260@nathanxps13> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk Hi hackers, I found that as of a0ffa88, it's possible to set a PGC_SUSET GUC defined by a trusted extension as a non-superuser. I've confirmed that this only affects v15 and later versions. postgres=# CREATE ROLE testuser; CREATE ROLE postgres=# GRANT CREATE ON DATABASE postgres TO testuser; GRANT postgres=# SET ROLE testuser; SET postgres=> SET plperl.on_plperl_init = 'test'; SET postgres=> CREATE EXTENSION plperl; CREATE EXTENSION postgres=> SELECT setting FROM pg_settings WHERE name = 'plperl.on_plperl_init'; setting --------- test (1 row) On previous versions, the CREATE EXTENSION command emits the following WARNING, and the setting does not take effect: WARNING: permission denied to set parameter "plperl.on_plperl_init" 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. -- Nathan Bossart Amazon Web Services: https://aws.amazon.com