Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtp (Exim 4.84_2) (envelope-from ) id 1cH5IL-0005d7-Nz for pgsql-hackers@arkaria.postgresql.org; Wed, 14 Dec 2016 08:52:14 +0000 Received: from localhost ([127.0.0.1] helo=postgresql.org) by malur.postgresql.org with smtp (Exim 4.84_2) (envelope-from ) id 1cH5IL-0004iX-6Q for pgsql-hackers@arkaria.postgresql.org; Wed, 14 Dec 2016 08:52:13 +0000 Received: from makus.postgresql.org ([2001:4800:1501:1::229]) by malur.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA384:256) (Exim 4.84_2) (envelope-from ) id 1cH5IB-0004ZU-FA for pgsql-hackers@postgresql.org; Wed, 14 Dec 2016 08:52:03 +0000 Received: from mail-lf0-x242.google.com ([2a00:1450:4010:c07::242]) by makus.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.84_2) (envelope-from ) id 1cH5I8-0006Ju-79 for pgsql-hackers@postgresql.org; Wed, 14 Dec 2016 08:52:02 +0000 Received: by mail-lf0-x242.google.com with SMTP id y21so1138058lfa.0 for ; Wed, 14 Dec 2016 00:51:59 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=sender:subject:to:references:cc:from:message-id:date:user-agent :mime-version:in-reply-to:content-transfer-encoding; bh=PUX/ebNkHmYvbe9WdW33V/1FAarFzvP2hTufQ0uLQ0o=; b=BUrmg8zXx7wmB3OVStpyLg+ZIFhtxDEEuW1ksBvGRDFloJkZCnGQb0JhWw7AnTxiZq T8y4pzHePyiA+GCiY2fnlSgZyJzsJnECtTFaYOUkuTu+dSPDxm1ErFYA/r1GTkkP0w5w Th9BjmOsCd+JiF1vVjiYT8fSEAA31yAE1HGtKkL5TS01J/e6Fer53Og9XVYUnNCGwcU9 Y1E0zYZld3nz1ot10DDfb5slaehhL+fdB/BD5VERSJldK6M/1m3jCkUgP03yPhJDaOF2 hJeyFuq5wPChlMD0n+RIHrD31GuVtUOMbOTKhGEeFiMg8Kr0y3bS0rVc8oklMaE8VCZD 6kxw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:sender:subject:to:references:cc:from:message-id :date:user-agent:mime-version:in-reply-to:content-transfer-encoding; bh=PUX/ebNkHmYvbe9WdW33V/1FAarFzvP2hTufQ0uLQ0o=; b=IzVxcstgxNBokSRdf6GB9e5huciH3K5fDYBIjqdebfE6Wg8k2UalTwZclUzpBtCffR vIEbBb30XRiQTaktHmZaqlmyReU++nrm7kp7A4DCMJTKM98NXLhfqREmksilnTrGk4Ie wfaeW1mulcuE7ymFugdif9kOdPZXgnCDAvxjf5379tVojz2yXATya0Tx/9gBgrMyzglB pPgByjxcfX0LW92xMZRfFgbjTGXzTpdqVyw2hoUdnHLzc84FMToCg7J6NFyPQXyBwsp4 rdumAVHWWNDL2OPj+Za3J8afwkJrkQbljPu2AsTQzMnS+P+zWWgXcEXg1zROhTsfXhYx LbOQ== X-Gm-Message-State: AKaTC01z1kfjNEBad04vu+hcrdBD/QpXsFDR/e8WI+qCn/yJqwW7xkAVcOukyvKZ6RsVnw== X-Received: by 10.46.77.92 with SMTP id a89mr40807106ljb.28.1481705517629; Wed, 14 Dec 2016 00:51:57 -0800 (PST) Received: from [192.168.1.111] (dsl-hkibrasgw1-58c38f-82.dhcp.inet.fi. [88.195.143.82]) by smtp.gmail.com with ESMTPSA id 32sm1420346lft.5.2016.12.14.00.51.55 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 14 Dec 2016 00:51:56 -0800 (PST) Subject: pg_authid.rolpassword format (was Re: Password identifiers, protocol aging and SCRAM protocol) To: Michael Paquier References: <947b9aff-8fdb-dbf5-a99c-0ffd4523a73f@2ndquadrant.com> <21eecdb8-365b-8347-1ae2-5278d1fe798c@iki.fi> <762f4875-a87e-cf0b-c06b-b357294d8be1@iki.fi> Cc: Robert Haas , Andres Freund , Peter Eisentraut , David Steele , Tom Lane , David Fetter , Alvaro Herrera , Magnus Hagander , Julian Markwort , Stephen Frost , PostgreSQL mailing lists , Valery Popov From: Heikki Linnakangas Message-ID: <2d07165c-1793-e243-a2a9-e45b624c7580@iki.fi> Date: Wed, 14 Dec 2016 10:51:55 +0200 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:45.0) Gecko/20100101 Icedove/45.4.0 MIME-Version: 1.0 In-Reply-To: Content-Type: text/plain; charset=utf-8; format=flowed Content-Transfer-Encoding: 7bit X-Pg-Spam-Score: -2.6 (--) 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 12/09/2016 10:19 AM, Michael Paquier wrote: > On Fri, Dec 9, 2016 at 5:11 PM, Heikki Linnakangas wrote: >> Couple of things I should write down before I forget: >> >> 1. It's a bit cumbersome that the scram verifiers stored in >> pg_authid.rolpassword don't have any clear indication that they're scram >> verifiers. MD5 hashes are readily identifiable by the "md5" prefix. I think >> we should use a "scram-sha-256:" for scram verifiers. > > scram-sha-256 would make the most sense to me. > >> Actually, I think it'd be awfully nice to also prefix plaintext passwords >> with "plain:", but I'm not sure it's worth breaking the compatibility, if >> there are tools out there that peek into rolpassword. Thoughts? > > pgbouncer is the only thing coming up in mind. It looks at pg_shadow > for password values. pg_dump'ing data from pre-10 instances will also > need to adapt. I see tricky the compatibility with the exiting CREATE > USER PASSWORD command though, so I am wondering if that's worth the > complication. > >> 2. It's currently not possible to use the plaintext "password" >> authentication method, for a user that has a SCRAM verifier in rolpassword. >> That seems like an oversight. We can't do MD5 authentication with a SCRAM >> verifier, but "password" we could. > > Yeah, that should be possible... The tip of the work branch can now do SCRAM authentication, when a user has a plaintext password in pg_authid.rolpassword. The reverse doesn't work, however: you cannot do plain "password" authentication, when the user has a SCRAM verifier in pg_authid.rolpassword. It gets worse: plain "password" authentication doesn't check if the string stored in pg_authid.rolpassword is a SCRAM authenticator, and treats it as a plaintext password, so you can do this: PGPASSWORD="scram-sha-256:mDBuqO1mEekieg==:4096:17dc259499c1a184c26ee5b19715173d9354195f510b4d3af8be585acb39ae33:d3d713149c6becbbe56bae259aafe4e95b79ab7e3b50f2fbd850ea7d7b7c114f" psql postgres -h localhost -U scram_user I think we're going to have a more bugs like this, if we don't start to explicitly label plaintext passwords as such. So, let's add "plain:" prefix to plaintext passwords, in pg_authid.rolpassword. With that, these would be valid values in pg_authid.rolpassword: plain:foo md55a962ce7a24371a10e85627a484cac28 scram-sha-256:mDBuqO1mEekieg==:4096:17dc259499c1a184c26ee5b19715173d9354195f510b4d3af8be585acb39ae33:d3d713149c6becbbe56bae259aafe4e95b79ab7e3b50f2fbd850ea7d7b7c114f But anything that doesn't begin with "plain:", "md5", or "scram-sha-256:" would be invalid. You shouldn't have invalid values in the column, but if you do, all the authentication mechanisms would reject it. It would be nice to also change the format of MD5 passwords to have a colon, as in "md5:", but that's probably not worth breaking compatibility for. Almost no-one stores passwords in plaintext, so changing the format of that wouldn't affect many people, but there might well be tools out there that peek into MD5 hashes. - Heikki -- Sent via pgsql-hackers mailing list (pgsql-hackers@postgresql.org) To make changes to your subscription: http://www.postgresql.org/mailpref/pgsql-hackers