]> git.ipfire.org Git - thirdparty/openssl.git/commitdiff
kek_unwrap_key(): Fix incorrect check of unwrapped key size
authorViktor Dukhovni <openssl-users@dukhovni.org>
Thu, 11 Sep 2025 16:10:12 +0000 (18:10 +0200)
committerTomas Mraz <tomas@openssl.org>
Mon, 29 Sep 2025 09:58:46 +0000 (11:58 +0200)
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 <nhorman@openssl.org>
Reviewed-by: Matt Caswell <matt@openssl.org>
Reviewed-by: Tomas Mraz <tomas@openssl.org>
(cherry picked from commit 9c462be2cea54ebfc62953224220b56f8ba22a0c)

crypto/cms/cms_pwri.c

index a7d609f83791a21ed5b3fe3ff1c87659e78bbdef..ee1b8aa6ed61d8a8b4075c975dd407e52db0a31a 100644 (file)
@@ -242,7 +242,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;
     }