Re: [TLS] Servers respond with BadRecordMac after ClientFinished, sent when PSK+EarlyData

Kristijan Sedlak <xpepermint@gmail.com> Wed, 10 August 2022 05:49 UTC

Return-Path: <xpepermint@gmail.com>
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 3F82DC147920 for <tls@ietfa.amsl.com>; Tue, 9 Aug 2022 22:49:04 -0700 (PDT)
X-Virus-Scanned: amavisd-new at amsl.com
X-Spam-Flag: NO
X-Spam-Score: -2.104
X-Spam-Level:
X-Spam-Status: No, score=-2.104 tagged_above=-999 required=5 tests=[BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, FREEMAIL_FROM=0.001, HTML_MESSAGE=0.001, RCVD_IN_ZEN_BLOCKED_OPENDNS=0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01, URIBL_BLOCKED=0.001, URIBL_DBL_BLOCKED_OPENDNS=0.001, URIBL_ZEN_BLOCKED_OPENDNS=0.001] autolearn=ham autolearn_force=no
Authentication-Results: ietfa.amsl.com (amavisd-new); dkim=pass (2048-bit key) header.d=gmail.com
Received: from mail.ietf.org ([50.223.129.194]) by localhost (ietfa.amsl.com [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id 4WhpkyjCwnS6 for <tls@ietfa.amsl.com>; Tue, 9 Aug 2022 22:49:00 -0700 (PDT)
Received: from mail-ej1-x631.google.com (mail-ej1-x631.google.com [IPv6:2a00:1450:4864:20::631]) (using TLSv1.3 with cipher TLS_AES_128_GCM_SHA256 (128/128 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by ietfa.amsl.com (Postfix) with ESMTPS id 91E98C14F74D for <tls@ietf.org>; Tue, 9 Aug 2022 22:49:00 -0700 (PDT)
Received: by mail-ej1-x631.google.com with SMTP id a7so25835853ejp.2 for <tls@ietf.org>; Tue, 09 Aug 2022 22:49:00 -0700 (PDT)
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=references:to:cc:in-reply-to:date:subject:mime-version:message-id :from:from:to:cc; bh=6HnRwbvZ7fsXyx1GhMIOr4ZD80WdErRjeYIAfLzN/Hs=; b=Yy+Xmv7DHYGT6yMQ9eR6MInkz0iDJepJD8/fECkSwW8dpJ1w0ka2sJpdiVTY3y1DeD AipFkDuS8cdde5NTE/7XkF6uB8r2AwZauVpt4cALhBa8Wr3pvbqcc4oEFv0gAjhbOr9W kf7QqpAzn2+BGuXARN2iPDBmgxNkTGW3MoUlNI+XIk3w5XymzS1kaf9C9cIdyymIhPYF 5yumkq1GBl5K86WajHA+kb/UYobEr0d4jq15VEjhfEm0kNQf0GWesRWeeACkfbBT5QlR BNPL4xQ0nTnqcL1HX16oe6m1Zn6ZfSxyn32n4xORsiIlFU8jbduQHNgJfdy4yBFlN1pk kWAg==
X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=references:to:cc:in-reply-to:date:subject:mime-version:message-id :from:x-gm-message-state:from:to:cc; bh=6HnRwbvZ7fsXyx1GhMIOr4ZD80WdErRjeYIAfLzN/Hs=; b=YMtneIhzHy2SUO8/Dxw7Ne6/gDGcPPJHeq71g9hffVbSBXTCk8qaRi3AzWgRxVpgHr lu7f/wPPx+3d899h7syY8L/B+DC203TW10LIgtnAW+8Jh+ZMS0KWBY+chc+7SKdHjI0F biYn/8WPomk1bvZ0htK9RqQmokqQYmJy5TblwYuCKUd3iPYgIaR/KDo1RyPxzND9QWY+ 0w0sy9BfPGwXDhZmSWE0w4/H8zqREmtyUSqFUG+Zi8ZsGqiOIvGx+KYtE7rW65FMOtew W2PuT1p7Ur3nTpmmcdK1bnSMTYc92lAGBYHv7NvYAqyAde/MQhWw5l+2EO410RbMrmmi sOiw==
X-Gm-Message-State: ACgBeo2BbPf3oD/Jnr4w4UnLP1X1BOWZBGlqFnDREM0yA3Dx811YGomq YhzZ5e5y9HYMpMPRVMg/ppU=
X-Google-Smtp-Source: AA6agR5o6qe0KdAOyv+mGQc9wPnmt7dyiCoN830YZQ6n4O4RdsvDsl7xJIjufE8lICnYRRk/0vRb9A==
X-Received: by 2002:a17:907:9726:b0:730:9e04:f738 with SMTP id jg38-20020a170907972600b007309e04f738mr19195317ejc.631.1660110538770; Tue, 09 Aug 2022 22:48:58 -0700 (PDT)
Received: from smtpclient.apple (84-255-199-63.static.t-2.net. [84.255.199.63]) by smtp.gmail.com with ESMTPSA id i26-20020a17090685da00b0073087140945sm1880835ejy.123.2022.08.09.22.48.56 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Tue, 09 Aug 2022 22:48:57 -0700 (PDT)
From: Kristijan Sedlak <xpepermint@gmail.com>
Message-Id: <766267FF-2935-4E4E-90CF-1696A173EBAD@gmail.com>
Content-Type: multipart/alternative; boundary="Apple-Mail=_59194AA8-FBB9-4189-94D9-1009F141075A"
Mime-Version: 1.0 (Mac OS X Mail 16.0 \(3696.120.41.1.1\))
Date: Wed, 10 Aug 2022 07:48:56 +0200
In-Reply-To: <CABcZeBNS1EUVr9zVsYq26rXWebUZHEY3GJ-R5FDW--YnMTe3Ug@mail.gmail.com>
Cc: Ilari Liusvaara <ilariliusvaara@welho.com>, tls@ietf.org
To: Eric Rescorla <ekr@rtfm.com>
References: <987212E5-9A26-4408-9BD5-2D26FA106D3F@gmail.com> <YvID85L+ICWVh9gi@LK-Perkele-VII2.locald> <CABcZeBNS1EUVr9zVsYq26rXWebUZHEY3GJ-R5FDW--YnMTe3Ug@mail.gmail.com>
X-Mailer: Apple Mail (2.3696.120.41.1.1)
Archived-At: <https://mailarchive.ietf.org/arch/msg/tls/it4K_xxzfcN9yJ6MoGqJMLvZf_0>
Subject: Re: [TLS] Servers respond with BadRecordMac after ClientFinished, sent when PSK+EarlyData
X-BeenThere: tls@ietf.org
X-Mailman-Version: 2.1.39
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: Wed, 10 Aug 2022 05:49:04 -0000

@Eric Are you referring to this " ... completing the handshake with EndOfEarlyData following (which follows) the ClientFinished ..."? Well, I meant EOED and then ClientFinished. Anyhow, the client part seems to do it correctly.

Thx,
Kristijan

> On 10 Aug 2022, at 00:05, Eric Rescorla <ekr@rtfm.com> wrote:
> 
> 
> 
> On Mon, Aug 8, 2022 at 11:52 PM Ilari Liusvaara <ilariliusvaara@welho.com <mailto:ilariliusvaara@welho.com>> wrote:
> On Mon, Aug 08, 2022 at 08:15:41PM +0200, Kristijan Sedlak wrote:
> > Hello everyone. 
> > 
> > I decided to get involved here since I hit a dead end when resolving
> > an Alert(20) error that I get from almost all servers when using PSK
> > with EarlyData.
> > 
> > Here's the initial issue I opened https://github.com/thekuwayama/tttls1.3/issues/48 <https://github.com/thekuwayama/tttls1.3/issues/48>.
> > It relates to a specific implementation but my questions are general.
> > There's also a code snippet that you can run and see the issue
> > yourself.
> > 
> > So it happens that when sending a GET request as EarlyData and then
> > completing the handshake with EndOfEarlyData following the
> > ClientFinished message, a server (e.g. ssltest.louis.info <http://ssltest.louis.info/>)
> > successfully sends a complete response but finishes the request with
> > Alert(20) message. It doesn't happen on 1-RTT nor 0-RTT(without early
> > data). If I don't send ClientFinished in 0-RTT+EarlyData I don't get
> > Alert(20) and everything works as expected.
> > 
> > I don't see anything in the spec that would describe something like
> > this or would point to a different way for calculating the
> > ClientFinished for 0-RTT+EarlyData case. Is maybe this sentence from
> > the spec "PSK-based authentication happens as a side effect of key
> > exchange." something that some of us miss interpreter and states
> > that Finished message should be verified and sent only in 1-RTT? 
> >
> > What could be the case here?
> 
> Wild guess, the transcript is not computed over correct messages or in
> correct order.
> 
> 
> When server accepts early data, the sequence of messages client sends
> is:
> 
> - ClientHello
> - (0-RTT data)
> - EndOfEarlyData
> - client Finished
> 
> I just want to flag this in case it got missed. EOED precedes ClientFinished, but your original
> message says the opposite.
> 
> -Ekr
>  
> 
> And the sequence of messages in transcript used to compute the client
> finished is (note the EoED, RFC 8446 section 4.4.1 is very explicit
> about it):
> 
> - ClientHello
> - ServerHello
> - EncryptedExtensions
> - server Finished
> - EndOfEarlyData
> 
> 
> (This assumes there is no extension that would add new messages in
> play. There can not be HelloRetryRequest because that implicitly
> rejects early data.)
> 
> 
> 
> -Ilari
> 
> _______________________________________________
> TLS mailing list
> TLS@ietf.org <mailto:TLS@ietf.org>
> https://www.ietf.org/mailman/listinfo/tls <https://www.ietf.org/mailman/listinfo/tls>