krb5 commit [krb5-1.21]: In PKINIT, check for null PKCS7 enveloped fields

ghudson at mit.edu ghudson at mit.edu
Mon Jun 24 19:51:02 EDT 2024


https://github.com/krb5/krb5/commit/5cbfb6366f6c07903e67c87db0144d280717cf0c
commit 5cbfb6366f6c07903e67c87db0144d280717cf0c
Author: Greg Hudson <ghudson at mit.edu>
Date:   Sat Nov 25 11:04:56 2023 -0500

    In PKINIT, check for null PKCS7 enveloped fields
    
    The PKCS7 ContentInfo content field and EncryptedContentInfo
    encryptedContent field are optional.  Check for null values in
    cms_envelopeddata_verify() before calling pkcs7_decrypt().  Reported
    by Bahaa Naamneh.
    
    (cherry picked from commit 48ccd81656381522d1f9ccb8705c13f0266a46ab)
    
    ticket: 9107
    version_fixed: 1.21.3

 src/plugins/preauth/pkinit/pkinit_crypto_openssl.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/src/plugins/preauth/pkinit/pkinit_crypto_openssl.c b/src/plugins/preauth/pkinit/pkinit_crypto_openssl.c
index f41328763..cb9c79626 100644
--- a/src/plugins/preauth/pkinit/pkinit_crypto_openssl.c
+++ b/src/plugins/preauth/pkinit/pkinit_crypto_openssl.c
@@ -2272,7 +2272,9 @@ cms_envelopeddata_verify(krb5_context context,
     }
 
     /* verify that the received message is PKCS7 EnvelopedData message */
-    if (OBJ_obj2nid(p7->type) != NID_pkcs7_enveloped) {
+    if (OBJ_obj2nid(p7->type) != NID_pkcs7_enveloped ||
+        p7->d.enveloped == NULL ||
+        p7->d.enveloped->enc_data->enc_data == NULL) {
         pkiDebug("Expected id-enveloped PKCS7 msg (received type = %d)\n",
                  OBJ_obj2nid(p7->type));
         krb5_set_error_message(context, retval, "wrong oid\n");


More information about the cvs-krb5 mailing list