Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtp (Exim 4.84_2) (envelope-from ) id 1cGRlw-0002E6-4Q for pgsql-hackers@arkaria.postgresql.org; Mon, 12 Dec 2016 14:40:08 +0000 Received: from localhost ([127.0.0.1] helo=postgresql.org) by malur.postgresql.org with smtp (Exim 4.84_2) (envelope-from ) id 1cGRlv-0000gF-Na for pgsql-hackers@arkaria.postgresql.org; Mon, 12 Dec 2016 14:40:07 +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 1cGRlu-0000fD-Mu for pgsql-hackers@postgresql.org; Mon, 12 Dec 2016 14:40:06 +0000 Received: from mail-wm0-x241.google.com ([2a00:1450:400c:c09::241]) by magus.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.84_2) (envelope-from ) id 1cGRlp-0008KZ-Bt for pgsql-hackers@postgresql.org; Mon, 12 Dec 2016 14:40:05 +0000 Received: by mail-wm0-x241.google.com with SMTP id u144so11674006wmu.0 for ; Mon, 12 Dec 2016 06:40:00 -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=ujzDRwlYhxgaPcGEkfKm8YsrqOPnGklov7v6j83KqPg=; b=pPXqot5nSTllDRynuo5WrZ049DvQrTtO6WKzscZRaVZE/9m9oisgLlnDmkwwN/LIb/ 9riGQxh2vITcMTHK+V2yfMpvaCa9MCF/w+buNivITEfJgK1uWOZy+QkBmTtzUIfb4MON 4annqnLnqWTikHxAUvI3phxeO0MJEOoe43Dyv2awvx/lx5xXgX5CqvEhae8DQIZ/B7ba U4Vbk1hHBeWgWrrW/N/M7qzZVsVbg0Ymra+Ut+wZEPrwwIUpdivNoNjmn/5dmP0bH+ot 17fd+SHkznGY9jJ1n2QCP9ZPChWAZVT7t+Ejy2xhFVfz6G4YCcLmCV4yHyriRecrtmza netw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; 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=ujzDRwlYhxgaPcGEkfKm8YsrqOPnGklov7v6j83KqPg=; b=aD/CtFt1W9gLsK0JaJ5PUaSRHhICg7O2uolVslEn1qYH4SlPCcnnZzOgL+mX3T+CBW E8Gz9hYvWkI1cRxCR99tzMR4K4xZPazePNiVPmm1KKhmzUvI5Mz3wISam5U3hZwtBoaE MdzeLKecuC1rOwLeU7WGvkj6+WBHX11wNbXtr6sGUXBQmSMe6BZGsML+zC0zZccRAWoO Fz8S4XViwbY3gXjAvYXWSmIDiyg1M7TLH43nRsIfBn2GkriWJPFtdcz8zz9hPYbuJ/1k F3uN8Jb1EeN2c150v+Upt/vaGHniQRCnChGjXNhALX4OZX1/gkCkJIHHYCssgGcNJXuh o0aQ== X-Gm-Message-State: AKaTC001VplakEVPhqP7qUjT2PQnHfW83qABwLkaW9MSy3W6GoyS56qbG0fWTJgR/pvIXg== X-Received: by 10.25.219.69 with SMTP id s66mr26688063lfg.116.1481553598088; Mon, 12 Dec 2016 06:39:58 -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 67sm9156249ljf.35.2016.12.12.06.39.55 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 12 Dec 2016 06:39:57 -0800 (PST) Subject: Re: Password identifiers, protocol aging and SCRAM protocol To: Michael Paquier References: <21eecdb8-365b-8347-1ae2-5278d1fe798c@iki.fi> <3029e460-d47c-710e-507e-d8ba759d7cbb@iki.fi> <20161209111041.GA23215@paquier.xyz> 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: <973937ca-cbed-ad48-c783-e29723a2a9c0@iki.fi> Date: Mon, 12 Dec 2016 16:39: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: <20161209111041.GA23215@paquier.xyz> Content-Type: text/plain; charset=windows-1252; 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 A few couple more things that caught my eye while hacking on this: 1. We don't use SASLPrep to scrub username's and passwords. That's by choice, for usernames, because historically in PostgreSQL usernames can be stored in any encoding, but SASLPrep assumes UTF-8. We dodge that by passing an empty username in the authentication exchange anyway, because we always use the username we got from the startup packet. But for passwords, I think we need to fix that. The spec is very clear on that: > Note that implementations MUST either implement SASLprep or disallow > use of non US-ASCII Unicode codepoints in "str". 2. I think we should check nonces, etc. more carefully, to not contain invalid characters. For example, in the server, we use the read_attr_value() function to read the client's nonce. Per the spec, the nonce should consist of ASCII printable characters, but we will accept anything except the comma. That's no trouble to the server, but let's be strict. To summarize, here's the overall TODO list so far: * Use SASLPrep for passwords. * Check nonces, etc. to not contain invalid characters. * Derive mock SCRAM verifier for non-existent users deterministically from username. * Allow plain 'password' authentication for users with a SCRAM verifier in rolpassword. * Throw an error if an "authorization identity" is given. ATM, we just ignore it, but seems better to reject the attempt than do something that might not be what the client expects. * Add "scram-sha-256" prefix to SCRAM verifiers stored in pg_authid.rolpassword. Anything else I'm missing? I've created a wiki page, mostly to host that TODO list, while we hack this to completion: https://wiki.postgresql.org/wiki/SCRAM_authentication. Feel free to add stuff that comes to mind, and remove stuff as you push patches to the branch on github. - Heikki -- Sent via pgsql-hackers mailing list (pgsql-hackers@postgresql.org) To make changes to your subscription: http://www.postgresql.org/mailpref/pgsql-hackers