]> git.kaiwu.me - nginx.git/commitdiff
QUIC: fixed possible segfault on handshake failures.
authorJan Svojanovsky <jan.svojanovsky@cdn77.com>
Tue, 9 Dec 2025 11:27:02 +0000 (12:27 +0100)
committerSergey Kandaurov <s.kandaurov@f5.com>
Tue, 9 Dec 2025 17:25:10 +0000 (21:25 +0400)
When using OpenSSL 3.5, the crypto_release_rcd QUIC callback can be
called late, after the QUIC connection was already closed on handshake
failure, resulting in a segmentation fault.  For instance, it happened
if a client Finished message didn't align with a record boundary.

src/event/quic/ngx_event_quic_ssl.c

index a502431f42df1e7df76e9fb129579bb3a70374f0..18992ae1be6fc18d440f2cb19dd3788d8210c3c0 100644 (file)
@@ -185,7 +185,13 @@ ngx_quic_cbs_release_rcd(ngx_ssl_conn_t *ssl_conn, size_t bytes_read, void *arg)
     ngx_log_debug1(NGX_LOG_DEBUG_EVENT, c->log, 0,
                    "quic ngx_quic_cbs_release_rcd len:%uz", bytes_read);
 
+    /* already closed on handshake failure */
+
     qc = ngx_quic_get_connection(c);
+    if (qc == NULL) {
+        return 1;
+    }
+
     ctx = ngx_quic_get_send_ctx(qc, qc->read_level);
 
     cl = ngx_quic_read_buffer(c, &ctx->crypto, bytes_read);