Skip to content

Verify Group Who Owns /etc/sysctl.d Directory

An XCCDF Rule

Description

To properly set the group owner of /etc/sysctl.d, run the command:

$ sudo chgrp root /etc/sysctl.d

Rationale

The ownership of the /etc/sysctl.d directory by the root group is important because this directory hosts kernel configuration. Protection of this directory is critical for system security. Assigning the ownership to root ensures exclusive control of the kernel configuration.

ID
xccdf_org.ssgproject.content_rule_directory_groupowner_etc_sysctld
Severity
Medium
References
Updated



Remediation - Ansible

- name: Ensure group owner on /etc/sysctl.d/
  file:
    path: /etc/sysctl.d/
    state: directory
    group: root
  when: ansible_virtualization_type not in ["docker", "lxc", "openvz", "podman", "container"]

Remediation - Shell Script

# Remediation is applicable only in certain platforms
if [ ! -f /.dockerenv ] && [ ! -f /run/.containerenv ]; then

find -H /etc/sysctl.d/ -maxdepth 1 -L -type d -exec chgrp -L root {} \;

else