BUG/MINOR: quic: use proper error code on invalid received TP value
authorAmaury Denoyelle <adenoyelle@haproxy.com>
Tue, 6 May 2025 16:00:43 +0000 (18:00 +0200)
committerChristopher Faulet <cfaulet@haproxy.com>
Tue, 20 May 2025 16:09:22 +0000 (18:09 +0200)
As per RFC 9000, checks must be implemented to reject invalid values for
received transport parameters. Such values are dependent on the
parameter type.

Checks were already implemented for ack_delay_exponent and
active_connection_id_limit, accordingly with the QUIC specification.
However, the connection was closed with an incorrect error code. Fix
this to ensure that TRANSPORT_PARAMETER_ERROR code is used as expected.

This should be backported up to 2.6. Note that is relies on previous
patch "MINOR: quic: extend return value on TP parsing".

(cherry picked from commit b60a17aad768369ab7e328949112b50cd78bc987)
Signed-off-by: Willy Tarreau <w@1wt.eu>
(cherry picked from commit af4048e4e36503557d90e37514a8a3e8e7210c03)
Signed-off-by: Christopher Faulet <cfaulet@haproxy.com>

src/quic_tp.c

index 33408ff..618cab1 100644 (file)
@@ -314,9 +314,17 @@ quic_transport_param_decode(struct quic_transport_params *p, int server,
                        return QUIC_TP_DEC_ERR_TRUNC;
                break;
        case QUIC_TP_ACK_DELAY_EXPONENT:
-               if (!quic_dec_int(&p->ack_delay_exponent, buf, end) ||
-                       p->ack_delay_exponent > QUIC_TP_ACK_DELAY_EXPONENT_LIMIT)
+               if (!quic_dec_int(&p->ack_delay_exponent, buf, end))
                        return QUIC_TP_DEC_ERR_TRUNC;
+
+               /* RFC 9000 18.2. Transport Parameter Definitions
+                *
+                * ack_delay_exponent (0x0a): [...]
+                * Values above 20 are invalid.
+                */
+               if (p->ack_delay_exponent > QUIC_TP_ACK_DELAY_EXPONENT_LIMIT)
+                       return QUIC_TP_DEC_ERR_INVAL;
+
                break;
        case QUIC_TP_MAX_ACK_DELAY:
                if (!quic_dec_int(&p->max_ack_delay, buf, end) ||
@@ -634,12 +642,16 @@ quic_transport_params_decode(struct quic_transport_params *p, int server,
                return QUIC_TP_DEC_ERR_INVAL;
        }
 
-       /* Note that if not received by the peer, active_connection_id_limit will
-        * have QUIC_TP_DFLT_ACTIVE_CONNECTION_ID_LIMIT as default value. This
-        * is also the minimum value for this transport parameter.
+       /* RFC 9000 18.2. Transport Parameter Definitions
+        *
+        * active_connection_id_limit (0x0e):
+        * [...] The value of the
+        * active_connection_id_limit parameter MUST be at least 2. An
+        * endpoint that receives a value less than 2 MUST close the
+        * connection with an error of type TRANSPORT_PARAMETER_ERROR.
         */
        if (p->active_connection_id_limit < QUIC_TP_DFLT_ACTIVE_CONNECTION_ID_LIMIT)
-               return QUIC_TP_DEC_ERR_TRUNC;
+               return QUIC_TP_DEC_ERR_INVAL;
 
        return QUIC_TP_DEC_ERR_NONE;
 }