Information
fs.suid_dumpable governs whether a privileged process (with the setuid bit) can generate a core dump, regardless of other configurations.
fs.suid_dumpable values:
- 0 (default) - Any process that has changed privilege levels (like SUID programs) or is execute-only will not dump core.
- 1 (debug) - All processes dump core if possible. The core dump is owned by the current user and security is not applied. This is primarily intended for system debugging.
- 2 (suidsafe) - Any binary that normally wouldn't be dumped is dumped, but only if the core_pattern is set to a pipe handler or a fully qualified path. This mode is suitable for administrators debugging in a production environment.
core dumps may contain sensitive in-memory data like password hashes or keys. An attacker could potentially exploit this to gain access to such data.
Solution
- Review all files ending in .conf in the /etc/sysctl.d directory and comment out or remove all fs.suid_dumpable lines that are not fs.suid_dumpable=0.
Example script:
#!/usr/bin/env bash
{
l_option="fs.suid_dumpable" l_grep="${l_option//./\\.}" l_value="0"
while IFS= read -r -d $'\0' l_file; do
grep -Poi '\h*'"$l_option"'\h*=\h*\H+\b' "$l_file" \
| grep -Pivq '^\h*'"$l_grep"'\h*=\h*'"$l_value"'\b' && \
sed -ri '/^\s*kernel.yama.ptrace_scope\s*=/s/^/# /' "$l_file"
done < <(find /etc/sysctl.d/ -type f -name '*.conf' -print0)
}
- Create or edit a file in the /etc/sysctl.d/ directory ending in .conf and edit or add the following line:
fs.suid_dumpable = 0
Example:
# [ ! -d "/etc/sysctl.d/" ] && mkdir -p /etc/sysctl.d/
# printf '%s\n' "" "fs.suid_dumpable = 0" >> /etc/sysctl.d/60-kernel_sysctl.conf
- Run the following command to load all system configuration filles:
# sysctl --system