CMP-4609: Fix file_permissions_scheduler rule to check for 0600 per CIS Benchmark - #15028
Conversation
|
Hi @taimurhafeez. 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 Tip We noticed you've done this a few times! Consider joining the org to skip this step and gain Once the patch is verified, the new status will be reflected by the I understand the commands that are listed here. DetailsInstructions 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. |
|
/ok-to-test |
|
@taimurhafeez: Cannot trigger testing until a trusted user reviews the PR and leaves an DetailsIn response to this:
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. |
|
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_scheduler'.
--- xccdf_org.ssgproject.content_rule_file_permissions_scheduler
+++ xccdf_org.ssgproject.content_rule_file_permissions_scheduler
@@ -6,7 +6,7 @@
[description]:
To properly set the permissions of /etc/kubernetes/static-pod-resources/kube-scheduler-pod-*/kube-scheduler-pod.yaml, run the command:
-$ sudo chmod 0644 /etc/kubernetes/static-pod-resources/kube-scheduler-pod-*/kube-scheduler-pod.yaml
+$ sudo chmod 0600 /etc/kubernetes/static-pod-resources/kube-scheduler-pod-*/kube-scheduler-pod.yaml
[warning]:
This rule is only applicable for nodes that run the Kubernetes Scheduler service.
OCIL for rule 'xccdf_org.ssgproject.content_rule_file_permissions_scheduler' differs.
--- ocil:ssg-file_permissions_scheduler_ocil:questionnaire:1
+++ ocil:ssg-file_permissions_scheduler_ocil:questionnaire:1
@@ -12,6 +12,6 @@
Then,run the command:
$ ls -l /etc/kubernetes/static-pod-resources/kube-scheduler-pod-*/kube-scheduler-pod.yaml
If properly configured, the output should indicate the following permissions:
--rw-r--r--
- Is it the case that /etc/kubernetes/static-pod-resources/kube-scheduler-pod-*/kube-scheduler-pod.yaml does not have unix mode -rw-r--r--?
+-rw-------
+ Is it the case that /etc/kubernetes/static-pod-resources/kube-scheduler-pod-*/kube-scheduler-pod.yaml does not have unix mode -rw-------?
|
|
/ok-to-test |
|
/ok-to-test |
|
/test e2e-aws-openshift-platform-compliance |
|
@taimurhafeez: The following tests failed, say
Full PR test history. Your PR dashboard. DetailsInstructions 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. |
Problem
The rule
file_permissions_scheduler(CIS Benchmark control 1.1.5) checks the permissions of/etc/kubernetes/static-pod-resources/kube-scheduler-pod-*/kube-scheduler-pod.yamlon master nodes.The rule was configured with
filemode: 0644, but the CIS Benchmark requires0600. On OCP clusters, these files already ship with the correct0600permissions (-rw-------).This caused two issues:
chmod 0644, which would weaken the existing0600permissions by adding group-read and other-read access.0644(suid, sgid, sticky, uexec, gwrite, gexec, owrite, oexec). It did not flaggreadororeadas violations, meaning a file with0644would incorrectly pass when it should fail per CIS requirements.Fix
Changed the
filemodetemplate parameter from0644to0600inapplications/openshift/master/file_permissions_scheduler/rule.yml.This produces four changes in the generated content:
chmod 0644→chmod 0600-rw-r--r--→-rw-------greadandoreadto the list of prohibited permission bits (matching the existing pattern used by 10 other rules likeetcd_data_files,master_admin_kubeconfigs,openshift_pki_key_files)mode_not_0644→mode_not_0600How to Reproduce / Verify
Reproduce the bug (before the fix)
oc get rules.compliance -n openshift-compliance ocp4-file-permissions-scheduler -o yamlchmod 0644and instructions say-rw-r--r--600(-rw-------), not644Verify the fix
./build_product ocp4 --datastreampodman build -f Dockerfiles/compliance_operator_content.Dockerfile -t <registry>/content:fix .oc patch profilebundle ocp4 -n openshift-compliance --type merge -p '{"spec":{"contentImage":"<registry>/content:fix"}}'chmod 0600and-rw-------0600Verified on
0600