Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.89) (envelope-from ) id 1htffb-0007gH-RG for pgsql-general@arkaria.postgresql.org; Fri, 02 Aug 2019 22:05:03 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.89) (envelope-from ) id 1htffa-0001ZP-A2 for pgsql-general@arkaria.postgresql.org; Fri, 02 Aug 2019 22:05:02 +0000 Received: from magus.postgresql.org ([2a02:c0:301:0:ffff::29]) by malur.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.89) (envelope-from ) id 1htffZ-0001Wx-U5 for pgsql-general@lists.postgresql.org; Fri, 02 Aug 2019 22:05:01 +0000 Received: from lungold.riddles.org.uk ([82.68.208.19]) by magus.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.89) (envelope-from ) id 1htffX-0003gV-Mo for pgsql-general@lists.postgresql.org; Fri, 02 Aug 2019 22:05:01 +0000 Received: from [192.168.127.1] (port=15837 helo=caithnard.riddles.org.uk) by lungold.riddles.org.uk with esmtps (TLSv1.2:ECDHE-RSA-AES256-GCM-SHA384:256) (Exim 4.88 (FreeBSD)) (envelope-from ) id 1htffV-00054d-Em; Fri, 02 Aug 2019 22:04:57 +0000 Received: from [127.0.0.1] (port=57374 helo=caithnard.riddles.org.uk) by caithnard.riddles.org.uk with esmtp (Exim 4.89 (FreeBSD)) (envelope-from ) id 1htffU-000253-LZ; Fri, 02 Aug 2019 22:04:56 +0000 From: Andrew Gierth To: Vladimir Soldatov Cc: pgsql-general@lists.postgresql.org Subject: Re: SCRAM-SHA-256, is it possible to retrieve enough information from PG server (pg_authid etc) to perform authentication as a client In-Reply-To: (Vladimir Soldatov's message of "Fri, 2 Aug 2019 15:52:16 +0300") Message-ID: <87pnlntfi3.fsf@news-spur.riddles.org.uk> References: User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/25.1 (berkeley-unix) Date: Fri, 02 Aug 2019 23:04:54 +0100 MIME-Version: 1.0 Content-Type: text/plain List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Precedence: bulk >>>>> "Vladimir" == Vladimir Soldatov writes: Vladimir> Hi guys, Vladimir> I am new to PostgreSQL, so sorry for maybe stupid question. I Vladimir> am working on some application implementing Frontend/Backend Vladimir> PG protocol and one of the goals - having only "admin" users Vladimir> credentials (like postgres user) be able to retrieve enough Vladimir> information from PG server (for example, from pg_authid Vladimir> table) to perform authentication for any user created in PG Vladimir> (without any user interaction, so we don't know the user's Vladimir> password). It's an explicit goal of SCRAM to make it impossible to use the server's stored authentication data to actually authenticate from a client (without first breaking the preimage resistance of the hash function). Specifically, the authentication exchange proves to the server that the client knows key_c, but the server only stores H(key_c); the server can validate the client message just by applying the hash function, but the correct value of key_c can't be determined in advance on the server without a successful preimage attack on H(key_c). The right way to allow a privileged user to operate as if they were someone else is to use SET ROLE or SET SESSION AUTHORIZATION rather than actually trying to log in as the other user. -- Andrew (irc:RhodiumToad)