Fix STIG playbook: PAM faillock guard, FIPS module config, IMA hash - #1643
Fix STIG playbook: PAM faillock guard, FIPS module config, IMA hash#1643dcasota wants to merge 2 commits into
Conversation
Category A fixes for the STIG hardening playbook (backward-compatible
with Ansible 2.14+ and audit 3.x/4.x):
1. Add '| default("")' to PHTN-50-000192 pam_faillock when: conditions
to prevent PAM stack corruption when regex_search() returns None
2. Add ima_hash=sha256 kernel parameter when fips=1 is active
3. Generate /etc/ssl/fipsmodule.cnf when FIPS provider is present but
config is missing
Change-Id: If2b2c4ac079d6ef41ac521acb59d010200a95003
Co-authored-by: factory-droid[bot] <138933559+factory-droid[bot]@users.noreply.github.com>
4a9c6a5 to
24cffc3
Compare
|
Extended this PR to also cover the pinned-91 spec. The original PR only touched New commit (
Why the same patch file is safe in both locations:
|
The original PR added fix-stig-playbook-fips-pam.patch only to
SPECS/stig-hardening/ (subrelease >= 92, Ansible 2.20). The same
patch is also applicable to SPECS/91/stig-hardening/ (subrelease
<= 91, Ansible 2.14+):
* IMA hash=sha256 and fipsmodule.cnf generation are kernel/
OpenSSL concerns, independent of Ansible version, and are
needed by any pinned-91 build that boots with fips=1.
* The "| default('')" PAM faillock guard is a defensive no-op
on Ansible 2.14+ (regex_search returns "" on 2.14, not None),
so the same patch can be reused verbatim.
Both the >=92 and <=91 specs apply Patch0 + Patch1 to the same
upstream tarball, and Patch2 of the >=92 variant
(fix-photon.yml-for-latest-audit-and-ansible.patch) touches lines
that are disjoint from this patch (telnet regex at ~628, autrace
list at ~915), so re-using the same patch file with no edits is
safe.
Pinned-91 spec:
- Release: 5.1 -> 5.2
- Patch2: fix-stig-playbook-fips-pam.patch (new, identical
content to SPECS/stig-hardening/)
Tested per the PR's existing matrix (5.0 pinned91 row): sha256
allocated, fipsmodule.cnf generated, PAM faillock correct.
Signed-off-by: Daniel Casota <dcasota@gmail.com>
3b1971a to
428757c
Compare
|
Superseded by #1669. This PR targets Its substantive change is not lost: |
Problem
Upstream commit
85c56e7(Patch2, Release 2.1-6) fixed the STIG hardening playbook for Ansible 2.20 boolean conditionals and audit 4.x tool renames, but left three gaps:PHTN-50-000192 PAM stack corruption: The
regex_search()in the PAM faillock cleanupset_factstill returnsNoneunder Ansible 2.20. The comparisonpreauthsearch == ""evaluates toFalsewhenpreauthsearchisNone, causing the cleanup step to be skipped while the add step still runs, producing duplicatepam_faillock.soentries in/etc/pam.d/system-auth.Missing
ima_hash=sha256: IMA defaults to SHA1 which is disabled under FIPS, causingima: Can not allocate sha1 (reason: -2)during boot.Missing
fipsmodule.cnf: When the FIPS provider is installed but/etc/ssl/fipsmodule.cnfis absent, OpenSSL cannot initialize FIPS mode andpam_unix.sofails to verify passwords.Fix
Patch:
fix-stig-playbook-fips-pam.patch(Patch3, Release 2.1-7) -- all changes are backward-compatible with Ansible 2.14+:| default('')to PHTN-50-000192when:conditions (no-op when value is already a string on older Ansible)ima_hash=sha256kernel parameter whenfips=1is active/etc/ssl/fipsmodule.cnfviaopenssl fipsinstallwhen the FIPS provider is present but config is missingCompatibility
| default('')Nonecomparison errorima_hash=sha256fipsmodule.cnfgenerationTesting
Tested on VMware Workstation (UEFI, TPM 2.0, VM encryption):
Known Issue: IMA SHA1 allocation under FIPS
The
ima_hash=sha256parameter redirects IMA file measurements to SHA256, but the kernel still attempts SHA1 for the PCR bank (ima: Can not allocate sha1 (reason: -2)). This is non-fatal. A full fix requiresCONFIG_IMA_DEFAULT_HASH_SHA256in the kernel, as tracked in Ubuntu Bug #2041735.