]> git.kaiwu.me - nginx.git/commitdiff
QUIC: rejected NEW_CONNECTION_ID from a client with zero-length ids
authorVadim Zhestikov <v.zhestikov@f5.com>
Fri, 6 Nov 2026 21:42:48 +0000 (13:42 -0800)
committerSergey Kandaurov <pluknet@nginx.com>
Fri, 27 Nov 2026 14:30:38 +0000 (18:30 +0400)
A client that selected a zero-length connection id during the handshake
cannot issue new connection ids, and an endpoint sending packets with
a zero-length Destination Connection ID must treat receipt of
a NEW_CONNECTION_ID frame as a connection error of type
PROTOCOL_VIOLATION, see RFC 9000, 19.15.  Instead, the frame was
accepted and the connection id it carried was added to the client ids.

src/event/quic/ngx_event_quic_connid.c

index b76eaaa5fb71a37c22dcab371c587acb915dd576..aac4f761c7b1c3b1a3934cced902785c39142806 100644 (file)
@@ -81,6 +81,20 @@ ngx_quic_handle_new_connection_id_frame(ngx_connection_t *c,
 
     qc = ngx_quic_get_connection(c);
 
+    if (qc->path->cid->len == 0) {
+        /*
+         * RFC 9000, 19.15.  NEW_CONNECTION_ID Frames
+         *
+         *  An endpoint that is sending packets with a zero-length
+         *  Destination Connection ID MUST treat receipt of
+         *  a NEW_CONNECTION_ID frame as a connection error of type
+         *  PROTOCOL_VIOLATION.
+         */
+        qc->error = NGX_QUIC_ERR_PROTOCOL_VIOLATION;
+        qc->error_reason = "new connection id from client with zero-length id";
+        return NGX_ERROR;
+    }
+
     if (f->seqnum < qc->max_retired_seqnum) {
         /*
          * RFC 9000, 19.15.  NEW_CONNECTION_ID Frame