1.1.1.8 Ensure udf kernel module is not available

Information

The udf filesystem type is the universal disk format used to implement ISO/IEC 13346 and ECMA-167 specifications. This is an open vendor filesystem type for data storage on a broad range of media. This filesystem type is necessary to support writing DVDs and newer optical disc formats.

Removing support for unneeded filesystem types reduces the local attack surface of the system. If this filesystem type is not needed, disable it.

Solution

Run the following script to unload and disable the udf module:

- IF - the udf kernel module is available in ANY installed kernel:

- Create a file ending inconf with install udf /bin/false in the /etc/modprobe.d/ directory
- Create a file ending inconf with blacklist udf in the /etc/modprobe.d/ directory
- Run modprobe -r udf 2>/dev/null; rmmod udf 2>/dev/null to remove udf from the kernel

- IF - the udf kernel module is not available on the system, or pre-compiled into the kernel, no remediation is necessary

#!/usr/bin/env bash

{
a_output2=() a_output3=() l_dl="" l_mod_name="udf" l_mod_type="fs"
l_mod_path="$(readlink -f /lib/modules/**/kernel/$l_mod_type | sort -u)"
f_module_fix()
{
l_dl="y" a_showconfig=()
while IFS= read -r l_showconfig; do
a_showconfig+=("$l_showconfig")
done < <(modprobe --showconfig | grep -P -- 'b(install|blacklist)h+'"${l_mod_chk_name//-/_}"'b')
if lsmod | grep "$l_mod_chk_name" &amp;> /dev/null; then
a_output2+=(" - unloading kernel module: \"$l_mod_name\"")
modprobe -r "$l_mod_chk_name" 2>/dev/null; rmmod "$l_mod_name" 2>/dev/null
fi
if ! grep -Pq -- 'binstallh+'"${l_mod_chk_name//-/_}"'h+(/usr)?/bin/(true|false)b' <<< "${a_showconfig[*]}"; then
a_output2+=(" - setting kernel module: \"$l_mod_name\" to \"$(readlink -f /bin/false)\"")
printf '%s
' "install $l_mod_chk_name $(readlink -f /bin/false)" >> /etc/modprobe.d/"$l_mod_name".conf
fi
if ! grep -Pq -- 'bblacklisth+'"${l_mod_chk_name//-/_}"'b' <<< "${a_showconfig[*]}"; then
a_output2+=(" - denylisting kernel module: \"$l_mod_name\"")
printf '%s
' "blacklist $l_mod_chk_name" >> /etc/modprobe.d/"$l_mod_name".conf
fi
}
for l_mod_base_directory in $l_mod_path; do # Check if the module exists on the system
if [ -d "$l_mod_base_directory/${l_mod_name/-//}" ] &amp;&amp; [ -n "$(ls -A "$l_mod_base_directory/${l_mod_name/-//}")" ]; then
a_output3+=(" - \"$l_mod_base_directory\"")
l_mod_chk_name="$l_mod_name"
[[ "$l_mod_name" =~ overlay ]] &amp;&amp; l_mod_chk_name="${l_mod_name::-2}"
[ "$l_dl" != "y" ] &amp;&amp; f_module_fix
else
printf '%s
' " - kernel module: \"$l_mod_name\" doesn't exist in \"$l_mod_base_directory\""
fi
done
[ "${#a_output3[@]}" -gt 0 ] &amp;&amp; printf '%s
' "" " -- INFO --" " - module: \"$l_mod_name\" exists in:" "${a_output3[@]}"
[ "${#a_output2[@]}" -gt 0 ] &amp;&amp; printf '%s
' "" "${a_output2[@]}" || printf '%s
' "" " - No changes needed"
printf '%s
' "" " - remediation of kernel module: \"$l_mod_name\" complete" ""
}

Impact:

Microsoft Azure requires the usage of udf

udf should not be disabled on systems run on Microsoft Azure.

See Also

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

Item Details

Category: CONFIGURATION MANAGEMENT

References: 800-53|CM-6, 800-53|CM-7, CSCv7|9.2

Plugin: Unix

Control ID: 36dc532725a27f96a3e11d2c3315f6ee74b1041e2e979cf0329375897e977ddb