Skip to content

Accept root as group owner of SSH private host keys - #15310

Open
spnngl wants to merge 1 commit into
ComplianceAsCode:masterfrom
spnngl:sshd-private-key-root-group
Open

spnngl wants to merge 1 commit into
ComplianceAsCode:masterfrom
spnngl:sshd-private-key-root-group

Conversation

@spnngl

@spnngl spnngl commented Nov 6, 2026

Copy link
Copy Markdown
Contributor

Description:

  • file_groupownership_sshd_private_key accepts the root group beside the dedicated SSH key group (dedicated_ssh_keyowner, ssh_keys) for the products that set one. The description says so.
  • New test scenario root_groupowner.pass.sh.

Rationale:

  • Fedora's sshd-keygen (/usr/libexec/openssh/sshd-keygen, openssh-server 10.2p1 in Fedora 44) writes the host keys root:root with mode 0600, without chgrp. Fedora's product sets dedicated_ssh_keyowner: ssh_keys, so the rule fails on a default install although the keys are as strict as can be.
  • file_permissions_sshd_private_key already accepts root:root 0600 (supercompliance.pass.sh), and CIS's audit accepts root or the SSH key group: the two rules of the same CIS control now agree.
  • The remediations are unchanged for keys owned by neither group: the dedicated group comes first in gid_or_name, so chgrp still sets it.

Review Hints:

  • ./build_product fedora --datastream-only, then in a Fedora CoreOS 44 container (quay.io/fedora/fedora-coreos:44.20261023.3.1, with openscap-scanner and scap-security-guide 0.1.82 installed), after /usr/libexec/openssh/sshd-keygen ed25519:

    oscap oval eval --id oval:ssg-file_groupownership_sshd_private_key:def:1 <oval.xml>
    Key group 0.1.82 this branch
    root false true
    ssh_keys true true
    another group false false

Fedora sshd-keygen writes the host keys root:root 0600, and products
that set dedicated_ssh_keyowner (Fedora, RHEL, OL, AlmaLinux, AL2023,
RHCOS) only accepted the ssh_keys group, so a default Fedora install
fails file_groupownership_sshd_private_key. The root group is as strict:
file_permissions_sshd_private_key already accepts root:root 0600, and
CIS asks for root or the dedicated group.

The remediations still set the dedicated group on keys owned by neither,
as it comes first in gid_or_name.
@openshift-ci openshift-ci Bot added the needs-ok-to-test Used by openshift-ci bot. label Nov 6, 2026
@openshift-ci

openshift-ci Bot commented Nov 6, 2026

Copy link
Copy Markdown

Hi @spnngl. Thanks for your PR.

I'm waiting for a ComplianceAsCode member to verify that this patch is reasonable to test. If it is, they should reply with /ok-to-test on its own line. Until that is done, I will not automatically test new commits in this PR, but the usual testing commands by org members will still work.

Regular contributors should join the org to skip this step.

Once the patch is verified, the new status will be reflected by the ok-to-test label.

I understand the commands that are listed here.

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.

spnngl added a commit to spnngl/images that referenced this pull request Nov 6, 2026
A node of 44-v1.35 scored 94.19, 8 rules failed:

- user init files: core's home files, 0644 from /etc/skel. The
  initramfs, rebuilt without dracut modules ignition-conf and
  ignition-conf-fcos, no longer creates the core user nor enables
  afterburn-sshkeys@core: rootless is the only login.
- world-writable, unowned and ungrouped files: the containers' (image
  owners, kubelet's 0666 termination-log, emptyDir), and again through
  /sysroot. openscap.service hides /sysroot, containerd's storage and the
  pods' volumes; the rules still check the host.
- rpcbind: removed with its NFSv3 dependants; NFSv4 needs none.
- SSH host keys group: Fedora writes them root:root 0600, the check wants
  ssh_keys. A sshd-keygen@ drop-in sets it until
  ComplianceAsCode/content#15310 accepts root.
- /boot/grub2 permissions: off, console.cfg and bootuuid.cfg are 0644 on
  a read-only /boot and hold nothing secret.
@Mab879 Mab879 self-assigned this Nov 6, 2026
@Mab879

Mab879 commented Nov 6, 2026

Copy link
Copy Markdown
Member

I'm wondering that maybe this should be am XCCDF variable, not a build time one.

I will need to double check the underlying policies to make sure this allowable as well.

spnngl added a commit to spnngl/images that referenced this pull request Nov 9, 2026
The node scan failed file_permissions_sshd_private_key on every node.
Its check takes ssh_keys' GID from /etc/group only, and FCOS keeps the
group in /usr/lib/group, so the root:ssh_keys keys the sshd-keygen@
drop-in made counted as offending. That drop-in only kept
file_groupownership_sshd_private_key passing: the two rules can't both
pass.

- Drop 50-ssh-keys-group.conf: keys stay Fedora's root:root 0600.
- Turn file_groupownership_sshd_private_key off in the node profile,
  until ComplianceAsCode/content#15310 accepts root.
- Test for root:root 0600.

Nodes made with the drop-in keep root:ssh_keys keys.
spnngl added a commit to spnngl/images that referenced this pull request Nov 9, 2026
The node scan failed file_permissions_sshd_private_key on every node.
Its check takes ssh_keys' GID from /etc/group only, and FCOS keeps the
group in /usr/lib/group, so the root:ssh_keys keys the sshd-keygen@
drop-in made counted as offending. That drop-in only kept
file_groupownership_sshd_private_key passing: the two rules can't both
pass.

- Drop 50-ssh-keys-group.conf: keys stay Fedora's root:root 0600.
- Turn file_groupownership_sshd_private_key off in the node profile,
  until ComplianceAsCode/content#15310 accepts root.
- Test for root:root 0600.

Nodes made with the drop-in keep root:ssh_keys keys.

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

needs-ok-to-test Used by openshift-ci bot.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants