Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtp (Exim 4.84_2) (envelope-from ) id 1cxVp6-0002JP-6X for pgsql-hackers@arkaria.postgresql.org; Mon, 10 Apr 2017 09:41:24 +0000 Received: from localhost ([127.0.0.1] helo=postgresql.org) by malur.postgresql.org with smtp (Exim 4.84_2) (envelope-from ) id 1cxVp5-0004cD-Lv for pgsql-hackers@arkaria.postgresql.org; Mon, 10 Apr 2017 09:41:23 +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 1cxVnX-0005bX-37 for pgsql-hackers@postgresql.org; Mon, 10 Apr 2017 09:39:47 +0000 Received: from mail-wm0-x232.google.com ([2a00:1450:400c:c09::232]) by magus.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.84_2) (envelope-from ) id 1cxVnT-0006nJ-LE for pgsql-hackers@postgresql.org; Mon, 10 Apr 2017 09:39:46 +0000 Received: by mail-wm0-x232.google.com with SMTP id y18so7629333wmh.0 for ; Mon, 10 Apr 2017 02:39:43 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=8kdata-com.20150623.gappssmtp.com; s=20150623; h=to:from:subject:message-id:date:user-agent:mime-version :content-transfer-encoding; bh=vy3DnaG/Fordv96WsDQ7OHrMBs7d9CH7L1FPkj+yqIk=; b=DckHCSdlQ24gIWBg/jX0N6lapExb4IwgdlUlao8hbb1MGo1BjnO3lokdM3DDhQurF+ cXmyI0jH3wqeYWN8Wilt4q1S9RP5jyyUSL9pXXKtTotaiQpl3EKTx5/tOAVjNced3r+t GjfjkUmEdi1WoZi34u6BFAGwkV77NUSm1ya95a0RktTURSZiDbr/ZNlZ3F9ZSW81aRzr 3G9ImaJ7QK9KxS+ZYme5hWsXuDNlrfNUwYQ/WDPcZpx1VFmFiMdGOkCPnisFF2DOj7PM SJpKV3jn7s0Zhx2i8725YQ3WVsukcq01l7ykz8aR/yphKS+wrgQ/szagplaeerOBSDtK DFsA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:to:from:subject:message-id:date:user-agent :mime-version:content-transfer-encoding; bh=vy3DnaG/Fordv96WsDQ7OHrMBs7d9CH7L1FPkj+yqIk=; b=lREtGP+Jv6FPggYcQBYPb45Sz662g19ATGiCJiGIexQRxkwG8Mfl9UmvDW6i4xYye9 PovtFVD/XeFHD13q1z2NIJ1yqTtvokMiHebWt0ukVFi8Oimj18lw1Hejkuo9kFMUXxY+ YLIaPn2wCMgtC+5m1PGr2CTDFEwfN/GQEPU7+WdCkIwXPJVl0Zh6TiaW8mx95o8mnplO HKJ8VlAxWTss3Kx4MP2BQEtGm1FY6ME/Wad5wOSkvDO6e4wPwEczWsJWhfDQ4TWdSsDk wixRrsZshi3aqez+ecH4Cs0jnQ4qMn+sCV2Z3vB9aaJOUvfC7nXS2yBI7Scq1LEQoibb MpEg== X-Gm-Message-State: AN3rC/6aOzlfRgv1ZHC1s42YAMe0Dcua8dWjWZfWR5St/TYE/ZmEBoUy /Ub0fya/KmVsC/bMas8= X-Received: by 10.28.15.69 with SMTP id 66mr9257484wmp.105.1491817182284; Mon, 10 Apr 2017 02:39:42 -0700 (PDT) Received: from [10.0.10.100] (92.red-83-40-76.dynamicip.rima-tde.net. [83.40.76.92]) by smtp.gmail.com with ESMTPSA id 81sm9576298wmj.9.2017.04.10.02.39.41 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 10 Apr 2017 02:39:41 -0700 (PDT) To: pgsql-hackers From: =?UTF-8?Q?=c3=81lvaro_Hern=c3=a1ndez_Tortosa?= Subject: Some thoughts about SCRAM implementation Message-ID: Date: Mon, 10 Apr 2017 11:39:41 +0200 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:45.0) Gecko/20100101 Thunderbird/45.8.0 MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8; format=flowed Content-Transfer-Encoding: 8bit X-Pg-Spam-Score: -1.8 (-) 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 Hi! There's some ongoing discussion about SCRAM (like this thread https://www.postgresql.org/message-id/243d8c11-6149-a4bb-0909-136992f74b23%40iki.fi) but I wanted to open a new thread that covers these topics and other, more general ones. Here are some thoughts based on my perspective on SCRAM, which I gained thanks to studying it as part of the effort to implement SCRAM in the JDBC driver. FYI, some very early code can be found here: https://github.com/ahachete/scram. Although there's still a lot to do, I'm doing great progress and I expect to have a working version within 2 weeks. So here's what I think: - Work so far is great. Thanks Heikki, Michael and others for the effort involved. I love to have SCRAM support in Postgres! - I think channel binding support should be added. SCRAM brings security improvements over md5 and other simpler digest algorithms. But where it really shines is together with channel binding. This is the only method to prevent MITM attacks. Implementing it should not very difficult. There are several possible channel binding mechanisms, but the mandatory and probably more typical one is 'tls-unique' which basically means getting the byte array from the TLSfinish() message and comparing it with the same data sent by the client. That's more or less all it takes to implement it. So I would go for it. - One SCRAM parameter, i, the iteration count, is important, and in my opinion should be configurable. AFAIK it is currently hard coded at 4096, which is the minimum value accepted by the RFC. But it should be at least 15K (RFC says), and given that it affects computing time of the authentication, it should be configurable. It's also now specified per user, which I think its too much granularity (it should suffice to say this group of users all require this iteration count). - The SCRAM RFC states that server should advertise supported mechanisms. I see discussion going into not advertising them. I think it should be done, I don't see reasons not to do it, and it will become compliant with the RFC. - I don't see why proposed scram mechanism names for pg_hba.conf are not following the IANA Registry standard ( https://www.iana.org/assignments/sasl-mechanisms/sasl-mechanisms.xhtml#scram), which is uppercase (like in SCRAM-SHA-256). - SCRAM also supports the concept of authzid, which is kind of what pg_ident does: authenticate the user as the user sent, but login as the user specified here. It could also be supported. Based on these comments, I'd like to propose the following changes: * Implement channel binding. * Add a GUC for the channel binding technique to use. It could be named as "scram_channel_binding_name" or "sasl_channel_binding_name", for example. And probably supported value as of today, 'tls-unique'. * AuthenticationSASL backend message: - The String field make it a CSV that would be a list of one or more supported IANA SCRAM authentication methods. This info comes from pg_scram.conf (see below). - Add another String to specify the variety of channel binding supported (if any), like 'tls-unique'. This info comes from the GUC. * Treat the configuration of scram in pg_hba.conf, which seems complicated, similarly to how pg_ident.conf is treated. Basically in pg_hba.conf specify a "scram=scram_entry_name" value and then look for a pg_scram.conf file for an entry with that name. The pg_scram.conf might have the following structure: name | scram_mechanisms | i scramlight | SCRAM-SHA-1 | 4096 scramstrong | SCRAM-SHA-256,SCRAM-SHA-256-PLUS | 16384 * The nonce length is not specified by the RFC. I see typical implementations use 24 chars for the client and 18 for the server. Current code uses 10. I think it should not hurt making it at least 16 or 18. * It seems to me that the errors defined by the RFC, sent on the server-final-message if there were errors, are never sent with the current implementation. I think they should be sent as per the standard, and also proceed until the last stage even if errors were detected earlier (to conform with the RFC). Thoughts? Álvaro -- Álvaro Hernández Tortosa ----------- <8K>data -- Sent via pgsql-hackers mailing list (pgsql-hackers@postgresql.org) To make changes to your subscription: http://www.postgresql.org/mailpref/pgsql-hackers