1.5.2 Ensure fs.protected_hardlinks is configured

Information

fs.protected_hardlinks Controls the creation of hard links to files.

More information about the kernel parameter configuration files, their location, and load preference is available in the section overview.

Disallowing hardlinks mitigates vulnerabilities based on unsecure file systems accessed by privileged programs. This reduces the risk of an exploitation vector exploiting unsafe use of open or creat.

Solution

- Run the following command to comment out fs.protected_hardlinks lines returned by the audit procedure that are not fs.protected_hardlinks = 1 :

# sed -ri '^\s*fs.protected_hardlinks\s*=\s*0/s/^/#/g' "path/to/file/in/audit/filename"

Example:

# sed -ri '/^\s*fs.protected_hardlinks\s*=\s*0/s/^/#/g' /etc/sysctl.d/99-sysctl.conf
- Create or edit a file in the /etc/sysctl.d/ directory ending in .conf and edit or add the following line:

fs.protected_hardlinks = 1

Example:

# [ ! -d "/etc/sysctl.d/" ] && mkdir -p /etc/sysctl.d/
# printf '%s\n' "" "fs.protected_hardlinks = 1" >> /etc/sysctl.d/60-fs_sysctl.conf
- Run the following command to load all sysctl configuration files:

# sysctl --system

Impact:

Users will not be able to create soft or hard links to files they do not own.

See Also

https://workbench.cisecurity.org/benchmarks/25279

Item Details

Category: ACCESS CONTROL

References: 800-53|AC-3(4), 800-53|AC-6(10), CCI|CCI-002165, CCI|CCI-002235, Rule-ID|SV-230268r1017086_rule, Rule-ID|SV-248578r958702_rule, Rule-ID|SV-257801r958702_rule, Rule-ID|SV-269144r1050026_rule, Rule-ID|SV-271740r1091932_rule

Plugin: Unix

Control ID: 7e3d7887af99bfb8098c3d22717fca20b6299ea02cebd01e223071a5301acf1f