Re: [TLS] Server validation of a second ClientHello

Martin Thomson <mt@lowentropy.net> Sun, 10 February 2019 23:43 UTC

Return-Path: <mt@lowentropy.net>
X-Original-To: tls@ietfa.amsl.com
Delivered-To: tls@ietfa.amsl.com
Received: from localhost (localhost [127.0.0.1]) by ietfa.amsl.com (Postfix) with ESMTP id D4D271295D8 for <tls@ietfa.amsl.com>; Sun, 10 Feb 2019 15:43:43 -0800 (PST)
X-Virus-Scanned: amavisd-new at amsl.com
X-Spam-Flag: NO
X-Spam-Score: -2.701
X-Spam-Level:
X-Spam-Status: No, score=-2.701 tagged_above=-999 required=5 tests=[BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, RCVD_IN_DNSWL_LOW=-0.7, SPF_PASS=-0.001] autolearn=ham autolearn_force=no
Authentication-Results: ietfa.amsl.com (amavisd-new); dkim=pass (2048-bit key) header.d=lowentropy.net header.b=QYoLSYoj; dkim=pass (2048-bit key) header.d=messagingengine.com header.b=rzS5kEzG
Received: from mail.ietf.org ([4.31.198.44]) by localhost (ietfa.amsl.com [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id gtvLcSDVGw-h for <tls@ietfa.amsl.com>; Sun, 10 Feb 2019 15:43:41 -0800 (PST)
Received: from out2-smtp.messagingengine.com (out2-smtp.messagingengine.com [66.111.4.26]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by ietfa.amsl.com (Postfix) with ESMTPS id 92A7012958B for <tls@ietf.org>; Sun, 10 Feb 2019 15:43:41 -0800 (PST)
Received: from compute1.internal (compute1.nyi.internal [10.202.2.41]) by mailout.nyi.internal (Postfix) with ESMTP id 40297216A6; Sun, 10 Feb 2019 18:43:40 -0500 (EST)
Received: from web3 ([10.202.2.213]) by compute1.internal (MEProxy); Sun, 10 Feb 2019 18:43:40 -0500
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=lowentropy.net; h=message-id:from:to:cc:mime-version:content-transfer-encoding :content-type:subject:references:date:in-reply-to; s=fm1; bh=Rvp z2kwsMn285tI3tRhPUUko8EuKRjAnWUU63IwMrL4=; b=QYoLSYojnLxSw7jJwTY DogQ9sIhBaL8/U8Xn6cenZYPqVR1Wutyq49DHuKTevlnBJDAYBCSgbLHvQ73U2Fy f85uUqqAKxgUl0NGsFm5n7It9tvWjX6SQksTQjtTYQq0q3gsJqXpJfynFER1Ur56 E1rV28B9gtXKYapgagJC7FRwY0C1NdHKpFs5pgeSpQy4id/u6gULTbV0VaY5GLik FRgH0Obs3MKCuzYgG+KsECq8X4jIzmKocf+ESmM9sOXNep6YygO8PUFe3xhWl8wl HyNegBnHGIWzHitcE6BwUTV4GyepN+MNriw01mGVBVqaS/stIH+tcR3iWK/S5hBc DdQ==
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=cc:content-transfer-encoding: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=Rvpz2kwsMn285tI3tRhPUUko8EuKRjAnWUU63IwMr L4=; b=rzS5kEzGJMpTH/Ko4Iv7DXSu/0grC7p4jR/2h4KO65qnRCkCKjKX334UV V6BueDpbHJ3MSeEmw86OG19Ya9kvxl3pDNn61dgtwRPAARmIeeamgP93mPYoXYcz of8/vsXGPP8Qcqi/jH5mAZMZsoiVff3s90A8jPvDXDFwzV1oPiSYi2xRju4GQhO4 MgABV47/Q5H4VKr9W8vImLEQfUPAN0ZLPUPEVgup3DmXt0Aye9oJw2AezG26jNEH 4wF+11aUhaUEutJPgbq3W/UlbSHK2peCNWHMQ7xpzj1Qe2SBdV+DV0sud+pgSJgo CV4J2lYTgsZDCHpKL0uQ6wtVoY6zw==
X-ME-Sender: <xms:K7dgXPfOdgK7F2uazFy22lM8ea1DRmgqv-T-Uj5SsJWo1QzuHATg6w>
X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgedtledrleejgdduvdcutefuodetggdotefrodftvf curfhrohhfihhlvgemucfhrghsthforghilhdpqfhuthenuceurghilhhouhhtmecufedt tdenucesvcftvggtihhpihgvnhhtshculddquddttddmnecujfgurhepkffhvfgggfgtof fufhffjgesthejredtredtjeenucfhrhhomhepofgrrhhtihhnucfvhhhomhhsohhnuceo mhhtsehlohifvghnthhrohhphidrnhgvtheqnecurfgrrhgrmhepmhgrihhlfhhrohhmpe hmtheslhhofigvnhhtrhhophihrdhnvghtnecuvehluhhsthgvrhfuihiivgeptd
X-ME-Proxy: <xmx:K7dgXBCIXtfqyyS8N5MwuztK2MdreijjllLGqhBqVYbgAlWLqBGmUg> <xmx:K7dgXP18GyvXzbBYc3Sx3rn_ahTqSq3H8bpU3xFC0CAubeXeXobtkQ> <xmx:K7dgXENpxqlNf5YCHT4lDSqyNc-mcDTCips0K-9y5VHo8qLBmSG_ow> <xmx:LLdgXPJVN4ClT8u9K4Pot8-ozBPX18JA8KP96LOmOKhB65Cig-RFiw>
Received: by mailuser.nyi.internal (Postfix, from userid 99) id 8C9F09E567; Sun, 10 Feb 2019 18:43:39 -0500 (EST)
Message-Id: <1549842219.465443.1655100776.7BADB4DA@webmail.messagingengine.com>
From: Martin Thomson <mt@lowentropy.net>
To: Hubert Kario <hkario@redhat.com>
Cc: tls@ietf.org
MIME-Version: 1.0
Content-Transfer-Encoding: 7bit
Content-Type: text/plain; charset="utf-8"
X-Mailer: MessagingEngine.com Webmail Interface - ajax-e6290ad1
References: <1549596678.898774.1653407000.2B2ACE8E@webmail.messagingengine.com> <3192766.6rApcoU5jf@pintsize.usersys.redhat.com>
Date: Mon, 11 Feb 2019 10:43:39 +1100
In-Reply-To: <3192766.6rApcoU5jf@pintsize.usersys.redhat.com>
Archived-At: <https://mailarchive.ietf.org/arch/msg/tls/9hpQvanfXh_WMNb7xBQPgTsCsko>
Subject: Re: [TLS] Server validation of a second ClientHello
X-BeenThere: tls@ietf.org
X-Mailman-Version: 2.1.29
Precedence: list
List-Id: "This is the mailing list for the Transport Layer Security working group of the IETF." <tls.ietf.org>
List-Unsubscribe: <https://www.ietf.org/mailman/options/tls>, <mailto:tls-request@ietf.org?subject=unsubscribe>
List-Archive: <https://mailarchive.ietf.org/arch/browse/tls/>
List-Post: <mailto:tls@ietf.org>
List-Help: <mailto:tls-request@ietf.org?subject=help>
List-Subscribe: <https://www.ietf.org/mailman/listinfo/tls>, <mailto:tls-request@ietf.org?subject=subscribe>
X-List-Received-Date: Sun, 10 Feb 2019 23:43:44 -0000

On Fri, Feb 8, 2019, at 23:53, Hubert Kario wrote:
> given need for GREASE and two dozen flags across OpenSSL history for 
> workarounds for bugs in different implementations, the lesson seems to be that 
> the receiving side should be as strict as it can (within protocol confines) or 
> we risk making the non-conforming behaviour common

I take something different from that experience.  There is value in having some implementations do strict checks, certainly.  However, in this case, I don't believe that it is reasonable to perform these checks (more below).
  
> > With that answer in mind, if the second ClientHello might differ, I assert
> > that the server uses that.  Hubert observes that this behaviour is not
> > specified at all, which is entirely true.  I think that using the first
> > ClientHello would be nonsensical, because the server needs to use the
> > second ClientHello for those extensions that can change, like key share.
> 
> And I say that when you have already parsed, verified and sanity-checked the 
> first set of extensions, it is much saner to reuse that work and only update 
> the values that can change and ignore all other extensions...

As I mentioned, NSS does that work, at least partially, and then throws all of that state away when it sends HelloRetryRequest.  It does that so that HelloRetryRequest can be truly stateless (an advantage for DTLS).  Doing that work all over is trivial, bundling the necessary state, not.
 
> There are multiple ways to look at this, and given that the standard is very 
> firm that the 2nd CH needs to be as similar to the first one as possible, it 
> is thus silent on which takes precedence in case they differ in general, 
> because they can't.

> > If we require or allow checking - and I think that we should definitely
> > allow a check - the details of the conditions under which a check might
> > fail aren't completely obvious for new extensions.  A new extension might
> > be defined that has special handling in HelloRetryRequest, so it might be
> > reasonable to allow new extensions to be changed.
> 
> yes, and we already had discussion on this ML about this: if the extension 
> needs to change (based on protocol definition), the server MUST include it in 
> HRR to signal to client, "yes, I do know about it, you can update it" and 
> client MUST NOT change it otherwise

I remember having that discussion, but I guess the only way it made it into the spec was as:

   -  Other modifications that may be allowed by an extension defined in
      the future and present in the HelloRetryRequest.

Which isn't particularly direct, but I guess that's enough.

> the cookie can be up to 2^16 bytes long, even if client sends all 50 
> extensions and spaces them with unknown extensions between, that's at most 20 
> bytes per extension = 1000 bytes total extra space needed in cookie (32 bytes 
> and 1600 bytes if you want to be very conservative)

Yeah, that's ridiculously large.  With quite a few extensions supported, and many more unknown to us, the only way we might realistically ensure that the ClientHello doesn't change is to save a hash snapshot at every boundary where the cookie extension might be inserted or where an extension might be changed.  SHA-2 has a fairly small state to capture, but that's still nearly unbounded state.  With an amplification factor of up to 8, meaning that it could be more efficient to send the client its entire ClientHello in the cookie.