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 1ntfhm-0000rW-Kv for pgsql-hackers@arkaria.postgresql.org; Wed, 25 May 2022 01:20:54 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.92) (envelope-from ) id 1ntfhl-0004Hm-Gf for pgsql-hackers@arkaria.postgresql.org; Wed, 25 May 2022 01:20:53 +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 1ntfgl-0007jn-4w for pgsql-hackers@lists.postgresql.org; Wed, 25 May 2022 01:19:51 +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 1ntfge-00069F-AB for pgsql-hackers@postgresql.org; Wed, 25 May 2022 01:19:47 +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 24P1JeuX1772517; Tue, 24 May 2022 21:19:41 -0400 From: Tom Lane To: Bruce Momjian cc: Robert Haas , Nathan Bossart , "pgsql-hackers@postgresql.org" Subject: Re: allow building trusted languages without the untrusted versions In-reply-to: References: <571753.1653092411@sss.pgh.pa.us> <20220523165403.GC938919@nathanxps13> <1290329.1653326228@sss.pgh.pa.us> <1333860.1653338790@sss.pgh.pa.us> <1354561.1653345768@sss.pgh.pa.us> <20220524172851.GA1191690@nathanxps13> Comments: In-reply-to Bruce Momjian message dated "Tue, 24 May 2022 19:54:18 -0400" MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-ID: <1772515.1653441580.1@sss.pgh.pa.us> Date: Tue, 24 May 2022 21:19:40 -0400 Message-ID: <1772516.1653441580@sss.pgh.pa.us> List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk Bruce Momjian writes: > I always thought if pg_proc is able to call an arbitrary function in an > arbitrary library, it could access to the file system, and if that is > true, locking the super-user from file system access seems impossible > and unwise to try because it would give a false sense of security. That was the situation when we had v0 function call semantics. ISTM we are at least a lot closer now to being able to say it's locked down: "internal" functions can only reach things that are in the fmgrtab table, and "C" functions can only reach things that have associated PG_FUNCTION_INFO_V1 symbols. Plus we won't load shared libraries that don't have PG_MODULE_MAGIC blocks. Maybe there's still a way around all that, but it's sure a lot less obvious than it once was, and there are probably things we could do to make it even harder. I think would-be hackers are now reduced to doing what Robert suggested, which is trying to find a way to subvert a validly SQL-callable function by passing it bogus arguments. Maybe there's a way to gain filesystem access by doing that, but it's not going to be easy if the function is not one that intended to allow such operations. regards, tom lane