Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtp (Exim 4.84_2) (envelope-from ) id 1dwUJD-0003Y0-J8 for pgsql-hackers@arkaria.postgresql.org; Mon, 25 Sep 2017 14:24:31 +0000 Received: from localhost ([127.0.0.1] helo=postgresql.org) by malur.postgresql.org with smtp (Exim 4.84_2) (envelope-from ) id 1dwUJD-0004K9-4V for pgsql-hackers@arkaria.postgresql.org; Mon, 25 Sep 2017 14:24:31 +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_SHA384:256) (Exim 4.84_2) (envelope-from ) id 1dwUHd-0007Xg-5R for pgsql-hackers@postgresql.org; Mon, 25 Sep 2017 14:22:53 +0000 Received: from out1-smtp.messagingengine.com ([66.111.4.25]) by magus.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA384:256) (Exim 4.84_2) (envelope-from ) id 1dwUHZ-00075N-Cd for pgsql-hackers@postgresql.org; Mon, 25 Sep 2017 14:22:52 +0000 Received: from compute7.internal (compute7.nyi.internal [10.202.2.47]) by mailout.nyi.internal (Postfix) with ESMTP id 4FE2521754; Mon, 25 Sep 2017 10:22:47 -0400 (EDT) Received: from frontend2 ([10.202.2.161]) by compute7.internal (MEProxy); Mon, 25 Sep 2017 10:22:47 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=cc:content-transfer-encoding:content-type :date:from:in-reply-to:message-id:mime-version:references :subject:to:x-me-sender:x-me-sender:x-sasl-enc:x-sasl-enc; s= fm1; bh=bKwOjFJ0UCE4Dv6QbG9xHTygMzneY4Ksps8k9XTYISg=; b=ls4tgKlQ rrhN9A9DDrB+0OhSjH1Bm7jMhUurhkx9Tqq4x/yHhJIyH+KJF90hABVNbzhFbFZB baisfOWGIBQvhTvZBi7px7L6dd5yWj1Zf7xh+8RnVMpu9uuppCTNSVxKIbPSt09h Eb2/Bn6Fdv0ZT+arhkVSlxp8YEyRyhPl+FwJgDYWA+MdGwyK/1osQ+NA1csO5JEk qcQIMt93hFSG69y0ZySzr4+lCsFQBlt90S1UmDddilOs5LAPB0KIwLCdBIqWusDc mC3RB1dySwx1DVVnWOqsq8/obVoguRJNWHsaUJkwan31H15GNA3ZD3Leh6osjSYh ThQRV9SCeeY7HA== X-ME-Sender: X-Sasl-enc: eq3BtbYSAv5UeqQvAZR9NejJ3j2MLOpZqL8YC/WHxsoM 1506349367 Received: from april.local (c-73-13-66-39.hsd1.pa.comcast.net [73.13.66.39]) by mail.messagingengine.com (Postfix) with ESMTPA id F142924950; Mon, 25 Sep 2017 10:22:46 -0400 (EDT) Subject: Re: [JDBC] Channel binding support for SCRAM-SHA-256 To: Michael Paquier References: <20170530151432.GW3151@tamriel.snowman.net> <20170530170036.GZ3151@tamriel.snowman.net> <20170531034941.GH3151@tamriel.snowman.net> <20170531235922.GR3151@tamriel.snowman.net> <20170601155042.GG3151@tamriel.snowman.net> <20170602010826.GP3151@tamriel.snowman.net> Cc: =?UTF-8?Q?=c3=81lvaro_Hern=c3=a1ndez_Tortosa?= , "pgsql-hackers@postgresql.org" From: Peter Eisentraut Organization: 2ndQuadrant Message-ID: Date: Mon, 25 Sep 2017 10:22:46 -0400 User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.12; rv:52.0) Gecko/20100101 Thunderbird/52.3.0 MIME-Version: 1.0 In-Reply-To: Content-Type: text/plain; charset=utf-8 Content-Language: en-US Content-Transfer-Encoding: 8bit List-Archive: List-Help: List-ID: List-Owner: List-Post: List-Subscribe: List-Unsubscribe: X-Mailing-List: pgsql-hackers Precedence: bulk Sender: pgsql-hackers-owner@postgresql.org On 9/10/17 22:37, Michael Paquier wrote: >>> With the tests directly in the patch, things are easy to run. WIth >>> PG10 stabilization work, of course I don't expect much feedback :) >>> But this set of patches looks like the direction we want to go so as >>> JDBC and libpq users can take advantage of channel binding with SCRAM. >> >> Attached is a new patch set, rebased as of c6293249. > > And again a new set to fix the rotten bits caused by 85f4d63. Here is a review of the meat of the code, leaving aside the discussion of the libpq connection parameters. Overall, the structure of the code makes sense and it fits in well with the existing SCRAM code. I think the channel-binding negotiation on the client side is wrong. The logic in the patch is +#ifdef USE_SSL + if (state->ssl_in_use) + appendPQExpBuffer(&buf, "p=%s", SCRAM_CHANNEL_TLS_UNIQUE); + else + appendPQExpBuffer(&buf, "y"); +#else + appendPQExpBuffer(&buf, "n"); +#endif But if SSL is compiled in but not used, the client does not in fact support channel binding (for that connection), so it should send "n". The "y" flag should be sent if ssl_in_use but the client did not see the server advertise SCRAM-SHA256-PLUS. That logic is missing entirely in this patch. You have the server reject a client that does not support channel binding ("n") on all SSL connections. I don't think this is correct. It is up to the client to use channel binding or not, even on SSL connections. We should update pg_hba.conf to allow a method specification of "scram-sha256-plus", i.e., only advertise the channel binding variant to the client. Then you could make policy decisions like rejecting clients that do not use channel binding on SSL connections. This could be a separate patch later. The error message in the "p" case if SSL is not in use is a bit confusing: "but the server does not need it". I think this could be left at the old message "but it is not supported". This ties into my interpretation from above that whether channel binding is "supported" depends on whether SSL is in use for a particular connection. Some small code things: - prefer to use size_t over int for length (tls_finish_len etc.) - tls_finish should be tls_finished - typos: certificate_bash -> certificate_hash In the patch for tls-server-end-point, I think the selection of the hash function deviates slightly from the RFC. The RFC only says to substitute MD5 and SHA-1. It doesn't say to turn SHA-224 into SHA-256, for example. There is also the problem that the code as written will turn any unrecognized hash method into SHA-256. If think the code should single out MD5 and SHA-1 only and then use EVP_get_digestbynid() for the rest. (I don't know anything about the details of OpenSSL APIs, but that function sounded right to me.) -- Peter Eisentraut http://www.2ndQuadrant.com/ PostgreSQL Development, 24x7 Support, Remote DBA, Training & Services -- Sent via pgsql-hackers mailing list (pgsql-hackers@postgresql.org) To make changes to your subscription: http://www.postgresql.org/mailpref/pgsql-hackers