Commit b09db769c0 for openssl.org
commit b09db769c06984df3e8f2aed8724fcb4ce9a3925
Author: Alexandr Nedvedicky <sashan@openssl.org>
Date: Wed Nov 4 23:58:13 2026 +0100
test/radix/quic_tests.c: test that retransmitted NEW_CONNECTION_ID frames are ignored
Add a test that sends 20 NEW_CONNECTION_ID frames with identical
sequence number. Only one should be hanled, the rest is ignored.
References: CVE-2026-107494
Co-authored-by: Andrew Dinh <andrewd@openssl.org>
Reviewed-by: Neil Horman <nhorman@openssl.org>
Reviewed-by: Bob Beck <beck@openssl.org>
Reviewed-by: Eugene Syromiatnikov <esyr@openssl.org>
Merge-date: Sun Nov 22 17:41:21 2026
Merged-from: https://github.com/openssl/openssl/pull/33544
diff --git a/test/radix/quic_tests.c b/test/radix/quic_tests.c
index 2564bd9185..baeb111b36 100644
--- a/test/radix/quic_tests.c
+++ b/test/radix/quic_tests.c
@@ -3167,10 +3167,11 @@ static int inject_new_conn_id_plain(RADIX_FAULT *fault, QUIC_PKT_HDR *hdr,
{
int ok = 0;
WPACKET wpkt;
- unsigned char frame_buf[64];
- size_t i, written;
+ unsigned char frame_buf[1000];
+ size_t i, written, j;
uint64_t seq_no = 0, retire_prior_to = 0;
QUIC_CONN_ID new_cid = { 0 };
+ unsigned int repeat = 1;
if (hdr->type != QUIC_PKT_TYPE_1RTT)
return 1;
@@ -3214,29 +3215,37 @@ static int inject_new_conn_id_plain(RADIX_FAULT *fault, QUIC_PKT_HDR *hdr,
seq_no = 20;
retire_prior_to = 5;
break;
+ case 7:
+ ossl_quic_channel_get_diag_local_cid(fault->ch, &new_cid);
+ seq_no = 2;
+ retire_prior_to = 1;
+ repeat = 20;
+ break;
}
if (!TEST_true(WPACKET_init_static_len(&wpkt, frame_buf,
sizeof(frame_buf), 0)))
return 0;
- if (!TEST_true(WPACKET_quic_write_vlint(&wpkt, OSSL_QUIC_FRAME_TYPE_NEW_CONN_ID))
- || !TEST_true(WPACKET_quic_write_vlint(&wpkt, seq_no)) /* seq no */
- || !TEST_true(WPACKET_quic_write_vlint(&wpkt, retire_prior_to)) /* retire prior to */
- || !TEST_true(WPACKET_put_bytes_u8(&wpkt, new_cid.id_len))) /* len */
- goto err;
-
- for (i = 0; i < new_cid.id_len && i < OSSL_NELEM(new_cid.id); ++i)
- if (!TEST_true(WPACKET_put_bytes_u8(&wpkt, new_cid.id[i])))
+ for (j = 0; j < repeat; j++) {
+ if (!TEST_true(WPACKET_quic_write_vlint(&wpkt, OSSL_QUIC_FRAME_TYPE_NEW_CONN_ID))
+ || !TEST_true(WPACKET_quic_write_vlint(&wpkt, seq_no)) /* seq no */
+ || !TEST_true(WPACKET_quic_write_vlint(&wpkt, retire_prior_to)) /* retire prior to */
+ || !TEST_true(WPACKET_put_bytes_u8(&wpkt, new_cid.id_len))) /* len */
goto err;
- for (; i < new_cid.id_len; ++i)
- if (!TEST_true(WPACKET_put_bytes_u8(&wpkt, 0x55)))
- goto err;
+ for (i = 0; i < new_cid.id_len && i < OSSL_NELEM(new_cid.id); ++i)
+ if (!TEST_true(WPACKET_put_bytes_u8(&wpkt, new_cid.id[i])))
+ goto err;
- for (i = 0; i < QUIC_STATELESS_RESET_TOKEN_LEN; ++i)
- if (!TEST_true(WPACKET_put_bytes_u8(&wpkt, 0x42)))
- goto err;
+ for (; i < new_cid.id_len; ++i)
+ if (!TEST_true(WPACKET_put_bytes_u8(&wpkt, 0x55)))
+ goto err;
+
+ for (i = 0; i < QUIC_STATELESS_RESET_TOKEN_LEN; ++i)
+ if (!TEST_true(WPACKET_put_bytes_u8(&wpkt, 0x42)))
+ goto err;
+ }
if (!TEST_true(WPACKET_get_total_written(&wpkt, &written))
|| !radix_fault_prepend_frame(fault, frame_buf, written))
@@ -6234,6 +6243,56 @@ DEF_SCRIPT(key_update_retained_keys,
}
}
+DEF_FUNC(check_new_conn_id_count)
+{
+ int ok = 0;
+ SSL *ssl;
+ QUIC_CHANNEL *ch;
+ uint64_t on_new_conn_id_recv;
+
+ REQUIRE_SSL(ssl);
+ ch = ossl_quic_conn_get_channel(ssl);
+ if (!TEST_ptr(ch))
+ goto err;
+
+ on_new_conn_id_recv = ossl_quic_channel_get_on_new_conn_id_handled(ch);
+
+ if (on_new_conn_id_recv == 0)
+ F_SPIN_AGAIN();
+
+ /*
+ * although test sends 20 NEW_CONNECTION_ID frames, only one should
+ * be handled, because 19 frames just retransmissions.
+ */
+ if (!TEST_uint64_t_eq(on_new_conn_id_recv, 1))
+ goto err;
+
+ ok = 1;
+err:
+ return ok;
+}
+
+DEF_SCRIPT(new_connid_retrans, "verify remote peer ignores retransmitted NEW_CONNID frames")
+{
+ OP_SIMPLE_PAIR_CONN();
+ OP_WRITE_B(C, "apple");
+ OP_ACCEPT_CONN_WAIT(L, S, 0);
+ OP_SET_INCOMING_STREAM_POLICY(C, SSL_INCOMING_STREAM_POLICY_ACCEPT, 42 /* error code */);
+ OP_SET_INCOMING_STREAM_POLICY(S, SSL_INCOMING_STREAM_POLICY_ACCEPT, 42 /* error code */);
+ OP_READ_EXPECT_B(S, "apple");
+
+ OP_SET_INJECT_PLAIN(S, inject_new_conn_id_plain);
+ OP_SET_INJECT_WORD(1, 7);
+
+ OP_WRITE_B(S, "orange");
+ OP_READ_EXPECT_B(C, "orange");
+
+ OP_SELECT_SSL(0, C);
+ OP_FUNC(check_new_conn_id_count);
+
+ OP_WRITE_B(S, "banana");
+}
+
/*
* List of Test Scripts
* ============================================================================
@@ -6360,6 +6419,7 @@ static SCRIPT_INFO *const scripts[] = {
USE(script_105),
USE(script_106),
USE(new_connid),
+ USE(new_connid_retrans),
USE(forbidden_frame_types),
USE(key_update_retained_keys),
};