Skip to content

Require 0600 for group-owned SSH private keys in the OVAL check - #15056

Merged
Mab879 merged 1 commit into
ComplianceAsCode:masterfrom
ggbecker:fix-ssh-keys-dedicated-group-0600
Aug 26, 2026
Merged

Require 0600 for group-owned SSH private keys in the OVAL check#15056
Mab879 merged 1 commit into
ComplianceAsCode:masterfrom
ggbecker:fix-ssh-keys-dedicated-group-0600

Conversation

@ggbecker

Copy link
Copy Markdown
Member

Description:

  • Require mode 0600 for group-owned SSH private host keys in the OVAL check, so root:<dedicated group> (e.g. root:ssh_keys) keys at 0640 are now flagged as a finding on non-immutable systems. The 0640 group-readable exception now applies to rhcos4 only.
  • Align the rule description, the Puppet remediation (which hardcoded 0640), and the test scenarios with this behavior.

Rationale:

  • PR Require 0600 permissions for SSH private keys on non-immutable systems #15015 restricted the 0640 exception to rhcos4, but the exception is implemented twice in the OVAL check — once for root:root and once for root:<dedicated group>. Only the root:root state was gated, so root:ssh_keys 0640 keys (the RHEL default) still passed even though the Bash/Ansible remediations already enforce 0600.
  • This caused SSG to report pass while DISA's SCAP content reported fail for SV-230287 on stock RHEL. This change closes that gap and matches the DISA STIG.

Review Hints:

  • The core fix is a single gread gate in oval/shared.xml; the built OVAL now sets gread=false for both the root and dedicated-group filter states.
  • The default RHEL host keys ship as root:ssh_keys 0640, so the two whole-system pass scenarios (supercompliance.pass.sh, altcorrect_permissions.pass.sh) now harden pre-existing keys first. New dedicated_group_lenient.fail.sh covers the root:<group> 0640 regression.
  • Run automatus tests for the affected rule

PR ComplianceAsCode#15015 restricted the 0640 group-readable exception to rhcos4 only,
but that exception is implemented twice in the OVAL check: once for the
root:root file state and once for the root:<dedicated_ssh_keyowner>
state. Only the root:root state was gated to rhcos4; the dedicated-group
state still left group-read "not considered", so keys owned
root:ssh_keys with mode 0640 (the RHEL default) still passed the check
even though the bash and ansible remediations already enforce 0600.

Gate the dedicated-group group-read bit to rhcos4 as well, so all
non-immutable products require 0600 regardless of group ownership,
matching the DISA STIG (SV-230287) and the existing remediations.

Also update the rule description, the puppet remediation (which
hardcoded 0640 for every product), and the test scenarios: the
group-owned pass scenario now uses 0600 and a new
dedicated_group_lenient.fail.sh asserts that a root:<group> key at 0640
is a finding on non-immutable systems.
@ggbecker ggbecker added this to the 0.1.83 milestone Aug 26, 2026
@ggbecker ggbecker added RHEL Red Hat Enterprise Linux product related. STIG STIG Benchmark related. backported-into-stabilization PRs which were cherry-picked during stabilization process. labels Aug 26, 2026
@github-actions

Copy link
Copy Markdown
Contributor

This datastream diff is auto generated by the check Compare DS/Generate Diff

Click here to see the full diff
New content has different text for rule 'xccdf_org.ssgproject.content_rule_file_permissions_sshd_private_key'.
--- xccdf_org.ssgproject.content_rule_file_permissions_sshd_private_key
+++ xccdf_org.ssgproject.content_rule_file_permissions_sshd_private_key
@@ -7,7 +7,7 @@
 [description]:
 SSH server private keys - files that match the /etc/ssh/*_key glob, have to have restricted permissions.
 If those files are owned by the root user and the root group, they have to have the 0600 permission or stricter.
-If they are owned by the root user, but by a dedicated group ssh_keys, they can have the 0640 permission or stricter.
+If they are owned by the root user, but by a dedicated group ssh_keys, they still have to have the 0600 permission or stricter.
 
 [warning]:
 Remediation is not possible at bootable container build time because SSH host

puppet remediation for rule 'xccdf_org.ssgproject.content_rule_file_permissions_sshd_private_key' differs.
--- xccdf_org.ssgproject.content_rule_file_permissions_sshd_private_key
+++ xccdf_org.ssgproject.content_rule_file_permissions_sshd_private_key
@@ -1,8 +1,11 @@
+
+
+
 include ssh_private_key_perms
 
 class ssh_private_key_perms {
   exec { 'sshd_priv_key':
-    command => "chmod 0640 /etc/ssh/*_key",
+    command => "chmod 0600 /etc/ssh/*_key",
     path    => '/bin:/usr/bin'
   }
 }

@Mab879 Mab879 self-assigned this Aug 26, 2026
@openshift-ci

openshift-ci Bot commented Aug 26, 2026

Copy link
Copy Markdown

@ggbecker: The following test failed, say /retest to rerun all failed tests or /retest-required to rerun all mandatory failed tests:

Test name Commit Details Required Rerun command
ci/prow/e2e-aws-openshift-platform-compliance ee6bcc8 link true /test e2e-aws-openshift-platform-compliance

Full PR test history. Your PR dashboard.

Details

Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes-sigs/prow repository. I understand the commands that are listed here.

@Mab879
Mab879 merged commit fd8276d into ComplianceAsCode:master Aug 26, 2026
72 of 74 checks passed
ggbecker added a commit to ggbecker/contest that referenced this pull request Aug 27, 2026
SSH host keys don't exist at image creation / anaconda install time, so
the remediation cannot fix them. They are generated on first boot by
sshd-keygen and only then become non-compliant, especially since
ComplianceAsCode/content#15056 now requires 0600 even for the ssh_keys
group owner while RHEL-generated keys are 0640 root:ssh_keys.
ggbecker added a commit to ggbecker/contest that referenced this pull request Sep 1, 2026
SSH host keys don't exist at image creation / anaconda install time, so
the remediation cannot fix them. They are generated on first boot by
sshd-keygen and only then become non-compliant, especially since
ComplianceAsCode/content#15056 now requires 0600 even for the ssh_keys
group owner while RHEL-generated keys are 0640 root:ssh_keys.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

backported-into-stabilization PRs which were cherry-picked during stabilization process. RHEL Red Hat Enterprise Linux product related. STIG STIG Benchmark related.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants