summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authortb <>2025-10-23 15:26:57 +0000
committertb <>2025-10-23 15:26:57 +0000
commita0dca9ee89cde95a556cd215202b7542ee5f598f (patch)
tree63ef7061b120fdf83bd33b2a787e23c5d846edc2 /src
parent752aec5fac0b359c7a675abc05db2deccf8c53af (diff)
downloadopenbsd-a0dca9ee89cde95a556cd215202b7542ee5f598f.tar.gz
openbsd-a0dca9ee89cde95a556cd215202b7542ee5f598f.tar.bz2
openbsd-a0dca9ee89cde95a556cd215202b7542ee5f598f.zip
Ensure that we specify the correct group when creating a HelloRetryRequest.libressl-v4.2.1OPENBSD_7_8
When processing the client supported groups and key shares extensions, the group selection is currently based on client preference. However, when building a HRR the preferred group is identified by calling tls1_get_supported_group(). If SSL_OP_CIPHER_SERVER_PREFERENCE is enabled, group selection will be based on server instead of client preference. This in turn can result in the server sending a HRR for a group that the client has already provided a key share for, violating the RFC. Avoid this issue by storing the client preferred group when processing the key share extension, then using this group when creating the HRR. Thanks to dzwdz for identifying and reporting the issue. ok beck@ tb@ from jsing@ This is errata/7.8/003_libssl.patch.sig
Diffstat (limited to 'src')
-rw-r--r--src/lib/libssl/ssl_tlsext.c3
-rw-r--r--src/lib/libssl/tls13_server.c10
2 files changed, 4 insertions, 9 deletions
diff --git a/src/lib/libssl/ssl_tlsext.c b/src/lib/libssl/ssl_tlsext.c
index 9209597601..311c29b42d 100644
--- a/src/lib/libssl/ssl_tlsext.c
+++ b/src/lib/libssl/ssl_tlsext.c
@@ -1,4 +1,4 @@
1/* $OpenBSD: ssl_tlsext.c,v 1.156 2025/06/07 10:23:21 tb Exp $ */ 1/* $OpenBSD: ssl_tlsext.c,v 1.156.2.1 2025/10/23 15:26:57 tb Exp $ */
2/* 2/*
3 * Copyright (c) 2016, 2017, 2019 Joel Sing <jsing@openbsd.org> 3 * Copyright (c) 2016, 2017, 2019 Joel Sing <jsing@openbsd.org>
4 * Copyright (c) 2017 Doug Hogan <doug@openbsd.org> 4 * Copyright (c) 2017 Doug Hogan <doug@openbsd.org>
@@ -1554,6 +1554,7 @@ tlsext_keyshare_server_process(SSL *s, uint16_t msg_type, CBS *cbs, int *alert)
1554 for (j = 0; j < server_groups_len; j++) { 1554 for (j = 0; j < server_groups_len; j++) {
1555 if (server_groups[j] == client_groups[i]) { 1555 if (server_groups[j] == client_groups[i]) {
1556 client_preferred_group = client_groups[i]; 1556 client_preferred_group = client_groups[i];
1557 s->s3->hs.tls13.server_group = client_preferred_group;
1557 preferred_group_found = 1; 1558 preferred_group_found = 1;
1558 break; 1559 break;
1559 } 1560 }
diff --git a/src/lib/libssl/tls13_server.c b/src/lib/libssl/tls13_server.c
index 63b7d92093..650fd135cd 100644
--- a/src/lib/libssl/tls13_server.c
+++ b/src/lib/libssl/tls13_server.c
@@ -1,4 +1,4 @@
1/* $OpenBSD: tls13_server.c,v 1.109 2024/07/22 14:47:15 jsing Exp $ */ 1/* $OpenBSD: tls13_server.c,v 1.109.4.1 2025/10/23 15:26:57 tb Exp $ */
2/* 2/*
3 * Copyright (c) 2019, 2020 Joel Sing <jsing@openbsd.org> 3 * Copyright (c) 2019, 2020 Joel Sing <jsing@openbsd.org>
4 * Copyright (c) 2020 Bob Beck <beck@openbsd.org> 4 * Copyright (c) 2020 Bob Beck <beck@openbsd.org>
@@ -437,8 +437,6 @@ tls13_server_engage_record_protection(struct tls13_ctx *ctx)
437int 437int
438tls13_server_hello_retry_request_send(struct tls13_ctx *ctx, CBB *cbb) 438tls13_server_hello_retry_request_send(struct tls13_ctx *ctx, CBB *cbb)
439{ 439{
440 int nid;
441
442 ctx->hs->tls13.hrr = 1; 440 ctx->hs->tls13.hrr = 1;
443 441
444 if (!tls13_synthetic_handshake_message(ctx)) 442 if (!tls13_synthetic_handshake_message(ctx))
@@ -446,9 +444,7 @@ tls13_server_hello_retry_request_send(struct tls13_ctx *ctx, CBB *cbb)
446 444
447 if (ctx->hs->key_share != NULL) 445 if (ctx->hs->key_share != NULL)
448 return 0; 446 return 0;
449 if (!tls1_get_supported_group(ctx->ssl, &nid)) 447 if (ctx->hs->tls13.server_group == 0)
450 return 0;
451 if (!tls1_ec_nid2group_id(nid, &ctx->hs->tls13.server_group))
452 return 0; 448 return 0;
453 449
454 if (!tls13_server_hello_build(ctx, cbb, 1)) 450 if (!tls13_server_hello_build(ctx, cbb, 1))
@@ -511,8 +507,6 @@ tls13_server_hello_send(struct tls13_ctx *ctx, CBB *cbb)
511 if (!tls13_servername_process(ctx)) 507 if (!tls13_servername_process(ctx))
512 return 0; 508 return 0;
513 509
514 ctx->hs->tls13.server_group = 0;
515
516 if (!tls13_server_hello_build(ctx, cbb, 0)) 510 if (!tls13_server_hello_build(ctx, cbb, 0))
517 return 0; 511 return 0;
518 512