Information
USB storage provides a means to transfer and store files ensuring persistence and availability of the files independent of network connection status. Its popularity and utility has led to USB-based malware being a simple and common means for network infiltration and a first step to establishing a persistent threat within a networked environment.
Restricting USB access on the system will decrease the physical attack surface for a device and diminish the possible vectors to introduce malware.
Solution
Run the following to unload and disable the usb-storage kernel module. This can also be done by running the script included below.
Run the following commands to unload the usb-storage kernel module:
# modprobe -r usb-storage 2>/dev/null
# rmmod usb-storage 2>/dev/null
Perform the following to disable the usb-storage kernel module:
Create a file ending inconf with install usb_storage /bin/false in the /etc/modprobe.d/ directory
Example:
# printf '\n%s\n' "install usb_storage /bin/false" >> usb-storage.conf
Create a file ending inconf with blacklist usb_storage in the /etc/modprobe.d/ directory
Example:
# printf '\n%s\n' "blacklist usb_storage" >> usb-storage.conf
Impact:
Disabling the usb-storage module will disable any usage of USB storage devices.
If requirements and local site policy allow the use of such devices, other solutions should be configured accordingly instead. One example of a commonly used solution is USBGuard