stig-hardening: first-boot SELinux relabel + FIPS PAM (default and subrelease-90) - #1669
Open
dcasota wants to merge 2 commits into
Open
stig-hardening: first-boot SELinux relabel + FIPS PAM (default and subrelease-90)#1669dcasota wants to merge 2 commits into
dcasota wants to merge 2 commits into
Conversation
…brelease-90) Rebased onto the current 5.0 head, clearing the conflict this PR had been sitting in. fix-selinux-relabel-first-boot.patch The installer kernel has SELinux compiled in but boots with no policy loaded, so lsetxattr for security.selinux returns EINVAL and install-time labeling is not possible. Files created by the STIG playbook during installation are therefore unlabeled_t, and confined processes are denied access to them once the installed system boots enforcing. Adds a oneshot selinux-relabel.service that runs restorecon -R / on first boot. fix-stig-playbook-fips-pam.patch PAM faillock guard, FIPS module config, IMA hash. Verified on a live install: SELinux comes up Enforcing, the playbook completes with 0 failed tasks, and the second boot is clean - 0 failed units, 0 AVC denials. The known first-boot race documented in the patch header is reproduced exactly (57 denials against unlabeled_t, and systemd-sysctl fails to read zz-stig-hardening.conf so the STIG sysctls are not applied on boot 1); a reboot resolves it, as documented. Change-Id: I5be0d139c84e5b6eb292684c6ed24552c534f377 Signed-off-by: Daniel Casota <dcasota@gmail.com>
…book files
selinux-relabel.service declared only Before=getty-pre.target
sysinit.target. systemd-sysctl.service also sets DefaultDependencies=no
and declares only Before=sysinit.target, so the two are each ordered
against that target but not against each other, and systemd is free to
run them in either order. Measured on a STIG install, it ran
systemd-sysctl first:
18:19:23 Starting Apply Kernel Variables...
18:19:23 AVC denied { read } comm="systemd-sysctl"
name="zz-stig-hardening.conf" tcontext=unlabeled_t permissive=0
18:19:23 Failed to start Apply Kernel Variables.
18:19:24 Starting SELinux Relabel Filesystem (first boot)...
The playbook writes zz-stig-hardening.conf during installation, where the
installer kernel has SELinux compiled in but no policy loaded, so the file
is unlabeled_t. Under Enforcing, systemd_sysctl_t is denied read on it,
and systemd-sysctl aborts on the first unreadable file - so every kernel
parameter in that file is silently absent for the whole first boot. On a
system installed to be STIG-hardened that is a compliance gap, not the
cosmetic first-boot noise the patch header previously described.
Add an explicit Before= against the units that consume playbook-written
files. Both the default and the subrelease-90 copies are updated.
Change-Id: Iddb0543f8077297151d2d9da2b345eb4f9dc061f
Signed-off-by: Daniel Casota <dcasota@gmail.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Add the first-boot SELinux relabel service and the FIPS PAM fixes to stig-hardening, across the maintained 5.0 subrelease variants:
SPECS/stig-hardening(subrelease ≥ 92; also used by 91) → 2.1-10SPECS/90/stig-hardening(subrelease 90) → 2.1-5.1.3Both add:
fix-selinux-relabel-first-boot.patch— first-boot SELinux relabel service for unlabeled filesystems.fix-stig-playbook-fips-pam.patch— PHTN-50-000192 pam_faillock guard, FIPS module config, IMA hash.Why the relabel service is needed
The installer kernel has SELinux compiled in but boots with no policy loaded, so
lsetxattrforsecurity.selinuxreturnsEINVALand install-time labeling is impossible. Every file the STIG Ansible playbook writes during installation therefore lands asunlabeled_t. When the installed system boots withSELINUX=enforcing, confined processes are denied access to those files.Ordering fix — the relabel must run before the units that read those files
The service originally declared only:
Before=getty-pre.target sysinit.targetThat is not sufficient.
systemd-sysctl.servicealso setsDefaultDependencies=noand declares onlyBefore=sysinit.target, so the two units are each ordered against that target but not against each other — systemd is free to run them in either order. On a measured STIG install it ransystemd-sysctlfirst:systemd-sysctlaborts on the first unreadable file, so every kernel parameter inzz-stig-hardening.confis silently absent for the whole first boot. On a system installed specifically to be STIG-hardened that is a compliance gap, not the cosmetic first-boot noise the patch header previously described — so the "known limitation / a reboot resolves all failures" note has been replaced with the fix.The service now also declares:
Before=systemd-sysctl.service auditd.service systemd-networkd.servicesystemd-sysctl.serviceisDefaultDependencies=no, so an explicitBefore=is the only thing that can constrain it. Applied to both the default and the subrelease-90 copies.Testing
Reproduced and diagnosed on permutations k03 (minimal / POI 2.8 / STIG / ext4 / kickstart) and k04 (same, btrfs) — filesystem-independent, identical failure on both:
guest.failed_unitssystemd-sysctl.servicefailedauditctl50,chmod31,modprobe,iptables,sshd-session)The relabel itself works correctly — zero denials after it runs, which is why a reboot cleared the symptom. Only the ordering was wrong.
Rebased onto current 5.0 (the earlier branch was ~124 commits behind, which made the diff noisy); the change touches only stig-hardening.
🤖 Generated with Claude Code