Sign Up
Log In
Log In
or
Sign Up
Places
All Projects
Status Monitor
Collapse sidebar
SUSE:SLE-12-SP2:GA
compat-openssl098.27677
openssl-CVE-2019-1563.patch
Overview
Repositories
Revisions
Requests
Users
Attributes
Meta
File openssl-CVE-2019-1563.patch of Package compat-openssl098.27677
From e21f8cf78a125cd3c8c0d1a1a6c8bb0b901f893f Mon Sep 17 00:00:00 2001 From: Bernd Edlinger <bernd.edlinger@hotmail.de> Date: Sun, 1 Sep 2019 00:16:28 +0200 Subject: [PATCH] Fix a padding oracle in PKCS7_dataDecode and CMS_decrypt_set1_pkey An attack is simple, if the first CMS_recipientInfo is valid but the second CMS_recipientInfo is chosen ciphertext. If the second recipientInfo decodes to PKCS #1 v1.5 form plaintext, the correct encryption key will be replaced by garbage, and the message cannot be decoded, but if the RSA decryption fails, the correct encryption key is used and the recipient will not notice the attack. As a work around for this potential attack the length of the decrypted key must be equal to the cipher default key length, in case the certifiate is not given and all recipientInfo are tried out. The old behaviour can be re-enabled in the CMS code by setting the CMS_DEBUG_DECRYPT flag. Reviewed-by: Matt Caswell <matt@openssl.org> (Merged from https://github.com/openssl/openssl/pull/9777) (cherry picked from commit 5840ed0cd1e6487d247efbc1a04136a41d7b3a37) Index: openssl-0.9.8j/crypto/cms/cms_lcl.h =================================================================== --- openssl-0.9.8j.orig/crypto/cms/cms_lcl.h +++ openssl-0.9.8j/crypto/cms/cms_lcl.h @@ -177,6 +177,8 @@ struct CMS_EncryptedContentInfo_st size_t keylen; /* Set to 1 if we are debugging decrypt and don't fake keys for MMA */ int debug; + /* Set to 1 if we have no cert and need extra safety measures for MMA */ + int havenocert; }; struct CMS_RecipientInfo_st Index: openssl-0.9.8j/crypto/cms/cms_smime.c =================================================================== --- openssl-0.9.8j.orig/crypto/cms/cms_smime.c +++ openssl-0.9.8j/crypto/cms/cms_smime.c @@ -733,6 +733,10 @@ int CMS_decrypt(CMS_ContentInfo *cms, EV cms->d.envelopedData->encryptedContentInfo->debug = 1; else cms->d.envelopedData->encryptedContentInfo->debug = 0; + if (!cert) + cms->d.envelopedData->encryptedContentInfo->havenocert = 1; + else + cms->d.envelopedData->encryptedContentInfo->havenocert = 0; if (!pk && !cert && !dcont && !out) return 1; if (pk && !CMS_decrypt_set1_pkey(cms, pk, cert)) Index: openssl-0.9.8j/crypto/cms/cms_env.c =================================================================== --- openssl-0.9.8j.orig/crypto/cms/cms_env.c +++ openssl-0.9.8j/crypto/cms/cms_env.c @@ -352,6 +352,7 @@ static int cms_RecipientInfo_ktri_decryp unsigned char *ek = NULL; int eklen; int ret = 0; + size_t fixlen = 0; CMS_EncryptedContentInfo *ec; ec = cms->d.envelopedData->encryptedContentInfo; @@ -362,6 +363,19 @@ static int cms_RecipientInfo_ktri_decryp return 0; } + if (cms->d.envelopedData->encryptedContentInfo->havenocert + && !cms->d.envelopedData->encryptedContentInfo->debug) { + X509_ALGOR *calg = ec->contentEncryptionAlgorithm; + const EVP_CIPHER *ciph = EVP_get_cipherbyobj(calg->algorithm); + + if (ciph == NULL) { + CMSerr(CMS_F_CMS_RECIPIENTINFO_KTRI_DECRYPT, CMS_R_UNKNOWN_CIPHER); + return 0; + } + + fixlen = EVP_CIPHER_key_length(ciph); + } + eklen = EVP_PKEY_size(ktri->pkey); ek = OPENSSL_malloc(eklen); @@ -376,7 +390,8 @@ static int cms_RecipientInfo_ktri_decryp eklen = EVP_PKEY_decrypt(ek, ktri->encryptedKey->data, ktri->encryptedKey->length, ktri->pkey); - if (eklen <= 0) + + if (eklen <= 0 || (fixlen != 0 && eklen != fixlen)) { CMSerr(CMS_F_CMS_RECIPIENTINFO_KTRI_DECRYPT, CMS_R_CMS_LIB); goto err; Index: openssl-0.9.8j/crypto/pkcs7/pk7_doit.c =================================================================== --- openssl-0.9.8j.orig/crypto/pkcs7/pk7_doit.c +++ openssl-0.9.8j/crypto/pkcs7/pk7_doit.c @@ -514,6 +514,7 @@ BIO *PKCS7_dataDecode(PKCS7 *p7, EVP_PKE /* Temporary storage in case EVP_PKEY_decrypt * overwrites output buffer on error. */ + size_t fixlen = EVP_CIPHER_key_length(evp_cipher); unsigned char *tmp2; tmp2 = OPENSSL_malloc(jj); if (!tmp2) @@ -531,7 +532,7 @@ BIO *PKCS7_dataDecode(PKCS7 *p7, EVP_PKE M_ASN1_STRING_data(ri->enc_key), M_ASN1_STRING_length(ri->enc_key), pkey); - if (tret > 0) + if (tret > 0 && tret == fixlen) { memcpy(tmp, tmp2, tret); OPENSSL_cleanse(tmp2, tret);
Locations
Projects
Search
Status Monitor
Help
OpenBuildService.org
Documentation
API Documentation
Code of Conduct
Contact
Support
@OBShq
Terms
openSUSE Build Service is sponsored by
The Open Build Service is an
openSUSE project
.
Sign Up
Log In
Places
Places
All Projects
Status Monitor