File permissions library dirs shall act on files when 'file_regex' is set#8420
Merged
vojtapolasek merged 3 commits intoComplianceAsCode:stabilization-v0.1.61from Mar 25, 2022
Conversation
The remediations should remediate regular files. No symlinks or the files they are pointing to should be changed. There are symlinks in `/lib/.buid-id/' that point to installed binaries. For example (the IDs will vary): '/lib/.build-id/a4/67cb9c8fa7306d41b96a820b0178f3a9c66055' -> '../../../../usr/bin/passwd' '/lib/.build-id/a4/8e8ae0d029dbbc1c1b0bb0fcea424860a6c412' -> '../../../../usr/bin/sudo' '/lib/.build-id/a4/2c53d4543f5c0bb8db47d65e4b766d12f3b7bd' -> '../../../../usr/lib64/python3.9/lib-dynload/_lsprof.cpython-39-x86_64-linux-gnu.so'
Member
Author
|
@dodys This reverts the |
|
This datastream diff is auto generated by the check Click here to see the full diffbash remediation for rule 'xccdf_org.ssgproject.content_rule_file_groupownership_audit_configuration' differs:
--- old datastream
+++ new datastream
@@ -1,18 +1,18 @@
# Remediation is applicable only in certain platforms
if rpm --quiet -q audit; then
-readarray -t files < <(find /etc/audit/ -maxdepth 1 ! -gid 0)
+readarray -t files < <(find /etc/audit/ -maxdepth 1 -type f ! -gid 0)
for file in "${files[@]}"; do
- if basename $file | grep -qE '^audit(\.rules|d\.conf)$'; then
- chgrp -h 0 "$file"
+ if basename "$file" | grep -qE '^audit(\.rules|d\.conf)$'; then
+ chgrp 0 "$file"
fi
done
-readarray -t files < <(find /etc/audit/rules.d/ -maxdepth 1 ! -gid 0)
+readarray -t files < <(find /etc/audit/rules.d/ -maxdepth 1 -type f ! -gid 0)
for file in "${files[@]}"; do
- if basename $file | grep -qE '^.*\.rules$'; then
- chgrp -h 0 "$file"
+ if basename "$file" | grep -qE '^.*\.rules$'; then
+ chgrp 0 "$file"
fi
done
bash remediation for rule 'xccdf_org.ssgproject.content_rule_file_ownership_audit_configuration' differs:
--- old datastream
+++ new datastream
@@ -1,17 +1,17 @@
# Remediation is applicable only in certain platforms
if rpm --quiet -q audit; then
-readarray -t files < <(find /etc/audit/ -maxdepth 1 ! -uid 0)
+readarray -t files < <(find /etc/audit/ -maxdepth 1 -type f ! -uid 0)
for file in "${files[@]}"; do
- if basename $file | grep -qE '^audit(\.rules|d\.conf)$'; then
- chown -h 0 "$file"
+ if basename "$file" | grep -qE '^audit(\.rules|d\.conf)$'; then
+ chown 0 "$file"
fi
done
-readarray -t files < <(find /etc/audit/rules.d/ -maxdepth 1 ! -uid 0)
+readarray -t files < <(find /etc/audit/rules.d/ -maxdepth 1 -type f ! -uid 0)
for file in "${files[@]}"; do
- if basename $file | grep -qE '^.*\.rules$'; then
- chown -h 0 "$file"
+ if basename "$file" | grep -qE '^.*\.rules$'; then
+ chown 0 "$file"
fi
done
bash remediation for rule 'xccdf_org.ssgproject.content_rule_file_permissions_etc_audit_rulesd' differs:
--- old datastream
+++ new datastream
@@ -1,9 +1,9 @@
-readarray -t files < <(find /etc/audit/rules.d/ -maxdepth 1)
+readarray -t files < <(find /etc/audit/rules.d/ -maxdepth 1 -type f)
for file in "${files[@]}"; do
- if basename $file | grep -qE '^.*rules$'; then
+ if basename "$file" | grep -qE '^.*rules$'; then
chmod 0640 "$file"
fi
done
bash remediation for rule 'xccdf_org.ssgproject.content_rule_file_ownership_library_dirs' differs:
--- old datastream
+++ new datastream
@@ -1,30 +1,30 @@
-readarray -t files < <(find /lib/ ! -uid 0)
+readarray -t files < <(find /lib/ -type f ! -uid 0)
for file in "${files[@]}"; do
- if basename $file | grep -qE '^.*$'; then
- chown -h 0 "$file"
+ if basename "$file" | grep -qE '^.*$'; then
+ chown 0 "$file"
fi
done
-readarray -t files < <(find /lib64/ ! -uid 0)
+readarray -t files < <(find /lib64/ -type f ! -uid 0)
for file in "${files[@]}"; do
- if basename $file | grep -qE '^.*$'; then
- chown -h 0 "$file"
+ if basename "$file" | grep -qE '^.*$'; then
+ chown 0 "$file"
fi
done
-readarray -t files < <(find /usr/lib/ ! -uid 0)
+readarray -t files < <(find /usr/lib/ -type f ! -uid 0)
for file in "${files[@]}"; do
- if basename $file | grep -qE '^.*$'; then
- chown -h 0 "$file"
+ if basename "$file" | grep -qE '^.*$'; then
+ chown 0 "$file"
fi
done
-readarray -t files < <(find /usr/lib64/ ! -uid 0)
+readarray -t files < <(find /usr/lib64/ -type f ! -uid 0)
for file in "${files[@]}"; do
- if basename $file | grep -qE '^.*$'; then
- chown -h 0 "$file"
+ if basename "$file" | grep -qE '^.*$'; then
+ chown 0 "$file"
fi
done
bash remediation for rule 'xccdf_org.ssgproject.content_rule_file_permissions_library_dirs' differs:
--- old datastream
+++ new datastream
@@ -1,30 +1,30 @@
-readarray -t files < <(find /lib/ )
+readarray -t files < <(find /lib/ -type f)
for file in "${files[@]}"; do
- if basename $file | grep -qE '^.*$'; then
+ if basename "$file" | grep -qE '^.*$'; then
chmod 0755 "$file"
fi
done
-readarray -t files < <(find /lib64/ )
+readarray -t files < <(find /lib64/ -type f)
for file in "${files[@]}"; do
- if basename $file | grep -qE '^.*$'; then
+ if basename "$file" | grep -qE '^.*$'; then
chmod 0755 "$file"
fi
done
-readarray -t files < <(find /usr/lib/ )
+readarray -t files < <(find /usr/lib/ -type f)
for file in "${files[@]}"; do
- if basename $file | grep -qE '^.*$'; then
+ if basename "$file" | grep -qE '^.*$'; then
chmod 0755 "$file"
fi
done
-readarray -t files < <(find /usr/lib64/ )
+readarray -t files < <(find /usr/lib64/ -type f)
for file in "${files[@]}"; do
- if basename $file | grep -qE '^.*$'; then
+ if basename "$file" | grep -qE '^.*$'; then
chmod 0755 "$file"
fi
done
bash remediation for rule 'xccdf_org.ssgproject.content_rule_root_permissions_syslibrary_files' differs:
--- old datastream
+++ new datastream
@@ -1,33 +1,33 @@
-readarray -t files < <(find /lib/ -maxdepth 1 ! -gid 0)
+readarray -t files < <(find /lib/ -maxdepth 1 -type f ! -gid 0)
for file in "${files[@]}"; do
- if basename $file | grep -qE '^.*$'; then
- chgrp -h 0 "$file"
+ if basename "$file" | grep -qE '^.*$'; then
+ chgrp 0 "$file"
fi
done
-readarray -t files < <(find /lib64/ -maxdepth 1 ! -gid 0)
+readarray -t files < <(find /lib64/ -maxdepth 1 -type f ! -gid 0)
for file in "${files[@]}"; do
- if basename $file | grep -qE '^.*$'; then
- chgrp -h 0 "$file"
+ if basename "$file" | grep -qE '^.*$'; then
+ chgrp 0 "$file"
fi
done
-readarray -t files < <(find /usr/lib/ -maxdepth 1 ! -gid 0)
+readarray -t files < <(find /usr/lib/ -maxdepth 1 -type f ! -gid 0)
for file in "${files[@]}"; do
- if basename $file | grep -qE '^.*$'; then
- chgrp -h 0 "$file"
+ if basename "$file" | grep -qE '^.*$'; then
+ chgrp 0 "$file"
fi
done
-readarray -t files < <(find /usr/lib64/ -maxdepth 1 ! -gid 0)
+readarray -t files < <(find /usr/lib64/ -maxdepth 1 -type f ! -gid 0)
for file in "${files[@]}"; do
- if basename $file | grep -qE '^.*$'; then
- chgrp -h 0 "$file"
+ if basename "$file" | grep -qE '^.*$'; then
+ chgrp 0 "$file"
fi
done
bash remediation for rule 'xccdf_org.ssgproject.content_rule_file_permissions_httpd_server_conf_d_files' differs:
--- old datastream
+++ new datastream
@@ -1,9 +1,9 @@
-readarray -t files < <(find /etc/httpd/conf.d/ -maxdepth 1)
+readarray -t files < <(find /etc/httpd/conf.d/ -maxdepth 1 -type f)
for file in "${files[@]}"; do
- if basename $file | grep -qE '^.*$'; then
+ if basename "$file" | grep -qE '^.*$'; then
chmod 0640 "$file"
fi
done
bash remediation for rule 'xccdf_org.ssgproject.content_rule_file_permissions_httpd_server_conf_files' differs:
--- old datastream
+++ new datastream
@@ -1,9 +1,9 @@
-readarray -t files < <(find /etc/httpd/conf/ -maxdepth 1)
+readarray -t files < <(find /etc/httpd/conf/ -maxdepth 1 -type f)
for file in "${files[@]}"; do
- if basename $file | grep -qE '^.*$'; then
+ if basename "$file" | grep -qE '^.*$'; then
chmod 0640 "$file"
fi
done
bash remediation for rule 'xccdf_org.ssgproject.content_rule_file_permissions_sshd_private_key' differs:
--- old datastream
+++ new datastream
@@ -1,9 +1,9 @@
# Remediation is applicable only in certain platforms
if [ ! -f /.dockerenv ] && [ ! -f /run/.containerenv ]; then
-readarray -t files < <(find /etc/ssh/ -maxdepth 1)
+readarray -t files < <(find /etc/ssh/ -maxdepth 1 -type f)
for file in "${files[@]}"; do
- if basename $file | grep -qE '^.*_key$'; then
+ if basename "$file" | grep -qE '^.*_key$'; then
chmod 0600 "$file"
fi
done
bash remediation for rule 'xccdf_org.ssgproject.content_rule_file_permissions_sshd_pub_key' differs:
--- old datastream
+++ new datastream
@@ -1,9 +1,9 @@
# Remediation is applicable only in certain platforms
if [ ! -f /.dockerenv ] && [ ! -f /run/.containerenv ]; then
-readarray -t files < <(find /etc/ssh/ -maxdepth 1)
+readarray -t files < <(find /etc/ssh/ -maxdepth 1 -type f)
for file in "${files[@]}"; do
- if basename $file | grep -qE '^.*.pub$'; then
+ if basename "$file" | grep -qE '^.*.pub$'; then
chmod 0644 "$file"
fi
done |
Member
|
Looks like another push is needed to get GH Actions to run. |
This test sets expectation on behavior of the rule. Symlinks are ignored, even when they have incompliant owner, and point to nowhere.
dff39d1 to
c5feb75
Compare
vojtapolasek
approved these changes
Mar 25, 2022
Collaborator
vojtapolasek
left a comment
There was a problem hiding this comment.
LGTM, thank you for quick fix
This was referenced Mar 31, 2022
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description:
file_owner,file_groupownerandfile_permissionto act only on regular files whenfile_regexis set,/lib,lib64,/usr/liband/usr/lib64and making changes can have catastrophic consequences.Rationale:
file_permissions_library_dirs.file_permissions_library_dirsstarted to recursively navigate down the directory of trees, and it found symlinks to binaries installed in the system:This became visible when
sudocommand stopped working after remediation was applied: