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 1pFiD5-0005pb-NT for pgsql-hackers@arkaria.postgresql.org; Wed, 11 Jan 2023 21:00:35 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.92) (envelope-from ) id 1pFiD4-0001WU-B8 for pgsql-hackers@arkaria.postgresql.org; Wed, 11 Jan 2023 21:00:34 +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 1pFiD4-0001WK-24 for pgsql-hackers@lists.postgresql.org; Wed, 11 Jan 2023 21:00:34 +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 1pFiCx-0000Si-Hq for pgsql-hackers@postgresql.org; Wed, 11 Jan 2023 21:00:33 +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 30BL0QBr668180; Wed, 11 Jan 2023 16:00:26 -0500 From: Tom Lane To: Robert Haas cc: "pgsql-hackers@postgresql.org" Subject: Re: pgsql: Add new GUC createrole_self_grant. In-reply-to: References: <399118.1673401630@sss.pgh.pa.us> <404209.1673404807@sss.pgh.pa.us> <408089.1673407504@sss.pgh.pa.us> Comments: In-reply-to Robert Haas message dated "Wed, 11 Jan 2023 13:24:31 -0500" MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-ID: <668178.1673470826.1@sss.pgh.pa.us> Date: Wed, 11 Jan 2023 16:00:26 -0500 Message-ID: <668179.1673470826@sss.pgh.pa.us> List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk Robert Haas writes: > If you want to make safe a SECURITY DEFINER function written using sql > or plpgsql, you either have to schema-qualify every single reference > or, more realistically, attach a SET clause to the function to set the > search_path to a sane value during the time that the function is > executing. The problem here can be handled the same way, except that > it's needed in a vastly more limited set of circumstances: you have to > be calling a SECURITY DEFINER function that will execute CREATE ROLE > as a non-superuser (and that user then needs to be sensitive to the > value of this GUC in some security-relevant way). It might be good to > document this -- I just noticed that the CREATE FUNCTION page has a > section on "Writing SECURITY DEFINER Functions Safely" which talks > about dealing with the search_path issues, and it seems like it would > be worth adding a sentence or two there to talk about this. OK, I'd be satisfied with that. regards, tom lane