1.5.9 Ensure systemd-coredump ProcessSizeMax is configured

Information

A core dump is the memory of an executable program. It is generally used to determine why a program aborted. It can also be used to glean confidential information from a core file.

A core dump includes a memory image taken at the time the operating system terminates an application. The memory image could contain sensitive data and is generally useful only for developers trying to debug problems, increasing the risk to the system.

Solution

- Review all files ending inconf in the /etc/systemd/coredump.conf.d/ directory and comment out or remove all ProcessSizeMax= lines in the [Coredump] block that are not ProcessSizeMax=0

Example script:

#!/usr/bin/env bash

{
l_block="Coredump" l_option="ProcessSizeMax" l_value="0"
while IFS= read -r -d $'\0' l_file; do
awk '/\['"$l_block"'\]/{a=1;next}/\[/{a=0}a' "$l_file" 2>/dev/null | \
grep -Poi '\h*'"$l_option"'\h*=\h*\H+\b' | \
grep -Pivq '^\h*'"$l_option"'\h*=\h*'"$l_value"'\b' && \
sed -ri '/^\s*[Pp]rocess[Ss]ize[Mm]ax\s*=/s/^/# /' "$l_file"
done < <(find /etc/systemd/coredump.conf.d/ -type f -name '*.conf' -print0)
} <xhtml:ol start="2"> - Create or edit a file in the /etc/systemd/coredump.conf.d directory ending inconf and edit or add the following line to the [Coredump] section:

ProcessSizeMax=0

Example:

#!/usr/bin/env bash

{
[ ! -d /etc/systemd/coredump.conf.d/ ] && mkdir /etc/systemd/coredump.conf.d/
l_file="/etc/systemd/coredump.conf.d/60-coredump.conf"
if grep -Psq -- '^\h*\[Coredump\]' "$l_file"; then
sed -ri '/^\s*\[Coredump\]/a ProcessSizeMax=0' "$l_file"
else
printf '%s\n' "" "[Coredump]" "ProcessSizeMax=0" >> "$l_file"
fi
} <xhtml:ol start="3"> - Run the following command to load the updated configuration:

# systemctl reload-or-restart systemd-coredump.socket

See Also

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

Item Details

Category: CONFIGURATION MANAGEMENT

References: 800-53|CM-7b.

Plugin: Unix

Control ID: 57c4f4738ae770d93b4cb3fd80458dc4924252c9ac436c658a0cf5729374633c