Verify Permissions On /etc/sysctl.d Directory
An XCCDF Rule
Description
To properly set the permissions of /etc/sysctl.d
, run the command:
$ sudo chmod 0755 /etc/sysctl.d
Rationale
Setting correct permissions on the /etc/sysctl.d directory is important because this directory hosts kernel configuration. Protection of this directory is critical for system security. Restricting the permissions ensures exclusive control of the kernel configuration.
- ID
- xccdf_org.ssgproject.content_rule_directory_permissions_etc_sysctld
- Severity
- Medium
- References
- Updated
Remediation - Ansible
- name: Find /etc/sysctl.d/ file(s)
command: 'find -H /etc/sysctl.d/ -maxdepth 1 -perm /u+s,g+ws,o+wt -type d '
register: files_found
changed_when: false
failed_when: false
check_mode: false
Remediation - Shell Script
# Remediation is applicable only in certain platforms
if [ ! -f /.dockerenv ] && [ ! -f /run/.containerenv ]; then
find -H /etc/sysctl.d/ -maxdepth 1 -perm /u+s,g+ws,o+wt -type d -exec chmod u-s,g-ws,o-wt {} \;
else