1.5.3 Ensure fs.protected_symlinks is configured

Information

fs.protected_symlinks Controls how the kernel handles symbolic links.

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

Disallowing symlinks 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_symlinks lines returned by the audit procedure that are not fs.protected_symlinks = 1 :

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

Example:

# sed -ri '/^\s*fs.protected_symlinks\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_symlinks = 1

Example:

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

# sysctl --system

Impact:

By enabling the fs.protected_symlinks kernel parameter, symbolic links are permitted to be followed only when outside a sticky world-writable directory, or when the user identifier (UID) of the link and follower match, or when the directory owner matches the symlink's owner.

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-248577r958702_rule, Rule-ID|SV-257801r958702_rule, Rule-ID|SV-269144r1050026_rule, Rule-ID|SV-271741r1091935_rule

Plugin: Unix

Control ID: 7356adff158f4bd32e5c64d28c072866c14d07299c574c41422ed151921469f1