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

Eric Rescorla <ekr@rtfm.com> Tue, 09 August 2022 22:06 UTC

Return-Path: <ekr@rtfm.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 D9B13C15790B for <tls@ietfa.amsl.com>; Tue, 9 Aug 2022 15:06:31 -0700 (PDT)
X-Virus-Scanned: amavisd-new at amsl.com
X-Spam-Flag: NO
X-Spam-Score: -1.903
X-Spam-Level:
X-Spam-Status: No, score=-1.903 tagged_above=-999 required=5 tests=[BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, HTML_MESSAGE=0.001, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_ZEN_BLOCKED_OPENDNS=0.001, SPF_HELO_NONE=0.001, SPF_NONE=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=rtfm-com.20210112.gappssmtp.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 JZTAjgDdth-k for <tls@ietfa.amsl.com>; Tue, 9 Aug 2022 15:06:28 -0700 (PDT)
Received: from mail-io1-xd30.google.com (mail-io1-xd30.google.com [IPv6:2607:f8b0:4864:20::d30]) (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 3B6B4C14EB1E for <tls@ietf.org>; Tue, 9 Aug 2022 15:06:28 -0700 (PDT)
Received: by mail-io1-xd30.google.com with SMTP id q124so10749725iod.3 for <tls@ietf.org>; Tue, 09 Aug 2022 15:06:28 -0700 (PDT)
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=rtfm-com.20210112.gappssmtp.com; s=20210112; h=cc:to:subject:message-id:date:from:in-reply-to:references :mime-version:from:to:cc; bh=M/y88rkKgSPTXmEZ6i0g87rOlVBGlxIljtkxSBlbKX4=; b=wg8xXadm1Z76jkDslzYWAvul4tGk17MruTkH75kOFT+QQu2/Ikpk1C/T2QNYHNUszv BqXizAdPUycfm7X72ziREQs+JAqAUMKaD2G4wBtSq0FdnT9F0xmkCOiI3hs+l/hNCZV+ PZCSN4Q6z+nIC+4Zwvhg+uhsofRBPTTD1Bke6joaMvxRTHTkWVJpDnsvM4bApVXdZe6v S6tB7rmhnU1mqTzTS0xb5kMJTxlC4bTZyMzW5qFois/yQQoeRK/LLnCJ+uIBuTwxBo5/ EqEH+X/DYpnm5OzY5XOAmZooKpNu7nWBptuvNqS630XAPT7hoA/I6qVIDgUeIfjBmUDO u9kA==
X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=cc:to:subject:message-id:date:from:in-reply-to:references :mime-version:x-gm-message-state:from:to:cc; bh=M/y88rkKgSPTXmEZ6i0g87rOlVBGlxIljtkxSBlbKX4=; b=iMYD1VnRDuT+c/hWUnKUkUtNEhDixWsY8JSlgLnj8OMNHlM8QAD5b8+SZAmuzxsLYc zOXFThk0oQEf1acKbQmAkppwaXvHqos3X51P6WyhoYCnHqdrLJVwHZVka3ER6i4/NovZ dzvNGvbdnb0Bt81XsBGEUOg7qCU4SR3dAdIe9bmIOPxoUTUjLewmj0y2lB0MBpMADlVV CzCG6fGw4dLrzrO41hqq+kFPlraVUO7p0EL2T89YG7X7AaJear5LdAvrltfpnmovlZta ZPmwCbZ4tg2Ywnv/y632edclGJ9c+IbKseaVnNkyHx7mLxWktVg+vRbZqqt4l9JvVN4o IOBA==
X-Gm-Message-State: ACgBeo3V2PHbdsG9qxJOvwKgkfBJiEC63/AmgCcI4ZW4aiTLrz9oRlV4 OEkyr17jwjgJi9zq5EW5Wkx7PUwKRVtnqT6IZGHS3w==
X-Google-Smtp-Source: AA6agR6JEjUZq9vktbGgw08W9z9RZ+3CU9mt8lswWSmYZWbn8tO9v+5SYd6JvPj90gO+rAKNZFablwm6DGqykoFKSe8=
X-Received: by 2002:a05:6602:154f:b0:67c:1de0:33b6 with SMTP id h15-20020a056602154f00b0067c1de033b6mr9758897iow.87.1660082787438; Tue, 09 Aug 2022 15:06:27 -0700 (PDT)
MIME-Version: 1.0
References: <987212E5-9A26-4408-9BD5-2D26FA106D3F@gmail.com> <YvID85L+ICWVh9gi@LK-Perkele-VII2.locald>
In-Reply-To: <YvID85L+ICWVh9gi@LK-Perkele-VII2.locald>
From: Eric Rescorla <ekr@rtfm.com>
Date: Tue, 09 Aug 2022 15:05:51 -0700
Message-ID: <CABcZeBNS1EUVr9zVsYq26rXWebUZHEY3GJ-R5FDW--YnMTe3Ug@mail.gmail.com>
To: Ilari Liusvaara <ilariliusvaara@welho.com>
Cc: Kristijan Sedlak <xpepermint@gmail.com>, tls@ietf.org
Content-Type: multipart/alternative; boundary="000000000000d7eec805e5d62429"
Archived-At: <https://mailarchive.ietf.org/arch/msg/tls/PqrtoC6e7vDTVbSx1pqONwNTCxI>
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: Tue, 09 Aug 2022 22:06:31 -0000

On Mon, Aug 8, 2022 at 11:52 PM Ilari Liusvaara <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.
> > 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)
> > 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
> https://www.ietf.org/mailman/listinfo/tls
>