Bug 2012308

Summary: Add client certificate validation D-Bus API (dependency of cockpit CVE-2021-3698 fix)
Product: Red Hat Enterprise Linux 8 Reporter: Alexey Tikhonov <atikhono>
Component: sssdAssignee: Iker Pedrosa <ipedrosa>
Status: CLOSED ERRATA QA Contact: Scott Poore <spoore>
Severity: high Docs Contact:
Priority: unspecified    
Version: 8.5CC: dlavu, grajaiya, jhrozek, lslebodn, mzidek, pbrezina, sgadekar, tscherf
Target Milestone: rcKeywords: Triaged
Target Release: ---Flags: pm-rhel: mirror+
Hardware: Unspecified   
OS: Unspecified   
Whiteboard: sync-to-jira
Fixed In Version: sssd-2.6.2-1.el8 Doc Type: If docs needed, set a value
Doc Text:
Story Points: ---
Clone Of: Environment:
Last Closed: 2022-05-10 15:26:45 UTC Type: Bug
Regression: --- Mount Type: ---
Documentation: --- CRM:
Verified Versions: Category: ---
oVirt Team: --- RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: --- Target Upstream Version:
Embargoed:
Bug Depends On: 2011216    
Bug Blocks:    

Description Alexey Tikhonov 2021-10-08 19:01:43 UTC
This bug was initially created as a copy of Bug #1992432

I am copying this bug because: to track fix for RHEL8



Description of problem:

Cockpit has initial support for client certificate (aka smart card) logins. This is currently only supported for machines joined to IdM (FreeIPA or AD) where you import and compare against the full client certificate with org.freedesktop.sssd.infopipe.Users.FindByCertificate(). There is no further validation of the certificate right now.

We'd like to make this both more robust and also allow this with certmap matchrules. For the latter it's absolutely crucial to ensure that the certificate is signed by an admin-specified CA, plus the usual extra checks (CRL file or OCSP, as configured). It's not strictly necessary for full certificate imports, but it'd be a desirable hardening step anyway.

For that we would like to have a D-Bus API that exposes sssd's cert validation. Right now that's done internally by pam_sss and the like, they apparently do cert validation and cert mapping as two distinct steps. There are reasons why they are separate (@sumit-bose mentioned on the meeting that mapping is done more often and is much cheaper than validation), so it should have a separate API as well. Something like org.freedesktop.sssd.infopipe.Users.ValidateCertificate s → void which gets the certificate PEM and throws a DbusError on failures, or alternatively returns a success/error code.

cockpit could then attempt to use that new API, and if the method does not exist, fall back to the current behaviour or do something more heuristic (like, erroring out when the mapped user is local, as then it's most likely a certmap one), and eventually require the new API.

The most important aspect of this is that this keeps the configuration like pam_cert_db_path, crl_file, ocsp_* etc. in sssd.conf and conf.d. cockpit-tls neither should (too complex) nor could (files are readable for root only) inspect these. It also avoids code duplication, as sssd already has all that validation logic.

As a kind of bonus it would be nice to expose the CA as a property on the InfoPipe object (or a GetCA() method), if it was set in the config. This would allow the server to send the expected CAs (or at least its properties) with the TLS handshake, using gnutls-x509-trust-list-add-cas() or a similar function. This may allow the web browser a more intelligent pre-selection of available certificates. But that's not crucial, and I'm also happy to split that out into a separate issue.


Version-Release number of selected component (if applicable):


sssd-2.5.2-2.el8.x86_64

Comment 2 Iker Pedrosa 2021-10-29 08:56:33 UTC
Upstream ticket:
https://github.com/SSSD/sssd/issues/5851

Comment 3 Alexey Tikhonov 2021-10-29 11:24:47 UTC
Upstream PR: https://github.com/SSSD/sssd/pull/5852

Comment 4 Alexey Tikhonov 2021-11-09 14:36:14 UTC
Pushed PR: https://github.com/SSSD/sssd/pull/5852

* `master`
    * 50e6070e4784e4a9a01ce26bd08229a07557948a - Tests: ifp interface to validate certificate
    * cf75d897b8ef03fdc471059214e86824f19b1bd1 - ifp: new interface to validate a certificate

Comment 10 Alexey Tikhonov 2021-12-15 12:39:17 UTC
Additional patch: https://github.com/SSSD/sssd/pull/5918

Comment 12 Alexey Tikhonov 2021-12-20 10:10:13 UTC
Pushed PR: https://github.com/SSSD/sssd/pull/5918

* `master`
    * fd0f087ada2f4a59d4b22846d06f1b19fd522e11 - ifp: improve FindByValidCertificate() error
    * 8d54b8c029d276801b323dfe045a155a4311ee49 - man: update ifp options for FindByValidCertificate

Comment 16 errata-xmlrpc 2022-05-10 15:26:45 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 (sssd 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/RHBA-2022:2070