Ignore retry packets that arrive too late
authorMatt Caswell <matt@openssl.org>
Tue, 17 Oct 2023 15:26:13 +0000 (16:26 +0100)
committerTomas Mraz <tomas@openssl.org>
Thu, 19 Oct 2023 09:53:07 +0000 (11:53 +0200)
RFC 9000 s 17.2.5.2 says

> After the client has received and processed an Initial or Retry packet
> from the server, it MUST discard any subsequent Retry packets that it
> receives.

We were checking for multiple Retry packets, but not if we had already
processed an Initial packet.

Fixes the assertion failure noted in
https://github.com/openssl/openssl/pull/22368#issuecomment-1765618884

Reviewed-by: Hugo Landau <hlandau@openssl.org>
Reviewed-by: Tomas Mraz <tomas@openssl.org>
(Merged from https://github.com/openssl/openssl/pull/22411)

ssl/quic/quic_channel.c

index 3da0caa4ea63b9cdf4cb3fa4c239b65569e2cdbc..a6ed14664eae7370173e24e871e9d85a242e077b 100644 (file)
@@ -2220,6 +2220,14 @@ static void ch_rx_handle_packet(QUIC_CHANNEL *ch)
              */
             return;
 
+        /*
+         * RFC 9000 s 17.2.5.2: After the client has received and processed an
+         * Initial or Retry packet from the server, it MUST discard any
+         * subsequent Retry packets that it receives.
+         */
+        if (ch->have_received_enc_pkt)
+            return;
+
         if (ch->qrx_pkt->hdr->len <= QUIC_RETRY_INTEGRITY_TAG_LEN)
             /* Packets with zero-length Retry Tokens are invalid. */
             return;