Vulnerability Discussion
By enabling the fs.protected_hardlinks kernel parameter, users can no longer create soft or hard links to files they do not own.
Disallowing such hardlinks mitigates vulnerabilities based on unsecure file systems accessed by privileged programs, avoiding an exploitation vector exploiting unsafe use of open() or creat().
Check
Verify AlmaLinux OS 9 is configured to enable DAC on hardlinks with the following command:
$ sysctl fs.protected_hardlinks
fs.protected_hardlinks = 1
If "fs.protected_hardlinks" is not set to "1" or is missing, this is a finding.
Check that the configuration files are present to enable this kernel parameter:
$ /usr/lib/systemd/systemd-sysctl --cat-config | egrep -v '^(#|;)' | grep -F fs.protected_hardlinks | tail -1
fs.protected_hardlinks = 1
If "fs.protected_hardlinks" is not set to "1" or is missing, this is a finding.
Fix
Configure AlmaLinux OS 9 to enable DAC on hardlinks with the following command:
$ echo "fs.protected_hardlinks = 1" > /etc/sysctl.d/60-hardlinks.conf
Load settings from all system configuration files with the following command:
$ sysctl –system