From: Viktor Dukhovni Date: Thu, 11 Sep 2025 16:10:12 +0000 (+0200) Subject: kek_unwrap_key(): Fix incorrect check of unwrapped key size X-Git-Tag: openssl-3.2.6~8 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=b5282d677551afda7d20e9c00e09561b547b2dfd;p=thirdparty%2Fopenssl.git kek_unwrap_key(): Fix incorrect check of unwrapped key size Fixes CVE-2025-9230 The check is off by 8 bytes so it is possible to overread by up to 8 bytes and overwrite up to 4 bytes. Reviewed-by: Neil Horman Reviewed-by: Matt Caswell Reviewed-by: Tomas Mraz (cherry picked from commit 9c462be2cea54ebfc62953224220b56f8ba22a0c) --- diff --git a/crypto/cms/cms_pwri.c b/crypto/cms/cms_pwri.c index 32392261260..74530cb68e5 100644 --- a/crypto/cms/cms_pwri.c +++ b/crypto/cms/cms_pwri.c @@ -238,7 +238,7 @@ static int kek_unwrap_key(unsigned char *out, size_t *outlen, /* Check byte failure */ goto err; } - if (inlen < (size_t)(tmp[0] - 4)) { + if (inlen < 4 + (size_t)tmp[0]) { /* Invalid length value */ goto err; }