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 1myGf2-0006Jl-7j for pgsql-sql@arkaria.postgresql.org; Fri, 17 Dec 2021 17:04:48 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.92) (envelope-from ) id 1myGez-0006F5-WB for pgsql-sql@arkaria.postgresql.org; Fri, 17 Dec 2021 17:04:46 +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 1myGez-0006D0-Mt for pgsql-sql@lists.postgresql.org; Fri, 17 Dec 2021 17:04:45 +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 1myGes-0000J3-Ui for pgsql-sql@lists.postgresql.org; Fri, 17 Dec 2021 17:04:45 +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 1BHH4XKu1358973; Fri, 17 Dec 2021 12:04:33 -0500 From: Tom Lane To: Jonathan Katz cc: aditya desai , pgsql-sql Subject: Re: Pragma autonomous transactions in Postgres/ Certification based authentication in DB Links In-reply-to: <52F9312D-4173-495B-B208-51CFA6331E00@excoventures.com> References: <1355149.1639758450@sss.pgh.pa.us> <52F9312D-4173-495B-B208-51CFA6331E00@excoventures.com> Comments: In-reply-to Jonathan Katz message dated "Fri, 17 Dec 2021 11:42:32 -0500" MIME-Version: 1.0 Content-Type: text/plain; charset="UTF-8" Content-ID: <1358971.1639760673.1@sss.pgh.pa.us> Content-Transfer-Encoding: 8bit Date: Fri, 17 Dec 2021 12:04:33 -0500 Message-ID: <1358972.1639760673@sss.pgh.pa.us> List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk Jonathan Katz writes: >> On Dec 17, 2021, at 11:27 AM, Tom Lane wrote: >> The problem is >> that making use of any credentials stored in the server's filesystem >> amounts to impersonating the OS user that's running the server. It'd >> be nice to find a less confining solution, but I'm not sure what one >> would look like. > Even stepping back and just looking at what prompted the question, > i.e. “hardcoding the username/password”, if there was a way we could > allow for the injection of the credentials when we’re trying to establish > the connection, that may be one way forward, but I see that also > opening up a bunch more problems we would need to consider. One approach that's available now is to have dblink use a foreign server/foreign user mapping definition. Then the secret is stored in pg_user_mapping rather than in the SQL text, which is an improvement anyway. (If you want to complain about that, you have to be a little more specific about what your threat model is. Somebody who can peek into pg_user_mapping can probably get hold of credentials in the server's filesystem, too.) regards, tom lane