Skip to content

Update rule to allow special bits in library dirs#8768

Merged
vojtapolasek merged 1 commit intoComplianceAsCode:masterfrom
yuumasato:file_mode_library_dirs_allow_special_bits
May 16, 2022
Merged

Update rule to allow special bits in library dirs#8768
vojtapolasek merged 1 commit intoComplianceAsCode:masterfrom
yuumasato:file_mode_library_dirs_allow_special_bits

Conversation

@yuumasato
Copy link
Copy Markdown
Member

Description:

  • Update file_permissions_library_dirs to allow special bits in the library dirs.
    • This will generate remediations that remove the write bit from group and others:
      e.g.: find -H /lib/ -perm /g+w,o+w -type f -regex '^.*$' -exec chmod g-w,o-w {} \;

Rationale:

@yuumasato yuumasato added this to the 0.1.62 milestone May 13, 2022
@yuumasato yuumasato requested a review from ggbecker May 13, 2022 14:01
@github-actions
Copy link
Copy Markdown

Start a new ephemeral environment with changes proposed in this pull request:

Open in Gitpod

@github-actions
Copy link
Copy Markdown

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

Click here to see the full diff
bash remediation for rule 'xccdf_org.ssgproject.content_rule_file_permissions_library_dirs' differs:
--- old datastream
+++ new datastream
@@ -2,10 +2,10 @@
 
 
 
-find -H /lib/ -perm /u+s,g+ws,o+wt -type f -regex '^.*$' -exec chmod u-s,g-ws,o-wt {} \;
+find -H /lib/ -perm /g+w,o+w -type f -regex '^.*$' -exec chmod g-w,o-w {} \;
 
-find -H /lib64/ -perm /u+s,g+ws,o+wt -type f -regex '^.*$' -exec chmod u-s,g-ws,o-wt {} \;
+find -H /lib64/ -perm /g+w,o+w -type f -regex '^.*$' -exec chmod g-w,o-w {} \;
 
-find -H /usr/lib/ -perm /u+s,g+ws,o+wt -type f -regex '^.*$' -exec chmod u-s,g-ws,o-wt {} \;
+find -H /usr/lib/ -perm /g+w,o+w -type f -regex '^.*$' -exec chmod g-w,o-w {} \;
 
-find -H /usr/lib64/ -perm /u+s,g+ws,o+wt -type f -regex '^.*$' -exec chmod u-s,g-ws,o-wt {} \;
+find -H /usr/lib64/ -perm /g+w,o+w -type f -regex '^.*$' -exec chmod g-w,o-w {} \;

ansible remediation for rule 'xccdf_org.ssgproject.content_rule_file_permissions_library_dirs' differs:
--- old datastream
+++ new datastream
@@ -1,5 +1,5 @@
 - name: Find /lib/ file(s) recursively
- command: find -H /lib/ -perm /u+s,g+ws,o+wt -type f -regex "^.*$"
+ command: find -H /lib/ -perm /g+w,o+w -type f -regex "^.*$"
 register: files_found
 changed_when: false
 failed_when: false
@@ -21,7 +21,7 @@
 - name: Set permissions for /lib/ file(s)
 file:
 path: '{{ item }}'
- mode: u-s,g-ws,o-wt
+ mode: g-w,o-w
 state: file
 with_items:
 - '{{ files_found.stdout_lines }}'
@@ -40,7 +40,7 @@
 - no_reboot_needed
 
 - name: Find /lib64/ file(s) recursively
- command: find -H /lib64/ -perm /u+s,g+ws,o+wt -type f -regex "^.*$"
+ command: find -H /lib64/ -perm /g+w,o+w -type f -regex "^.*$"
 register: files_found
 changed_when: false
 failed_when: false
@@ -62,7 +62,7 @@
 - name: Set permissions for /lib64/ file(s)
 file:
 path: '{{ item }}'
- mode: u-s,g-ws,o-wt
+ mode: g-w,o-w
 state: file
 with_items:
 - '{{ files_found.stdout_lines }}'
@@ -81,7 +81,7 @@
 - no_reboot_needed
 
 - name: Find /usr/lib/ file(s) recursively
- command: find -H /usr/lib/ -perm /u+s,g+ws,o+wt -type f -regex "^.*$"
+ command: find -H /usr/lib/ -perm /g+w,o+w -type f -regex "^.*$"
 register: files_found
 changed_when: false
 failed_when: false
@@ -103,7 +103,7 @@
 - name: Set permissions for /usr/lib/ file(s)
 file:
 path: '{{ item }}'
- mode: u-s,g-ws,o-wt
+ mode: g-w,o-w
 state: file
 with_items:
 - '{{ files_found.stdout_lines }}'
@@ -122,7 +122,7 @@
 - no_reboot_needed
 
 - name: Find /usr/lib64/ file(s) recursively
- command: find -H /usr/lib64/ -perm /u+s,g+ws,o+wt -type f -regex "^.*$"
+ command: find -H /usr/lib64/ -perm /g+w,o+w -type f -regex "^.*$"
 register: files_found
 changed_when: false
 failed_when: false
@@ -144,7 +144,7 @@
 - name: Set permissions for /usr/lib64/ file(s)
 file:
 path: '{{ item }}'
- mode: u-s,g-ws,o-wt
+ mode: g-w,o-w
 state: file
 with_items:
 - '{{ files_found.stdout_lines }}'

@vojtapolasek vojtapolasek self-assigned this May 16, 2022
Copy link
Copy Markdown
Collaborator

@vojtapolasek vojtapolasek left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I confirm this works as expected. The rule does not react to changes in suid / sgid bits, it reacts only if there are group or world writable files within designated directories.

@vojtapolasek
Copy link
Copy Markdown
Collaborator

Could you please just rebase on master so that tests run properly?aaa

Rule file_permissions_library_dirs is about preventing group-writable or
world-writable files in the library dirs. The Suid bits and the stick
bit don't need to be stripped.

The default mode of file_permissions is to allow stricter permissions,
so this change will make the template ignore the special bits and remove
only the 'w' bits from group and others.
@yuumasato yuumasato force-pushed the file_mode_library_dirs_allow_special_bits branch from 201cb09 to 3bf26b7 Compare May 16, 2022 13:44
@yuumasato
Copy link
Copy Markdown
Member Author

@vojtapolasek rebased.

@qlty-cloud-legacy
Copy link
Copy Markdown

Code Climate has analyzed commit 3bf26b7 and detected 0 issues on this pull request.

View more on Code Climate.

@openshift-ci
Copy link
Copy Markdown

openshift-ci Bot commented May 16, 2022

@yuumasato: The following tests 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-rhcos4-moderate 3bf26b7 link true /test e2e-aws-rhcos4-moderate
ci/prow/e2e-aws-rhcos4-e8 3bf26b7 link true /test e2e-aws-rhcos4-e8
ci/prow/e2e-aws-rhcos4-high 3bf26b7 link true /test e2e-aws-rhcos4-high

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/test-infra repository. I understand the commands that are listed here.

@vojtapolasek vojtapolasek merged commit 516e7b1 into ComplianceAsCode:master May 16, 2022
@yuumasato yuumasato deleted the file_mode_library_dirs_allow_special_bits branch May 16, 2022 17:13
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

rpm_verify_permission and file_permissions_library_dirs conflict - /usr/lib/polkit-1/polkit-agent-helper-1 permissions

2 participants