Re: Negotiating the SCRAM channel binding type

From: Michael Paquier <michael(at)paquier(dot)xyz>
To: Heikki Linnakangas <hlinnaka(at)iki(dot)fi>
Cc: pgsql-hackers <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: Negotiating the SCRAM channel binding type
Date: 2018-07-12 04:14:10
Message-ID: 20180712041410.GC7352@paquier.xyz
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

On Wed, Jul 11, 2018 at 03:01:03PM +0300, Heikki Linnakangas wrote:
> That would be more complicated to parse. Yeah, we might need further options
> for some SASL mechanisms in the future, but we can cross that bridge when we
> get there. I don't see any need to complicate this case for that.

Okay, fine for me.

> I started digging into this more closely, and ran into a little problem. If
> channel binding is not used, the client sends a flag to the server to
> indicate if it's because the client doesn't support channel binding, or
> because it thought that the server doesn't support it. This is the
> gs2-cbind-flag. How should the flag be set, if the server supports channel
> binding type A, while client supports only type B? The purpose of the flag
> is to detect downgrade attacks, where a man-in-the-middle removes the PLUS
> variants from the list of supported mechanisms. If we treat incompatible
> channel binding types as "client doesn't support channel binding", then the
> downgrade attack becomes possible (the attacker can replace the legit PLUS
> variants with bogus channel binding types that the client surely doesn't
> support). If we treat it as "server doesn't support channel binding", then
> we won't downgrade to the non-channel-binding variant, in the legitimate
> case that the client and server both support channel binding, but with
> incompatible types.
>
> What we'd really want, is to include the full list of server's supported
> mechanisms as part of the exchange, not just a boolean "y/n" flag. But
> that's not what the spec says :-(.

Let's not break the spec :) I understand from it that the client is in
charge of the choice, so we are rather free to choose the reaction the
client should have. In the second phase of the exchange, the client
communicates back to the server the channel binding it has decided to
choose, it is not up to the server to pick up one if the client thinks
that it can use multiple ones.

> I guess we should err on the side of caution, and fail the authentication in
> that case. That's unfortunate, but it's better than not negotiating at all.
> At least with the negotiation, the authentication will work if there is any
> mutually supported channel binding type.

I think that in this case the client should throw an error
unconditionally if it wants to use channel A but server supports only B.
It is always possible for the client to adjust the channel binding type
it wants to use by using the connection parameter scram_channel_binding,
or to recompile. If there is incompatibility between channel binding
types, it would actually mean that the client and the server are not
compiled with the same SSL implementation, would that actually work? Say
a server has only tls-unique with gnu's library and the client uses JDBC
which only has tls-server-end-point..

So, to keep things simple, it seems to me that we should just make the
server send the list, and then check at client-level if the list sent by
server includes what the client wants to use, complaining if the option
is not present.
--
Michael

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Ashutosh Bapat 2018-07-12 04:38:13 Re: Expression errors with "FOR UPDATE" and postgres_fdw with partition wise join enabled.
Previous Message Nico Williams 2018-07-12 04:07:14 Re: How can we submit code patches that implement our (pending) patents?