From: deanliang06 Date: Mon, 30 Nov 2026 14:31:40 +0000 (-0500) Subject: BUG/MINOR: quic-be: install the peer CID only from an accepted Initial X-Git-Url: https://git.kaiwu.me/http/%22..//%22data:,/%22?a=commitdiff_plain;h=3ce902c740171c54600746d73fbfa8b0656a8f0f;p=haproxy.git BUG/MINOR: quic-be: install the peer CID only from an accepted Initial On backend QUIC connections, parsing an Initial header sets the peer CID before the packet is validated. If that packet is discarded, a later valid Initial cannot replace the CID. If the CIDs differ, the backend handshake can fail. Install the peer CID only after the Initial has been decrypted and its frames have been parsed. Preserve the existing Retry handling. This should be backported up to 3.3, where the bug was introduced by 2d076178c ("MINOR: quic-be: Store asap the DCID"). --- diff --git a/include/haproxy/quic_conn-t.h b/include/haproxy/quic_conn-t.h index 3b84b2db1..8570b42b1 100644 --- a/include/haproxy/quic_conn-t.h +++ b/include/haproxy/quic_conn-t.h @@ -464,7 +464,7 @@ struct quic_conn_closed { #define QUIC_FL_CONN_HPKTNS_DCD (1U << 16) /* Handshake packet number space discarded */ #define QUIC_FL_CONN_PEER_VALIDATED_ADDR (1U << 17) /* Peer address is considered as validated for this connection. */ #define QUIC_FL_CONN_NO_TOKEN_RCVD (1U << 18) /* Client dit not send any token */ -#define QUIC_FL_CONN_SCID_RECEIVED (1U << 19) /* (client only: first Initial received. */ +#define QUIC_FL_CONN_SCID_RECEIVED (1U << 19) /* (client only: first Initial accepted. */ #define QUIC_FL_CONN_XPRT_CLOSED (1U << 20) /* close callback of xprt layer already called */ /* gap here */ #define QUIC_FL_CONN_TO_KILL (1U << 24) /* Unusable connection, to be killed */ diff --git a/src/quic_rx.c b/src/quic_rx.c index 83c3fec0f..1bdb98fb7 100644 --- a/src/quic_rx.c +++ b/src/quic_rx.c @@ -1468,6 +1468,14 @@ int qc_treat_rx_pkts(struct quic_conn *qc) else { struct quic_arng ar = { .first = pkt->pn, .last = pkt->pn }; + if (pkt->type == QUIC_PACKET_TYPE_INITIAL && qc_is_back(qc) && + !(qc->flags & QUIC_FL_CONN_SCID_RECEIVED)) { + /* Adopt the peer CID only after accepting its Initial. */ + memcpy(qc->dcid.data, pkt->scid.data, pkt->scid.len); + qc->dcid.len = pkt->scid.len; + qc->flags |= QUIC_FL_CONN_SCID_RECEIVED; + } + /* RFC 9000 8.1. Address Validation during Connection Establishment * * Connection establishment implicitly provides address validation for @@ -2271,12 +2279,6 @@ static int quic_rx_pkt_parse(struct quic_conn *qc, struct quic_rx_packet *pkt, * ack-eliciting Initial packets to at least the smallest allowed maximum * datagram size of 1200 bytes. */ - if (!(qc->flags & QUIC_FL_CONN_SCID_RECEIVED)) { - qc->flags |= QUIC_FL_CONN_SCID_RECEIVED; - memcpy(qc->dcid.data, pkt->scid.data, pkt->scid.len); - qc->dcid.len = pkt->scid.len; - } - if (qc_is_back(qc)) { if (qc->flags & QUIC_FL_CONN_CLOSING) { TRACE_PROTO("Packet dropped",