Bug 2073605

Summary: FIPS mode detection in SSHD role is wrong
Product: Red Hat Enterprise Linux 9 Reporter: Jakub Jelen <jjelen>
Component: rhel-system-rolesAssignee: Rich Megginson <rmeggins>
Status: CLOSED ERRATA QA Contact: Jakub Haruda <jharuda>
Severity: unspecified Docs Contact: Jan Fiala <jafiala>
Priority: unspecified    
Version: 9.0CC: briasmit, djez, gfialova, jharuda, kanderso, nhosoi, pkettman, rmeggins, spetrosi, szidek
Target Milestone: rcKeywords: ZStream
Target Release: 9.1Flags: pkettman: needinfo+
pkettman: needinfo+
Hardware: Unspecified   
OS: Unspecified   
Whiteboard: role:sshd
Fixed In Version: rhel-system-roles-1.18.0-1.el9 Doc Type: No Doc Update
Doc Text:
Story Points: ---
Clone Of:
: 2075338 2077475 (view as bug list) Environment:
Last Closed: 2022-11-15 10:23:26 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:    
Bug Blocks: 2075338, 2077475    

Description Jakub Jelen 2022-04-08 22:04:39 UTC
Description of problem:
This is a follow-up from the bug #2029634 and #2029634, which implements the FIPS mode detection, but it is not correct because of two reasons:

 * any RHEL/Fedora configuration is detected as in FIPS mode
 * the templates are not modified to exclude the fips hostkeys (only the meta/10_top.j2 was modified, but the templates were not regenerated)

The result is that regardless the FIPS mode status, the ed25519 hostkeys
are not generated and checked:
```
TASK [ansible-sshd : Make sure hostkeys are available] **************************************************************
ok: [localhost] => (item=/etc/ssh/ssh_host_rsa_key) => {...}
ok: [localhost] => (item=/etc/ssh/ssh_host_ecdsa_key) => {...}
```
but they are included in the configuration file:
```
[root@5c5bfece6a22 tests]# cat /etc/ssh/sshd_config
[...]
HostKey /etc/ssh/ssh_host_ed25519_key
```

This is handled on non-fips systems by the systemd service which probably generates the keys and sshd stars ok in real systems (I tested only in containers so far). On FIPS systems, it might fail to start the service.

Version-Release number of selected component (if applicable):
rhel-system-roles-1.11.0-1.el8
rhel-system-roles-1.11.0-1.el9

How reproducible:
always

Steps to Reproduce:
1. set system into fips mode on RHEL8
2. run sshd role with default parameters

Actual results:
 * the ed25519 key is listed in configuration file in FIPS mode
 * the ed25519 key is NOT checked/created by the role out of FIPS mode

Expected results:
 * the ed25519 key is NOT listed in configuration file in FIPS mode
 * the ed25519 key is checked/created by the role out of FIPS mode


Additional info:
on RHEL9, this will not demonstrate as there are no default hostkeys in configuration file as the drop-in directory is used.

Comment 1 Jakub Jelen 2022-04-08 22:12:42 UTC
The fix for this is first couple of commits in https://github.com/willshersystems/ansible-sshd/pull/178 which I started putting together while working on other feature. I will probably split them into separate PR to simplify things, but most of the changes are needed to unbreak the CI anyway.

Comment 2 Jakub Jelen 2022-04-11 12:31:59 UTC
The current patch-set to unbreak FIPS detection including tests:

https://github.com/willshersystems/ansible-sshd/pull/179

I would be glad for review/comments either in this or previous PR.

We talked with David that we might want to relase these changes as part of the 0day (8.6 and 9.0), but it will depend on how much risky the changes and the bug itself will be considered.

Comment 15 Fedora Update System 2022-05-11 01:18:53 UTC
FEDORA-2022-2da3a47337 has been pushed to the Fedora 36 stable repository.
If problem still persists, please make note of it in this bug report.

Comment 16 Fedora Update System 2022-05-11 01:25:01 UTC
FEDORA-2022-d6e6c7c37c has been pushed to the Fedora 35 stable repository.
If problem still persists, please make note of it in this bug report.

Comment 17 Fedora Update System 2022-05-11 01:35:23 UTC
FEDORA-2022-671a5d63e6 has been pushed to the Fedora 34 stable repository.
If problem still persists, please make note of it in this bug report.

Comment 26 errata-xmlrpc 2022-11-15 10:23:26 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 (rhel-system-roles 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/RHEA-2022:8117