Verify that system commands directories have root ownership
An XCCDF Rule
Description
System commands are stored in the following directories by default:
/bin /sbin /usr/bin /usr/sbin /usr/local/bin /usr/local/sbinAll these directories should be owned by the
root
user.
If any system command directory is not owned by a user other than root
correct its ownership with the following command:
$ sudo chown root DIR
Rationale
If the operating system were to allow any user to make changes to software libraries, then those changes might be implemented without undergoing the appropriate testing and approvals that are part of a robust change management process. This requirement applies to operating systems with software libraries that are accessible and configurable, as in the case of interpreted languages. Software libraries also include privileged programs which execute with escalated privileges. Only qualified and authorized individuals must be allowed to obtain access to information system components for purposes of initiating changes, including upgrades and modifications.
- ID
- xccdf_org.ssgproject.content_rule_dir_system_commands_root_owned
- Severity
- Medium
- References
- Updated
Remediation - Ansible
- name: Set ownership of directories that contain system commands to root
file:
path: '{{ item }}'
owner: root
recurse: 'yes'
state: directory
Remediation - Shell Script
for SYSCMDDIRS in /bin /sbin /usr/bin /usr/sbin /usr/local/bin /usr/local/sbin
do
find -L $SYSCMDDIRS \! -user root -type d -exec chown root {} \;
done