diff options
| author | Peter Marko <peter.marko@siemens.com> | 2025-11-27 00:34:31 +0100 |
|---|---|---|
| committer | Steve Sakoman <steve@sakoman.com> | 2025-12-05 07:13:42 -0800 |
| commit | adc9e377c8203935e52b10ab970902c7a175dff6 (patch) | |
| tree | e3a0651f9f0259c54d1e22fa3c0353dc11c67a20 | |
| parent | e6bfeed8f3e72c577820e3d01f7d697c4d3fc5d4 (diff) | |
| download | poky-adc9e377c8203935e52b10ab970902c7a175dff6.tar.gz | |
gnutls: patch CVE-2025-9820
This CVE is announced under [1].
Pick commit which mentions this CVE per [2].
[1] https://www.gnutls.org/security-new.html#GNUTLS-SA-2025-11-18
[2] https://security-tracker.debian.org/tracker/CVE-2025-9820
(From OE-Core rev: 37dcb0f617f02f95293455d58927e0da4e768cc4)
Signed-off-by: Peter Marko <peter.marko@siemens.com>
Signed-off-by: Steve Sakoman <steve@sakoman.com>
| -rw-r--r-- | meta/recipes-support/gnutls/gnutls/CVE-2025-9820.patch | 250 | ||||
| -rw-r--r-- | meta/recipes-support/gnutls/gnutls_3.8.4.bb | 1 |
2 files changed, 251 insertions, 0 deletions
diff --git a/meta/recipes-support/gnutls/gnutls/CVE-2025-9820.patch b/meta/recipes-support/gnutls/gnutls/CVE-2025-9820.patch new file mode 100644 index 0000000000..99a6c11ee4 --- /dev/null +++ b/meta/recipes-support/gnutls/gnutls/CVE-2025-9820.patch | |||
| @@ -0,0 +1,250 @@ | |||
| 1 | From 1d56f96f6ab5034d677136b9d50b5a75dff0faf5 Mon Sep 17 00:00:00 2001 | ||
| 2 | From: Daiki Ueno <ueno@gnu.org> | ||
| 3 | Date: Tue, 18 Nov 2025 13:17:55 +0900 | ||
| 4 | Subject: [PATCH] pkcs11: avoid stack overwrite when initializing a token | ||
| 5 | |||
| 6 | If gnutls_pkcs11_token_init is called with label longer than 32 | ||
| 7 | characters, the internal storage used to blank-fill it would | ||
| 8 | overflow. This adds a guard to prevent that. | ||
| 9 | |||
| 10 | Signed-off-by: Daiki Ueno <ueno@gnu.org> | ||
| 11 | |||
| 12 | CVE: CVE-2025-9820 | ||
| 13 | Upstream-Status: Backport [https://gitlab.com/gnutls/gnutls/-/commit/1d56f96f6ab5034d677136b9d50b5a75dff0faf5] | ||
| 14 | Signed-off-by: Peter Marko <peter.marko@siemens.com> | ||
| 15 | --- | ||
| 16 | NEWS | 4 + | ||
| 17 | lib/pkcs11_write.c | 5 +- | ||
| 18 | tests/Makefile.am | 2 +- | ||
| 19 | tests/pkcs11/long-label.c | 164 ++++++++++++++++++++++++++++++++++++++ | ||
| 20 | 4 files changed, 172 insertions(+), 3 deletions(-) | ||
| 21 | create mode 100644 tests/pkcs11/long-label.c | ||
| 22 | |||
| 23 | diff --git a/NEWS b/NEWS | ||
| 24 | index 0ae3c9991..d6df70ee6 100644 | ||
| 25 | --- a/NEWS | ||
| 26 | +++ b/NEWS | ||
| 27 | @@ -5,6 +5,10 @@ Copyright (C) 2000-2016 Free Software Foundation, Inc. | ||
| 28 | Copyright (C) 2013-2019 Nikos Mavrogiannopoulos | ||
| 29 | See the end for copying conditions. | ||
| 30 | |||
| 31 | +** libgnutls: Fix stack overwrite in gnutls_pkcs11_token_init | ||
| 32 | + Reported by Luigino Camastra from Aisle Research. [GNUTLS-SA-2025-11-18, | ||
| 33 | + CVSS: low] [CVE-2025-9820] | ||
| 34 | + | ||
| 35 | ** libgnutls: Fix NULL pointer dereference when 2nd Client Hello omits PSK | ||
| 36 | Reported by Stefan Bühler. [GNUTLS-SA-2025-07-07-4, CVSS: medium] | ||
| 37 | [CVE-2025-6395] | ||
| 38 | diff --git a/lib/pkcs11_write.c b/lib/pkcs11_write.c | ||
| 39 | index f5e9058e0..64b85a2df 100644 | ||
| 40 | --- a/lib/pkcs11_write.c | ||
| 41 | +++ b/lib/pkcs11_write.c | ||
| 42 | @@ -28,6 +28,7 @@ | ||
| 43 | #include "pkcs11x.h" | ||
| 44 | #include "x509/common.h" | ||
| 45 | #include "pk.h" | ||
| 46 | +#include "minmax.h" | ||
| 47 | |||
| 48 | static const ck_bool_t tval = 1; | ||
| 49 | static const ck_bool_t fval = 0; | ||
| 50 | @@ -1173,7 +1174,7 @@ int gnutls_pkcs11_delete_url(const char *object_url, unsigned int flags) | ||
| 51 | * gnutls_pkcs11_token_init: | ||
| 52 | * @token_url: A PKCS #11 URL specifying a token | ||
| 53 | * @so_pin: Security Officer's PIN | ||
| 54 | - * @label: A name to be used for the token | ||
| 55 | + * @label: A name to be used for the token, at most 32 characters | ||
| 56 | * | ||
| 57 | * This function will initialize (format) a token. If the token is | ||
| 58 | * at a factory defaults state the security officer's PIN given will be | ||
| 59 | @@ -1211,7 +1212,7 @@ int gnutls_pkcs11_token_init(const char *token_url, const char *so_pin, | ||
| 60 | /* so it seems memset has other uses than zeroing! */ | ||
| 61 | memset(flabel, ' ', sizeof(flabel)); | ||
| 62 | if (label != NULL) | ||
| 63 | - memcpy(flabel, label, strlen(label)); | ||
| 64 | + memcpy(flabel, label, MIN(sizeof(flabel), strlen(label))); | ||
| 65 | |||
| 66 | rv = pkcs11_init_token(module, slot, (uint8_t *)so_pin, strlen(so_pin), | ||
| 67 | (uint8_t *)flabel); | ||
| 68 | diff --git a/tests/Makefile.am b/tests/Makefile.am | ||
| 69 | index be4966f4b..8327c90ca 100644 | ||
| 70 | --- a/tests/Makefile.am | ||
| 71 | +++ b/tests/Makefile.am | ||
| 72 | @@ -496,7 +496,7 @@ pathbuf_CPPFLAGS = $(AM_CPPFLAGS) \ | ||
| 73 | if ENABLE_PKCS11 | ||
| 74 | if !WINDOWS | ||
| 75 | ctests += tls13/post-handshake-with-cert-pkcs11 pkcs11/tls-neg-pkcs11-no-key \ | ||
| 76 | - global-init-override pkcs11/distrust-after | ||
| 77 | + global-init-override pkcs11/distrust-after pkcs11/long-label | ||
| 78 | tls13_post_handshake_with_cert_pkcs11_DEPENDENCIES = libpkcs11mock2.la libutils.la | ||
| 79 | tls13_post_handshake_with_cert_pkcs11_LDADD = $(LDADD) $(LIBDL) | ||
| 80 | pkcs11_tls_neg_pkcs11_no_key_DEPENDENCIES = libpkcs11mock2.la libutils.la | ||
| 81 | diff --git a/tests/pkcs11/long-label.c b/tests/pkcs11/long-label.c | ||
| 82 | new file mode 100644 | ||
| 83 | index 000000000..a70bc9728 | ||
| 84 | --- /dev/null | ||
| 85 | +++ b/tests/pkcs11/long-label.c | ||
| 86 | @@ -0,0 +1,164 @@ | ||
| 87 | +/* | ||
| 88 | + * Copyright (C) 2025 Red Hat, Inc. | ||
| 89 | + * | ||
| 90 | + * Author: Daiki Ueno | ||
| 91 | + * | ||
| 92 | + * This file is part of GnuTLS. | ||
| 93 | + * | ||
| 94 | + * GnuTLS is free software; you can redistribute it and/or modify it | ||
| 95 | + * under the terms of the GNU General Public License as published by | ||
| 96 | + * the Free Software Foundation; either version 3 of the License, or | ||
| 97 | + * (at your option) any later version. | ||
| 98 | + * | ||
| 99 | + * GnuTLS is distributed in the hope that it will be useful, but | ||
| 100 | + * WITHOUT ANY WARRANTY; without even the implied warranty of | ||
| 101 | + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | ||
| 102 | + * General Public License for more details. | ||
| 103 | + * | ||
| 104 | + * You should have received a copy of the GNU Lesser General Public License | ||
| 105 | + * along with this program. If not, see <https://www.gnu.org/licenses/> | ||
| 106 | + */ | ||
| 107 | + | ||
| 108 | +#ifdef HAVE_CONFIG_H | ||
| 109 | +#include "config.h" | ||
| 110 | +#endif | ||
| 111 | + | ||
| 112 | +#include <stdbool.h> | ||
| 113 | +#include <stdio.h> | ||
| 114 | +#include <stdlib.h> | ||
| 115 | + | ||
| 116 | +#if defined(_WIN32) | ||
| 117 | + | ||
| 118 | +int main(void) | ||
| 119 | +{ | ||
| 120 | + exit(77); | ||
| 121 | +} | ||
| 122 | + | ||
| 123 | +#else | ||
| 124 | + | ||
| 125 | +#include <string.h> | ||
| 126 | +#include <unistd.h> | ||
| 127 | +#include <gnutls/gnutls.h> | ||
| 128 | + | ||
| 129 | +#include "cert-common.h" | ||
| 130 | +#include "pkcs11/softhsm.h" | ||
| 131 | +#include "utils.h" | ||
| 132 | + | ||
| 133 | +/* This program tests that a token can be initialized with | ||
| 134 | + * a label longer than 32 characters. | ||
| 135 | + */ | ||
| 136 | + | ||
| 137 | +static void tls_log_func(int level, const char *str) | ||
| 138 | +{ | ||
| 139 | + fprintf(stderr, "server|<%d>| %s", level, str); | ||
| 140 | +} | ||
| 141 | + | ||
| 142 | +#define PIN "1234" | ||
| 143 | + | ||
| 144 | +#define CONFIG_NAME "softhsm-long-label" | ||
| 145 | +#define CONFIG CONFIG_NAME ".config" | ||
| 146 | + | ||
| 147 | +static int pin_func(void *userdata, int attempt, const char *url, | ||
| 148 | + const char *label, unsigned flags, char *pin, | ||
| 149 | + size_t pin_max) | ||
| 150 | +{ | ||
| 151 | + if (attempt == 0) { | ||
| 152 | + strcpy(pin, PIN); | ||
| 153 | + return 0; | ||
| 154 | + } | ||
| 155 | + return -1; | ||
| 156 | +} | ||
| 157 | + | ||
| 158 | +static void test(const char *provider) | ||
| 159 | +{ | ||
| 160 | + int ret; | ||
| 161 | + size_t i; | ||
| 162 | + | ||
| 163 | + gnutls_pkcs11_init(GNUTLS_PKCS11_FLAG_MANUAL, NULL); | ||
| 164 | + | ||
| 165 | + success("test with %s\n", provider); | ||
| 166 | + | ||
| 167 | + if (debug) { | ||
| 168 | + gnutls_global_set_log_function(tls_log_func); | ||
| 169 | + gnutls_global_set_log_level(4711); | ||
| 170 | + } | ||
| 171 | + | ||
| 172 | + /* point to SoftHSM token that libpkcs11mock4.so internally uses */ | ||
| 173 | + setenv(SOFTHSM_ENV, CONFIG, 1); | ||
| 174 | + | ||
| 175 | + gnutls_pkcs11_set_pin_function(pin_func, NULL); | ||
| 176 | + | ||
| 177 | + ret = gnutls_pkcs11_add_provider(provider, "trusted"); | ||
| 178 | + if (ret != 0) { | ||
| 179 | + fail("gnutls_pkcs11_add_provider: %s\n", gnutls_strerror(ret)); | ||
| 180 | + } | ||
| 181 | + | ||
| 182 | + /* initialize softhsm token */ | ||
| 183 | + ret = gnutls_pkcs11_token_init( | ||
| 184 | + SOFTHSM_URL, PIN, | ||
| 185 | + "this is a very long label whose length exceeds 32"); | ||
| 186 | + if (ret < 0) { | ||
| 187 | + fail("gnutls_pkcs11_token_init: %s\n", gnutls_strerror(ret)); | ||
| 188 | + } | ||
| 189 | + | ||
| 190 | + for (i = 0;; i++) { | ||
| 191 | + char *url = NULL; | ||
| 192 | + | ||
| 193 | + ret = gnutls_pkcs11_token_get_url(i, 0, &url); | ||
| 194 | + if (ret < 0) | ||
| 195 | + break; | ||
| 196 | + if (strstr(url, | ||
| 197 | + "token=this%20is%20a%20very%20long%20label%20whose")) | ||
| 198 | + break; | ||
| 199 | + } | ||
| 200 | + if (ret < 0) | ||
| 201 | + fail("gnutls_pkcs11_token_get_url: %s\n", gnutls_strerror(ret)); | ||
| 202 | + | ||
| 203 | + gnutls_pkcs11_deinit(); | ||
| 204 | +} | ||
| 205 | + | ||
| 206 | +void doit(void) | ||
| 207 | +{ | ||
| 208 | + const char *bin; | ||
| 209 | + const char *lib; | ||
| 210 | + char buf[128]; | ||
| 211 | + | ||
| 212 | + if (gnutls_fips140_mode_enabled()) | ||
| 213 | + exit(77); | ||
| 214 | + | ||
| 215 | + /* this must be called once in the program */ | ||
| 216 | + global_init(); | ||
| 217 | + | ||
| 218 | + /* we call gnutls_pkcs11_init manually */ | ||
| 219 | + gnutls_pkcs11_deinit(); | ||
| 220 | + | ||
| 221 | + /* check if softhsm module is loadable */ | ||
| 222 | + lib = softhsm_lib(); | ||
| 223 | + | ||
| 224 | + /* initialize SoftHSM token that libpkcs11mock4.so internally uses */ | ||
| 225 | + bin = softhsm_bin(); | ||
| 226 | + | ||
| 227 | + set_softhsm_conf(CONFIG); | ||
| 228 | + snprintf(buf, sizeof(buf), | ||
| 229 | + "%s --init-token --slot 0 --label test --so-pin " PIN | ||
| 230 | + " --pin " PIN, | ||
| 231 | + bin); | ||
| 232 | + system(buf); | ||
| 233 | + | ||
| 234 | + test(lib); | ||
| 235 | + | ||
| 236 | + lib = getenv("P11MOCKLIB4"); | ||
| 237 | + if (lib == NULL) { | ||
| 238 | + fail("P11MOCKLIB4 is not set\n"); | ||
| 239 | + } | ||
| 240 | + | ||
| 241 | + set_softhsm_conf(CONFIG); | ||
| 242 | + snprintf(buf, sizeof(buf), | ||
| 243 | + "%s --init-token --slot 0 --label test --so-pin " PIN | ||
| 244 | + " --pin " PIN, | ||
| 245 | + bin); | ||
| 246 | + system(buf); | ||
| 247 | + | ||
| 248 | + test(lib); | ||
| 249 | +} | ||
| 250 | +#endif /* _WIN32 */ | ||
diff --git a/meta/recipes-support/gnutls/gnutls_3.8.4.bb b/meta/recipes-support/gnutls/gnutls_3.8.4.bb index dde3bc3014..026ae650f6 100644 --- a/meta/recipes-support/gnutls/gnutls_3.8.4.bb +++ b/meta/recipes-support/gnutls/gnutls_3.8.4.bb | |||
| @@ -33,6 +33,7 @@ SRC_URI = "https://www.gnupg.org/ftp/gcrypt/gnutls/v${SHRT_VER}/gnutls-${PV}.tar | |||
| 33 | file://CVE-2025-32988.patch \ | 33 | file://CVE-2025-32988.patch \ |
| 34 | file://CVE-2025-32990.patch \ | 34 | file://CVE-2025-32990.patch \ |
| 35 | file://CVE-2025-6395.patch \ | 35 | file://CVE-2025-6395.patch \ |
| 36 | file://CVE-2025-9820.patch \ | ||
| 36 | " | 37 | " |
| 37 | 38 | ||
| 38 | SRC_URI[sha256sum] = "2bea4e154794f3f00180fa2a5c51fe8b005ac7a31cd58bd44cdfa7f36ebc3a9b" | 39 | SRC_URI[sha256sum] = "2bea4e154794f3f00180fa2a5c51fe8b005ac7a31cd58bd44cdfa7f36ebc3a9b" |
