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 1hIpMj-0005a6-44 for pgsql-bugs@arkaria.postgresql.org; Tue, 23 Apr 2019 06:57:17 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.89) (envelope-from ) id 1hIpMh-0004Yy-EF for pgsql-bugs@arkaria.postgresql.org; Tue, 23 Apr 2019 06:57:15 +0000 Received: from makus.postgresql.org ([2001:4800:3e1:1::229]) by malur.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.89) (envelope-from ) id 1hIpMg-0004Yr-7W for pgsql-bugs@lists.postgresql.org; Tue, 23 Apr 2019 06:57:14 +0000 Received: from out4-smtp.messagingengine.com ([66.111.4.28]) by makus.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.89) (envelope-from ) id 1hIpMb-0005x5-60 for pgsql-bugs@lists.postgresql.org; Tue, 23 Apr 2019 06:57:12 +0000 Received: from compute4.internal (compute4.nyi.internal [10.202.2.44]) by mailout.nyi.internal (Postfix) with ESMTP id 50A98283EF; Tue, 23 Apr 2019 02:57:08 -0400 (EDT) Received: from mailfrontend1 ([10.202.2.162]) by compute4.internal (MEProxy); Tue, 23 Apr 2019 02:57:08 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=paquier.xyz; h= date:from:to:cc:subject:message-id:references:mime-version :content-type:in-reply-to; s=fm1; bh=1X0Zu96yElNCj/uKhFVYxnmXXVf v6uHDtbu9pZZtUuE=; b=qTTChM93NsnejEGdINhl3HJhYRNgvjw5bbEXQ80QBEj Fjk1+uC5cquXMfDUsjV6MUbzRTtpXzdvOq/PPPJa6Hkv1bhKMJ4mRb+5FUzS2Lpp evJII7XezgpA+/UGw0z3T0GVT3EVqHdK3t/dkgmTQA4DC6R1XoysgQs5vsp1Ccff bs1uW5O0pPpCa9IoMl4rfPWP+m2JQf6UsJ89HH8gexZWJ7rxyVC38iR22J1iZ7qL nqH4KqozRh4nN4JH3+ofQePwLQ0noCkuuOfvhgIGjOwv3OJETD7hNwTodxMlJbQQ +apvniyP48Hz0+rmIdVChohlcRfO6Ns8DjqQtA0V/cg== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=cc:content-type:date:from:in-reply-to :message-id:mime-version:references:subject:to:x-me-proxy :x-me-proxy:x-me-sender:x-me-sender:x-sasl-enc; s=fm2; bh=1X0Zu9 6yElNCj/uKhFVYxnmXXVfv6uHDtbu9pZZtUuE=; b=2z8SBh2tvWYijEBbfRw23m oIPSQxwOAwdK8NwzfOe48YS4iokXQZL/Gcx86tEnB4bXMFgpFiGGEdFesE7Exeog feebY3BQ6MCjHzpvEOQ9rv7JGCMebnABnl0Qb92fcM/i4N1gKWpjpKAQNJycxhoa R5o5YWxlvUZL+64A1mvSlyOJNs8Oj1P+AbSwORgKP0EMXLTu8Nqm+BaCpq/H4Phb j0ADDvIzOCW3c1Y5bpaIYJSD4fhre6rzG1g/aSFynVUQhXM1sKhDmstzWDo/2Qga qO6gKr+OAuvjo6svJOxOm2F2WiCm4fVKO88G+6JaZdSk087qGb/WsGWEAA9nH61g == X-ME-Sender: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgeduuddrgeejgdellecutefuodetggdotefrodftvf curfhrohhfihhlvgemucfhrghsthforghilhdpqfgfvfdpuffrtefokffrpgfnqfghnecu uegrihhlohhuthemuceftddtnecusecvtfgvtghiphhivghnthhsucdlqddutddtmdenfg hrlhcuvffnffculdejtddmnecujfgurhepfffhvffukfhfgggtuggjsehgtderredttddv necuhfhrohhmpefoihgthhgrvghlucfrrghquhhivghruceomhhitghhrggvlhesphgrqh huihgvrhdrgiihiieqnecukfhppeduuddurddutddvrddukedtrddukeehnecurfgrrhgr mhepmhgrihhlfhhrohhmpehmihgthhgrvghlsehprghquhhivghrrdighiiinecuvehluh hsthgvrhfuihiivgeptd X-ME-Proxy: Received: from paquier.xyz (ee0822lan1.rev.em-net.ne.jp [111.102.180.185]) by mail.messagingengine.com (Postfix) with ESMTPA id B0C9BE44B6; Tue, 23 Apr 2019 02:57:04 -0400 (EDT) Date: Tue, 23 Apr 2019 15:57:01 +0900 From: Michael Paquier To: "Jonathan S. Katz" Cc: Tom Lane , pgsql-bugs@lists.postgresql.org, Stephen Frost Subject: Re: Possible to store invalid SCRAM-SHA-256 Passwords Message-ID: <20190423065701.GL2712@paquier.xyz> References: <4240a41f-a957-fd7d-7c24-31683f259b9d@postgresql.org> <20190422015051.GA3433@paquier.xyz> <3033.1555940554@sss.pgh.pa.us> <5a93333c-dde6-ee52-f870-4dccfc50eb6f@postgresql.org> <30284.1555972921@sss.pgh.pa.us> <15140775-08c3-45bd-6dab-fdcd290d1bf0@postgresql.org> <20190423010142.GE2712@paquier.xyz> <10698.1555981849@sss.pgh.pa.us> <265876b8-1a72-89cd-bdcf-e641d93e166c@postgresql.org> <20190423021018.GF2712@paquier.xyz> MIME-Version: 1.0 Content-Type: multipart/signed; micalg=pgp-sha512; protocol="application/pgp-signature"; boundary="6iXXu7NwgEt9u5a7" Content-Disposition: inline In-Reply-To: <20190423021018.GF2712@paquier.xyz> List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Precedence: bulk --6iXXu7NwgEt9u5a7 Content-Type: multipart/mixed; boundary="c2gYorpyS4gG0T74" Content-Disposition: inline --c2gYorpyS4gG0T74 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline On Tue, Apr 23, 2019 at 11:10:18AM +0900, Michael Paquier wrote: > That's a hard morning... Yes you are right and I can see the failure. > By the way, grouping everything in one patch looks more adapted to me > as this tightens all the checks for the different verifier types. The afternoon has been better. I have double-checked your patch and committed it down to v10. Now, there are two things which may need extra handling: - Do we add a note in the release notes about that with a SQL query checking the state of pg_authid? - In ~9.6 we include in md5.h a macro which does not care about hex characters in the MD5 hash. I think that we should fix that as well, or perhaps that's not worth caring per the lack of complaints? Attached is what would be needed. -- Michael --c2gYorpyS4gG0T74 Content-Type: text/x-diff; charset=us-ascii Content-Disposition: attachment; filename="md5-check-96-v1.patch" Content-Transfer-Encoding: quoted-printable diff --git a/src/include/libpq/md5.h b/src/include/libpq/md5.h index f3eec8b4f4..fac2636c07 100644 --- a/src/include/libpq/md5.h +++ b/src/include/libpq/md5.h @@ -16,10 +16,12 @@ #ifndef PG_MD5_H #define PG_MD5_H =20 +#define MD5_PASSWD_CHARSET "0123456789abcdef" #define MD5_PASSWD_LEN 35 =20 #define isMD5(passwd) (strncmp(passwd, "md5", 3) =3D=3D 0 && \ - strlen(passwd) =3D=3D MD5_PASSWD_LEN) + strlen(passwd) =3D=3D MD5_PASSWD_LEN && \ + strspn(passwd + 3, MD5_PASSWD_CHARSET) =3D=3D MD5_PASSWD_LEN - 3) =20 =20 extern bool pg_md5_hash(const void *buff, size_t len, char *hexsum); --c2gYorpyS4gG0T74-- --6iXXu7NwgEt9u5a7 Content-Type: application/pgp-signature; name="signature.asc" -----BEGIN PGP SIGNATURE----- iQIzBAABCgAdFiEEG72nH6vTowiyblFKnvQgOdbyQH0FAly+tz0ACgkQnvQgOdby QH1dJA/+K3JY/3sshdNJ0rlmT+9t5Drg4h1LLQ5lp+YHbIdQBgqil1vllRmbqOJF Yf7JoXujwxOm3jmp6cN9eKrGyMu8bvyp/pZga37muaJyzkJZKZMOFUEGJRvWePlX 6H52svSjUNtkwyAGWyX88rWtn0NB6v//4nf+2y3+nzCGNvpp4WhtdOQ5NRJ9GJsK MMu90bONhU56i2nBz8Fz3K0sg5rZKg1Rn+Zy4g0p0L/ttxmbE08w6cECgaGqqTxn vi8r6vCmYiqayg90TlzHA+KxKT3VcIZnu7m2qYlyCnET0/htUODA6PW2Wjz5/6Kx /OKqmcwkexwYKShRuWtVjPxl9dtuptyJ7WO9bTY6yEyFOk0Cly8p4a4nV4Q2P2la Ya3emtYc2szN6+LvDmxWJTyoB/nx+jhrWnYU4jX+kMleigh23+PRiOyAKGHZmroS tliyEnfDTzQMItwZpCZB5xyl7u9EtjxzXRHFj7PpY6MFwBVEGDjbyK7SivJ1NpBM Tc2MfsPMXRyAkAlcASEu1n6LuEfO11hgw0BB5A+Y0Ahn/vM5KVlbaL5Sya+aE6To XXakkxCV+mP4bcUn0cprM2950MFV018c0xHhLHJmfqXpdzJAnfdONc/pwurt4t5J jQ14bddoCLdsLvZtSf/v3kTtAuFW2q+Tf55kX/RZL4EvX0bzBQg= =zJXo -----END PGP SIGNATURE----- --6iXXu7NwgEt9u5a7--