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 1lWjrw-0005EZ-Gw for pgsql-hackers@arkaria.postgresql.org; Wed, 14 Apr 2021 18:04:04 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.92) (envelope-from ) id 1lWjrv-0006j7-52 for pgsql-hackers@arkaria.postgresql.org; Wed, 14 Apr 2021 18:04:03 +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 1lWjru-0006iz-V2 for pgsql-hackers@lists.postgresql.org; Wed, 14 Apr 2021 18:04:02 +0000 Received: from sss.pgh.pa.us ([66.207.139.130]) by magus.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1lWjrs-0000e0-Iy for pgsql-hackers@lists.postgresql.org; Wed, 14 Apr 2021 18:04:02 +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 13EI3uEB3567050; Wed, 14 Apr 2021 14:03:56 -0400 From: Tom Lane To: Robert Haas cc: Noah Misch , PostgreSQL Hackers , Peter Eisentraut Subject: Re: Converting contrib SQL functions to new style In-reply-to: References: <3395418.1618352794@sss.pgh.pa.us> <20210414020827.GA1232417@rfd.leadboat.com> <3441172.1618369873@sss.pgh.pa.us> <20210414125811.GB1263822@rfd.leadboat.com> <3489827.1618411777@sss.pgh.pa.us> <3566011.1618422104@sss.pgh.pa.us> Comments: In-reply-to Robert Haas message dated "Wed, 14 Apr 2021 13:56:34 -0400" MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-ID: <3567048.1618423436.1@sss.pgh.pa.us> Date: Wed, 14 Apr 2021 14:03:56 -0400 Message-ID: <3567049.1618423436@sss.pgh.pa.us> List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk Robert Haas writes: > On Wed, Apr 14, 2021 at 1:41 PM Tom Lane wrote: >> Could we hack things so that extension scripts are only allowed to >> reference objects created (a) by the system, (b) earlier in the >> same script, or (c) owned by one of the declared prerequisite >> extensions? Seems like that might provide a pretty bulletproof >> defense against trojan-horse objects, though I'm not sure how much >> of a pain it'd be to implement. > That doesn't seem like a crazy idea, but the previous idea of having > some magic syntax that means "the schema where extension FOO is" seems > like it might be easier to implement and more generally useful. I think that's definitely useful, but it's not a fix for the reference-capture problem unless you care to assume that the other extension's schema is free of trojan-horse objects. So I'm thinking that we really ought to pursue both ideas. This may mean that squeezing these contrib changes into v14 is a lost cause. We certainly shouldn't try to do what I suggest above for v14; but without it, these changes are just moving the security issue to a different place rather than eradicating it completely. regards, tom lane