aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDaniel Kubec <[email protected]>2026-08-02 02:23:39 +0200
committerNorbert Pocs <[email protected]>2026-08-24 16:44:46 +0200
commita0c8ec557d9cac078f032d76cdf684fe743eb382 (patch)
tree0309bb7c95ae0e2157e312195d94fa26ca43ca81
parentAdd test for CVE-2026-63072 (diff)
downloadopenssl-a0c8ec557d9cac078f032d76cdf684fe743eb382.tar.gz
openssl-a0c8ec557d9cac078f032d76cdf684fe743eb382.zip
Fix heap buffer overflow (8-byte OOB write) in AES-WRAP-PAD unwrap
On its integrity-failure paths that primitive writes and cleanses up to inlen bytes of the output buffer. Size the buffer for that worst case so a failed unwrap cannot write past the allocation. Fixes CVE-2026-63072 Reviewed-by: Milan Broz <[email protected]> Reviewed-by: Andrew Dinh <[email protected]> Merge-date: Mon Aug 24 14:44:55 2026
-rw-r--r--crypto/cms/cms_kari.c9
1 files changed, 8 insertions, 1 deletions
diff --git a/crypto/cms/cms_kari.c b/crypto/cms/cms_kari.c
index 76121783864..858efcd06b9 100644
--- a/crypto/cms/cms_kari.c
+++ b/crypto/cms/cms_kari.c
@@ -218,6 +218,7 @@ static int cms_kek_cipher(unsigned char **pout, size_t *poutlen,
unsigned char *out = NULL;
size_t out_alloc_len = 0;
int outlen;
+ size_t outsize;
keklen = EVP_CIPHER_CTX_get_key_length(kari->ctx);
if (keklen > EVP_MAX_KEY_LENGTH)
@@ -231,7 +232,13 @@ static int cms_kek_cipher(unsigned char **pout, size_t *poutlen,
/* obtain output length of ciphered key */
if (!EVP_CipherUpdate(kari->ctx, NULL, &outlen, in, inlen))
goto err;
- out = OPENSSL_malloc(outlen);
+ /*
+ * On its integrity-failure paths that primitive writes and cleanses up to
+ * inlen bytes of the output buffer. Size the buffer for that worst case so
+ * a failed unwrap cannot write past the allocation.
+ */
+ outsize = (size_t)outlen < inlen ? inlen : (size_t)outlen;
+ out = OPENSSL_malloc(outsize);
if (out == NULL)
goto err;
out_alloc_len = (size_t)outlen;