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 1p3mgz-0001JO-M8 for pgsql-hackers@arkaria.postgresql.org; Fri, 09 Dec 2022 23:22:10 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.92) (envelope-from ) id 1p3mgy-0003dl-HK for pgsql-hackers@arkaria.postgresql.org; Fri, 09 Dec 2022 23:22:08 +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 1p3mgw-0003dJ-K6 for pgsql-hackers@lists.postgresql.org; Fri, 09 Dec 2022 23:22:08 +0000 Received: from out3-smtp.messagingengine.com ([66.111.4.27]) by magus.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1p3mgs-0000xj-K1 for pgsql-hackers@lists.postgresql.org; Fri, 09 Dec 2022 23:22:06 +0000 Received: from compute5.internal (compute5.nyi.internal [10.202.2.45]) by mailout.nyi.internal (Postfix) with ESMTP id BB1D75C00AB; Fri, 9 Dec 2022 18:21:58 -0500 (EST) Received: from mailfrontend2 ([10.202.2.163]) by compute5.internal (MEProxy); Fri, 09 Dec 2022 18:21:58 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=paquier.xyz; h= cc:cc:content-type:date:date:from:from:in-reply-to:in-reply-to :message-id:mime-version:references:reply-to:sender:subject :subject:to:to; s=fm2; t=1670628118; x=1670714518; bh=hXDB17yWYH 4lvdb1J/sEXaC/NH7t4a2sd5X95uzAp0E=; b=kNrFyzQubLgegUnok8et1pUUGB 1BsddWUy2yzgZ1JW9q7MeDw+8/F62eHbZVwkTf6CYaLBEXqAcf4SsVNNpsMbZewa 3eHSWFFqUOp9EuPWXMaVyCrlURQF3O+wrj5H3LjY4cqQecEyfD4Htp5+imDFHxdz zfnpnUshu+/6AaYgYH1f1w4zbm580eEYbLBHX/mQqtuEb6Q0y0Yp0jvULjJ/jvqE 2yfj/1PbRjPnXKQAjetzJ+9fzXurhcSWWAT2gf7nCkXUjsFlvEOiuPawPe3urG7M YqJvGwDJyqg25SBN7x8VSxDndRNY14JFzDsmt1pGwD9OxL+sxlJXgdVXjU3Q== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=cc:cc:content-type:date:date:feedback-id :feedback-id:from:from:in-reply-to:in-reply-to:message-id :mime-version:references:reply-to:sender:subject:subject:to:to :x-me-proxy:x-me-proxy:x-me-sender:x-me-sender:x-sasl-enc; s= fm2; t=1670628118; x=1670714518; bh=hXDB17yWYH4lvdb1J/sEXaC/NH7t 4a2sd5X95uzAp0E=; b=AOYyJt6zUN9FBUiENR409Qe5odTaWpLrr4DpYvMrDOyy 3pG/Me6CfYeOc8f2PIc48qAq6hcfsU7Ty6L5d3dqUKyAT3j3WaWmwmdOus+z7/jF G9dvCl4gJNuraRGL7b53cJ3LqBbShkoRw2oLTWMal7YJxQtN53SnNfQctjo+HhMK 7MVgAp57FfqPxkAw+qynhIgebR3GsXsux93xrBZzscciXhGqRDZOa2hTkihY8wsF uIqhlvYT6zMCMO7NkoHWYxkYk0K9ig2CWSqjLSA+sSTyFRb9ZqxKBDxqdVeHOf/4 MIHYyvXwE0T/O8suk7z/DJsXujAys2UHe7iZSC5ffQ== X-ME-Sender: X-ME-Received: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgedvhedrvdefgddtlecutefuodetggdotefrodftvf curfhrohhfihhlvgemucfhrghsthforghilhdpqfgfvfdpuffrtefokffrpgfnqfghnecu uegrihhlohhuthemuceftddtnecusecvtfgvtghiphhivghnthhsucdlqddutddtmdenfg hrlhcuvffnffculdejtddmnecujfgurhepfffhvfevuffkfhggtggujgesghdtreertddt vdenucfhrhhomhepofhitghhrggvlhcurfgrqhhuihgvrhcuoehmihgthhgrvghlsehprg hquhhivghrrdighiiiqeenucggtffrrghtthgvrhhnpeetleeifedufffhhfdtteelgeeg geffhfekueevteeigfduudevudetgfegiedvjeenucevlhhushhtvghrufhiiigvpedtne curfgrrhgrmhepmhgrihhlfhhrohhmpehmihgthhgrvghlsehprghquhhivghrrdighiii X-ME-Proxy: Feedback-ID: i0fe9450f:Fastmail Received: by mail.messagingengine.com (Postfix) with ESMTPA; Fri, 9 Dec 2022 18:21:56 -0500 (EST) Date: Sat, 10 Dec 2022 08:21:51 +0900 From: Michael Paquier To: Heikki Linnakangas Cc: Daniel Gustafsson , PostgreSQL Hackers Subject: Re: Raising the SCRAM iteration count Message-ID: References: <1d669d97-86b3-a5dc-9f02-c368bca911f6@iki.fi> MIME-Version: 1.0 Content-Type: multipart/signed; micalg=pgp-sha512; protocol="application/pgp-signature"; boundary="BmOQhyeTT1lr344O" Content-Disposition: inline In-Reply-To: <1d669d97-86b3-a5dc-9f02-c368bca911f6@iki.fi> List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk --BmOQhyeTT1lr344O Content-Type: text/plain; charset=us-ascii Content-Disposition: inline Content-Transfer-Encoding: quoted-printable On Fri, Dec 09, 2022 at 05:50:00PM +0200, Heikki Linnakangas wrote: >> The attached introduces a scram_iteration_count GUC with a default of 15= 000 >> (still conservative, from RFC7677) and a minimum of 4096. Since the ite= rations >> are stored per secret it can be altered with backwards compatibility. >=20 > We just had a discussion with a colleague about using a *smaller* iterati= on > count. Why? To make the connection startup faster. We're experimenting wi= th > a client that runs in a Cloudflare worker, which is a wasm runtime with v= ery > small limits on how much CPU time you're allowed to use (without paying > extra). And we know that the password is randomly generated and long enou= gh. > If I understand correctly, the point of iterations is to slow down > brute-force or dictionary attacks, but if the password is strong enough to > begin with, those attacks are not possible regardless of iteration count.= So > I would actually like to set the minimum iteration count all the way down= to > 1. This is the kind of thing that should be easily measurable with pgbench -C and an empty script. How much difference are you seeing with 1, 4096 and more than that? All that comes down to provide more capability for the existing routines in my opinion. So what if we finally extended with a new flavor PQencryptPasswordConn() able to get a list of options, say PQencryptPasswordConn() extended that has a string with all the options? psql could use for \password a grammar consistent with \g, as of: \password (iteration=3D4096, salt_length=3D123) PASS_STR Note that scram_build_secret() is already able to handle any iteration count, even at 1, so IMO it is not a good idea to lower the default to be so. I'd agree with Daniel to make it higher by default and follow the RFCs, though like you I have wanted also in core much more control over that. -- Michael --BmOQhyeTT1lr344O Content-Type: application/pgp-signature; name="signature.asc" -----BEGIN PGP SIGNATURE----- iQIzBAABCgAdFiEEG72nH6vTowiyblFKnvQgOdbyQH0FAmOTww8ACgkQnvQgOdby QH2ZJhAApeTQd1YFtQSNcJFom716c6rgmx9ZOQGCv4TIvrBj9wUFYWlh5vgdHAjb tkafFEPyFiWvg3363Jb3aQlSKbrCT1YzmwOpN6UU/Ofp1pcfiSPWD/ylfKPh501p KMbbF8ZHyVR8TCYbs2y8M2PnEyo145DorrfojY+a5CirYV5ng3+Cwgbz1i97x/Y4 OCedfOnd8mEQf+mmuLuwn/tx3l94kBaVO/hhJmafr15Py8oRdLDlKzDdtyjs7lZi OuqSEDNCH4g6zMnHo/mgR9xQxJuOvgZU/fhkxpDKsLlY+gZTf6+EOUd9UkbyzvoZ dzPey4PKUrn3zqDjiZcU0UAthjgEYKQRy+PFO9dtH5MeUDcXoqGx8pTwcTY6mIj2 S4vlEv+DTi8+HNOLskbfQxf18/aC+rQhU4py/5s2GuW5goTn1CHbdK2K6bEd8Brz dXEDUB4SjOJOcq2iUGNrQ1fSG8V3yqzFUvDeMGDoydh5UBY9jd82kBI5euuqnshI dAzwaf6g2Ch0TRcroy+J3KpYrz3szjJfPuP2mytUr7gTkkkPWT4Gr9wY/cExdsFe qVyVcCCKTjfD7d1F9FR5lwbWtBhtaBLAzjBHpk9rMNK7jnbfchFSCT6DQfpmaIaq GJKB2Yo20AjeCeBdv5pmlVrAFUBkyzNiF99Liu4xZo0jpYPLRFU= =H11q -----END PGP SIGNATURE----- --BmOQhyeTT1lr344O--