-
Notifications
You must be signed in to change notification settings - Fork 697
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Improve rule file_permissions_ungroupowned for use in bootable containers #12584
base: master
Are you sure you want to change the base?
Improve rule file_permissions_ungroupowned for use in bootable containers #12584
Conversation
In systems based on bootable container images the `/sysroot` directory contains the filesystem of the image which should be excluded from the scanned files check.
If the `nss-altfiles` are installed and `/etc/nsswitch.conf` is configured to use `nss-altfiles`, the users group can be defined als in `/usr/lib/group` next to `/etc/group`. The `/usr/lib/group` is a valid source of group definitions and therefore needs to be consulted during the check if nsswitch is configured to use this file. The `nss-altfiles` is often used in bootable containers base images.
Add new Automatus test scenarios for rule file_permissions_ungroupowned that cover recent changes - exclusion of /sysroot and addition of /usr/lib/group as second source of group data.
Skipping CI for Draft Pull Request. |
<ind:filepath>/etc/group</ind:filepath> | ||
<ind:pattern operation="pattern match">^[^:]+:[^:]*:([\d]+):[^:]*$</ind:pattern> | ||
<ind:instance operation="greater than or equal" datatype="int">1</ind:instance> | ||
</ind:textfilecontent54_object> | ||
|
||
<ind:textfilecontent54_object id="object_usr_lib_group" version="1"> | ||
<ind:filepath>/usr/lib/group</ind:filepath> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It would be great to not read this file always but to read this file only if the nsswitch.conf is configured to use altfiles for groups. How can I implement this condition in OVAL?
Reflects the recent change that the check now considers /usr/lib/group in addition.
This datastream diff is auto generated by the check Click here to see the full diffNew content has different text for rule 'xccdf_org.ssgproject.content_rule_file_permissions_ungroupowned'.
--- xccdf_org.ssgproject.content_rule_file_permissions_ungroupowned
+++ xccdf_org.ssgproject.content_rule_file_permissions_ungroupowned
@@ -3,9 +3,11 @@
Ensure All Files Are Owned by a Group
[description]:
-If any file is not group-owned by a group present in /etc/group, the cause of the lack of
+If any file is not group-owned by a valid defined group, the cause of the lack of
group-ownership must be investigated. Following this, those files should be deleted or
-assigned to an appropriate group.
+assigned to an appropriate group. The groups need to be defined in /etc/group
+or in /usr/lib/group if nss-altfiles are configured to be used
+in /etc/nsswitch.conf.
Locate the mount points related to local devices by the following command:
$ findmnt -n -l -k -it $(awk '/nodev/ { print $2 }' /proc/filesystems | paste -sd,)
@@ -16,7 +18,7 @@
[warning]:
This rule only considers local groups as valid groups.
-If you have your groups defined outside /etc/group, the rule won't consider those.
+If you have your groups defined outside /etc/group or /usr/lib/group, the rule won't consider those.
[warning]:
This rule can take a long time to perform the check and might consume a considerable |
Code Climate has analyzed commit 6a30452 and detected 0 issues on this pull request. The test coverage on the diff in this pull request is 100.0% (50% is the threshold). This pull request will bring the total coverage in the repository to 60.9% (0.0% change). View more on Code Climate. |
I think this won't cover all situations. In bootable containers, for "system" users it's strongly recommended to use systemd DynamicUser=yes where possible. See https://containers.github.io/bootc/building/users-and-groups.html#using-dynamicuseryes-for-systemd-units. This isn't covered by our OVAL. |
Description:
/sysroot
from scanning/usr/lib/group
For more details, please read commit messages of all commits.
Rationale:
In systems based on bootable container images the
/sysroot
directory contains the filesystem of the image which should be excluded from the scanned files check.If the
nss-altfiles
are installed and/etc/nsswitch.conf
is configured to usenss-altfiles
, the users group can be definedalso in
/usr/lib/group
next to/etc/group
. The/usr/lib/group
is a valid source of group definitions and therefore needs to be consulted during the check if nsswitch is configured to use this file. Thenss-altfiles
is often used in bootable containers base images.Review Hints:
Build CS9 data stream and apply STIG profile in podman build of an image based on quay.io/centos-bootc/centos-bootc:stream9.