diff options
| author | tb <> | 2025-09-30 12:54:18 +0000 |
|---|---|---|
| committer | tb <> | 2025-09-30 12:54:18 +0000 |
| commit | 2f913441f29f1f81d45eb8d13b12bdfd75a57d70 (patch) | |
| tree | 6bd735c3de0d6ebec02d4b9896dbc6061659379e /src | |
| parent | 9d824f57e18af2ec9fe3dab311be62b1e32eda9b (diff) | |
| download | openbsd-2f913441f29f1f81d45eb8d13b12bdfd75a57d70.tar.gz openbsd-2f913441f29f1f81d45eb8d13b12bdfd75a57d70.tar.bz2 openbsd-2f913441f29f1f81d45eb8d13b12bdfd75a57d70.zip | |
cms_RecipientInfo_pwri_crypt: fix incorrect return checklibressl-v4.1.1
cms_RecipientInfo_pwri_crypt: plug leak of kekalg
cms: fix incorrect length check in kek_unwrap_key()
An incorrect length check can result in a 4-byte overwrite and an
8-byte overread.
From Stanislav Fort and Viktor Dukhovni via OpenSSL.
CVE-2025-9230.
ok jsing
this is errata/7.7/010_libcrypto.patch.sig
Diffstat (limited to 'src')
| -rw-r--r-- | src/lib/libcrypto/cms/cms_pwri.c | 12 |
1 files changed, 6 insertions, 6 deletions
diff --git a/src/lib/libcrypto/cms/cms_pwri.c b/src/lib/libcrypto/cms/cms_pwri.c index b6fe5df961..cbcb7e09d3 100644 --- a/src/lib/libcrypto/cms/cms_pwri.c +++ b/src/lib/libcrypto/cms/cms_pwri.c | |||
| @@ -1,4 +1,4 @@ | |||
| 1 | /* $OpenBSD: cms_pwri.c,v 1.31 2024/01/14 18:40:24 tb Exp $ */ | 1 | /* $OpenBSD: cms_pwri.c,v 1.31.8.1 2025/09/30 12:54:18 tb Exp $ */ |
| 2 | /* | 2 | /* |
| 3 | * Written by Dr Stephen N Henson (steve@openssl.org) for the OpenSSL | 3 | * Written by Dr Stephen N Henson (steve@openssl.org) for the OpenSSL |
| 4 | * project. | 4 | * project. |
| @@ -267,7 +267,7 @@ kek_unwrap_key(unsigned char *out, size_t *outlen, const unsigned char *in, | |||
| 267 | /* Check byte failure */ | 267 | /* Check byte failure */ |
| 268 | goto err; | 268 | goto err; |
| 269 | } | 269 | } |
| 270 | if (inlen < (size_t)(tmp[0] - 4)) { | 270 | if (inlen < 4 + (size_t)tmp[0]) { |
| 271 | /* Invalid length value */ | 271 | /* Invalid length value */ |
| 272 | goto err; | 272 | goto err; |
| 273 | } | 273 | } |
| @@ -368,13 +368,13 @@ cms_RecipientInfo_pwri_crypt(CMS_ContentInfo *cms, CMS_RecipientInfo *ri, | |||
| 368 | kekcipher = EVP_get_cipherbyobj(kekalg->algorithm); | 368 | kekcipher = EVP_get_cipherbyobj(kekalg->algorithm); |
| 369 | if (!kekcipher) { | 369 | if (!kekcipher) { |
| 370 | CMSerror(CMS_R_UNKNOWN_CIPHER); | 370 | CMSerror(CMS_R_UNKNOWN_CIPHER); |
| 371 | return 0; | 371 | goto err; |
| 372 | } | 372 | } |
| 373 | 373 | ||
| 374 | kekctx = EVP_CIPHER_CTX_new(); | 374 | kekctx = EVP_CIPHER_CTX_new(); |
| 375 | if (kekctx == NULL) { | 375 | if (kekctx == NULL) { |
| 376 | CMSerror(ERR_R_MALLOC_FAILURE); | 376 | CMSerror(ERR_R_MALLOC_FAILURE); |
| 377 | return 0; | 377 | goto err; |
| 378 | } | 378 | } |
| 379 | /* Fixup cipher based on AlgorithmIdentifier to set IV etc */ | 379 | /* Fixup cipher based on AlgorithmIdentifier to set IV etc */ |
| 380 | if (!EVP_CipherInit_ex(kekctx, kekcipher, NULL, NULL, NULL, en_de)) | 380 | if (!EVP_CipherInit_ex(kekctx, kekcipher, NULL, NULL, NULL, en_de)) |
| @@ -389,8 +389,8 @@ cms_RecipientInfo_pwri_crypt(CMS_ContentInfo *cms, CMS_RecipientInfo *ri, | |||
| 389 | 389 | ||
| 390 | /* Finish password based key derivation to setup key in "ctx" */ | 390 | /* Finish password based key derivation to setup key in "ctx" */ |
| 391 | 391 | ||
| 392 | if (EVP_PBE_CipherInit(algtmp->algorithm, (char *)pwri->pass, | 392 | if (!EVP_PBE_CipherInit(algtmp->algorithm, (char *)pwri->pass, |
| 393 | pwri->passlen, algtmp->parameter, kekctx, en_de) < 0) { | 393 | pwri->passlen, algtmp->parameter, kekctx, en_de)) { |
| 394 | CMSerror(ERR_R_EVP_LIB); | 394 | CMSerror(ERR_R_EVP_LIB); |
| 395 | goto err; | 395 | goto err; |
| 396 | } | 396 | } |
