RHEL Engineering is moving the tracking of its product development work on RHEL 6 through RHEL 9 to Red Hat Jira (issues.redhat.com). If you're a Red Hat customer, please continue to file support cases via the Red Hat customer portal. If you're not, please head to the "RHEL project" in Red Hat Jira and file new tickets here. Individual Bugzilla bugs in the statuses "NEW", "ASSIGNED", and "POST" are being migrated throughout September 2023. Bugs of Red Hat partners with an assigned Engineering Partner Manager (EPM) are migrated in late September as per pre-agreed dates. Bugs against components "kernel", "kernel-rt", and "kpatch" are only migrated if still in "NEW" or "ASSIGNED". If you cannot log in to RH Jira, please consult article #7032570. That failing, please send an e-mail to the RH Jira admins at rh-issues@redhat.com to troubleshoot your issue as a user management inquiry. The email creates a ServiceNow ticket with Red Hat. Individual Bugzilla bugs that are migrated will be moved to status "CLOSED", resolution "MIGRATED", and set with "MigratedToJIRA" in "Keywords". The link to the successor Jira issue will be found under "Links", have a little "two-footprint" icon next to it, and direct you to the "RHEL project" in Red Hat Jira (issue links are of type "https://issues.redhat.com/browse/RHEL-XXXX", where "X" is a digit). This same link will be available in a blue banner at the top of the page informing you that that bug has been migrated.
Bug 2063838 - Mishandling of CMS_verify() errors in PKINIT plugin
Summary: Mishandling of CMS_verify() errors in PKINIT plugin
Keywords:
Status: CLOSED ERRATA
Alias: None
Product: Red Hat Enterprise Linux 9
Classification: Red Hat
Component: krb5
Version: 9.0
Hardware: Unspecified
OS: Unspecified
unspecified
unspecified
Target Milestone: rc
: ---
Assignee: Julien Rische
QA Contact: Filip Dvorak
URL:
Whiteboard:
Depends On:
Blocks: 2119704
TreeView+ depends on / blocked
 
Reported: 2022-03-14 13:48 UTC by Julien Rische
Modified: 2023-05-09 10:42 UTC (History)
1 user (show)

Fixed In Version: krb5-1.20.1-3.el9
Doc Type: If docs needed, set a value
Doc Text:
Clone Of:
: 2119704 (view as bug list)
Environment:
Last Closed: 2023-05-09 08:25:24 UTC
Type: Bug
Target Upstream Version:
Embargoed:


Attachments (Terms of Use)


Links
System ID Private Priority Status Summary Last Updated
Github krb5 krb5 pull 1264 0 None open Update error codes for OpenSSL CMS_verify 2022-08-02 07:40:57 UTC
Red Hat Issue Tracker FREEIPA-8006 0 None None None 2022-03-14 14:18:38 UTC
Red Hat Issue Tracker RHELPLAN-115510 0 None None None 2022-03-14 14:18:43 UTC
Red Hat Product Errata RHSA-2023:2570 0 None None None 2023-05-09 08:26:08 UTC

Description Julien Rische 2022-03-14 13:48:43 UTC
The signature verification part of the krb5 PKINIT plugin was initially implemented using PKCS7_verify[1], and error handling was written according to this function[2].

This code was modified[3] to use CMS_verify[4] when building against >= OpenSSL 1.0, but kept PKCS7_verify error codes handling.

As a consequence, the KDC_ERR_DIGEST_IN_SIGNED_DATA_NOT_ACCEPTED error, which should explain the digest algorithm is not support is no raised and an unrelated error is displayed:

"Failed to verify CMS message: content type not enveloped data"

Actual CMS_verify error codes should be handled.

[1] https://www.openssl.org/docs/man3.0/man3/PKCS7_verify.html
[2] https://github.com/krb5/krb5/blob/0ef0646069c1d1376aa632a4791ea7e429f5ae9b/src/plugins/preauth/pkinit/pkinit_crypto_openssl.c#L1290-L1297
[3] https://github.com/krb5/krb5/commit/1b57e7650da41dbef6a50c6e925583d6c8ed9e52#diff-4aab62556d7562101df00d240f5444ed99a48a8e00d06c57a9bf5cb29b8a1ea8R1395
[4] https://www.openssl.org/docs/man3.0/man3/CMS_verify.html

Comment 1 Julien Rische 2022-07-29 15:51:59 UTC
There are 2 points to fix:

  * Error codes have to be modified to match the new function.
  * The last error from OpenSSL stack should be picked rather that the first one which is always CMS_R_CONTENT_TYPE_NOT_ENVELOPED_DATA[1], therefore it does not allow to differentiate an error caused by an unaccepted digest algorithm and an invalid signature.

The error code we could expect based on the code of OpenSSL CMS signature verification are:

  * CMS_R_NO_MATCHING_DIGEST[2]
  * CMS_R_NO_MATCHING_SIGNATURE (not used in practice)
  * CMS_R_UNKNOWN_DIGEST_ALGORITHM[3]

But I've run some tests and the error codes that seems to be actually raised are:

  * EVP_R_INVALID_DIGEST: the OID is recognized the algorithm is not allowed by the policy in signature verification
  * RSA_R_DIGEST_NOT_ALLOWED: OpenSSL fails to infer a signature algorithm based on the digest one and the key type (the more generic code PROV_R_DIGEST_NOT_ALLOWED might be considered too)
  * CMS_R_VERIFICATION_FAILURE: signature verification failed

We should use ERR_peek_last_error()[4] instead of ERR_peek_error() in order to get these error codes.


[1] https://github.com/openssl/openssl/blob/openssl-3.0.1/crypto/cms/cms_err.c#L45-L46
[2] https://github.com/openssl/openssl/blob/openssl-3.0.1/crypto/cms/cms_lib.c#L458
[3] https://github.com/openssl/openssl/blob/openssl-3.0.1/crypto/cms/cms_sd.c#L869
[4] https://www.openssl.org/docs/man3.0/man3/ERR_peek_last_error.html

Comment 2 Julien Rische 2022-08-02 07:40:20 UTC
Pull request:
https://github.com/krb5/krb5/pull/1264

Comment 3 Julien Rische 2022-08-19 08:47:10 UTC
EVP_R_INVALID_DIGEST is actually raised by code in a downstream OpenSSL patch[1]. I will handle it in a krb5 downstream patch too.

[1] https://src.fedoraproject.org/rpms/openssl/blob/rawhide/f/0049-Allow-disabling-of-SHA1-signatures.patch#_217

Comment 18 errata-xmlrpc 2023-05-09 08:25:24 UTC
Since the problem described in this bug report should be
resolved in a recent advisory, it has been closed with a
resolution of ERRATA.

For information on the advisory (Moderate: krb5 security, bug fix, and enhancement update), and where to find the updated
files, follow the link below.

If the solution does not work for you, open a new bug report.

https://access.redhat.com/errata/RHSA-2023:2570


Note You need to log in before you can comment on or make changes to this bug.