Group PoliciesWindows 10Windows Server

How to Block USB Drives in Windows using Group Policy

By March 17, 2021August 18th, 2021No Comments

When connecting a new USB device to the computer, Windows automatically detects the device and installs an appropriate driver. As a result, the user can almost immediately use a connected USB drive or device. In some organizations, the use of USB storage devices (flash drives, USB HDDs, SD cards and so on) is blocked for security reasons to prevent leakage of sensitive data and infecting computers. This post describes how to use the Group Policy (GPO) to disable external removable USB-drives.

Configuring GPO to Disable USB Storage Devices on Domain Computers

In all versions of Windows, starting from Windows 7, you can flexibly manage access to external drives (USB, CD / DVD, floppy, tape etc.) using Group Policies. It is possible to programmatically block the use of only USB drives, without affecting a USB devices as a mouse, keyboard, printer, etc (which are not recognized as a removable disk).

The USB device blocking policy will work if the infrastructure of your AD domain meets the following requirements:

  • Active Directory schema version — Windows Server 2008 or newer; The set of Group Policies allowed to control the installation and use of removable media on Windows appeared only in the AD version 44.
  • Desktop OSs –Windows 7 or newer.

We are going to restrict the use of USB-drives for all computers in a certain AD container (OU). You can apply the USB block policy to the entire domain, but this will affect the servers and other technological devices. Let’s assume that we want to apply the policy to OU named Workstations. To do it, open the GPO management console (gpmc.msc), right-click on OU Workstations and create a new policy (Create a GPO in this domain and Link it here). In case of stand-alone computer, the USB-device restriction policy can be edited using a local Group Policy Editor – gpedit.msc.

gpmc - Create a GPO in this domain and Link it

Set the GPO name “Disable USB Access”.

Policy Name: Disable USB Access

Modify the GPO settings (Edit).

Edit GPO

The settings for blocking external storage devices are available in both the User and Computer sections of the GPO:

  • User Configuration -> Policies -> Administrative Templates -> System -> Removable Storage Access.
  • Computer Configuration -> Policies -> Administrative Templates -> System -> Removable Storage Access.

If you want to block USB storage devices for all computer users, you need to configure the settings in the “Computer Configuration” section.

In the Removable Storage Access section, there are several policies allowing you to disable the use of different types of storage classes — CD/DVDs, FDD, USB-devices, tapes, etc.

  • CD and DVD: Deny execute access.
  • CD and DVD: Deny read access.
  • CD and DVD: Deny write access.
  • Custom Classes: Deny read access.
  • Custom Classes: Deny write access.
  • Floppy Drives: Deny execute access.
  • Floppy Drives: Deny read access.
  • Floppy Drives: Deny write access.
  • Removable Disks: Deny execute access.
  • Removable Disks: Deny read access.
  • Removable Disks: Deny write access.
  • All Removable Storage classes: Deny all access.
  • All Removable Storage: Allow direct access in remote sessions.
  • Tape Drives: Deny execute access.
  • Tape Drives: Deny read access.
  • Tape Drives: Deny write access.
  • Windows Portable Device – this class includes smartphones, tablets, players, etc.
  • WPD Devices: Deny write access.

As you can see, you can deny the launch of executable files for each device class (protect computers against viruses), prohibit reading data and writing /editing files on external media.

Removable Storage Access settings in GPO

The “strongest” restrict policy — All Removable Storage Classes: Deny All Access – allows to completely disable the access to all types of external storage devices. To turn on the policy, open it and check Enable.

All Removable Storage Classes: Deny All Access

After enabling and updating the policy on client computers (gpupdate /force), the OS detects the connected external devices (not only USB devices, but also any external drives), but when trying to open them, an error is appeared:

Location is not available
Drive is not accessible. Access is denied.
Drive is not accessible. Access is denied

The same restriction can be set using the registry by creating DWORD parameter Deny_All with the value 00000001 in the registry key HKEY_CURRENT_USER\Software\Policies\Microsoft\Windows\RemovableStorageDevices.

In the same policy section, you can configure more flexible restrictions on the use of external USB drives.

For example, to prevent writing data to USB flash drives and other types of USB drives, you should enable the policy Removable Disk: Deny write access.

USB Removable Disk: Deny write access

In this case, users will be able to read the data from the USB flash drive, but when they attempt to write information to it, they will receive an access denied error:

Destination Folder Access Denied
You need permission to perform this action
USB media- write Access Denied

You can prevent executable and script files from running from USB-drives using the Removable Disks: Deny execute access policy.

Removable Disks: Deny execute access

Disabling USB Drives via GPO for Specific Users

Quite often it is necessary to block USB drives for all users in the domain except administrators.

The easiest way to do this is to use the Security Filtering in the GPO. For example, to prevent the USB block policy from being applied to the Domain Admins group:

  1. Select your Disable USB Access policy in the Group Policy Management console;
  2. In the Security Filtering section, add the Domain Admins group;
  3. Go to the Delegation tab and click the Advanced. In the security settings editor, specify that the Domain Admins group is not allowed to apply this GPO (Apply group policy – Deny).

There may be another scenario – you need to allow the use of external USB drives for everyone except a certain group of users. Create a security group “Deny USB” and add this group in the security settings of the GPO. For this group, set permissions to read and apply the GPO, and leave only read permission for the Authenticated Users or Domain Computers group (by unchecking the Apply group policy checkbox).

deny gpo applying to authenticated users

Blocking USB and Removable Devices via Registry and Group Policy Preferences

You can more flexibly control access to external devices by configuring the registry settings that are set by the policies discussed above via the Group Policy Preferences (GPP). All the above policies correspond to certain registry keys in the HKLM (or HKCU\SOFTWARE\Policies\Microsoft\Windows\RemovableStorageDevices key (by default this registry key is missing).

To enable one of these policies, you must create a new subkey in the specified key with the name of the device class you want to block access to (column 2) and REG_DWORD parameter with constraint type (Deny_ReadDeny_Write or Deny_Execute). If the value of this parameter is equal to 1, the USB restriction is active, if 0 – there are no recstrcition on this device class.

Policy nameDevice Class GUIDRegistry parameter name
Floppy Drives:
Deny read access
{53f56311-b6bf-11d0-94f2-00a0c91efb8b}Deny_Read
Floppy Drives:
Deny write access
{53f56311-b6bf-11d0-94f2-00a0c91efb8b}Deny_Write
CD and DVD:
Deny read access
{53f56308-b6bf-11d0-94f2-00a0c91efb8b}Deny_Read
CD and DVD:
Deny write access
{53f56308-b6bf-11d0-94f2-00a0c91efb8b}Deny_Write
Removable Disks:
Deny read access
{53f5630d-b6bf-11d0-94f2-00a0c91efb8b}Deny_Read
Removable Disks:
Deny write access
{53f5630d-b6bf-11d0-94f2-00a0c91efb8b}Deny_Write
Tape Drives:
Deny read access
{53f5630b-b6bf-11d0-94f2-00a0c91efb8b}Deny_Read
Tape Drives:
Deny write access
{53f5630b-b6bf-11d0-94f2-00a0c91efb8b}Deny_Write
WPD Devices:
Deny read access
{6AC27878-A6FA-4155-BA85-F98F491D4F33}
{F33FDC04-D1AC-4E8E-9A30-19BBD4B108AE}
Deny_Read
WPD Devices:
Deny write access
{6AC27878-A6FA-4155-BA85-F98F491D4F33}
{F33FDC04-D1AC-4E8E-9A30-19BBD4B108AE}
Deny_Write

You can manually create the specified registry keys and parameters. In the screenshot below, I’ve created a RemovableStorageDevices key, and a subkey named {53f5630d-b6bf-11d0-94f2-00a0c91efb8b}. With the help of REG_DWORD parameters, I prohibited writing and running executable from USB drives.

RemovableStorageDevices set USB write and execute restrictions via registry

Disabling USB storage will take effect immediately after the policy is applied (no need to restart your computer). If a USB flash drive is connected to the computer, it will be available until it is reconnected.

You can use these registry keys and GPP’s Item-level targeting to flexibly apply policies that restrict the use of external USB storage devices. You can apply policies to specific AD security groups, sites, OS versions, OUs (you can use even WMI filters). For example, you can create the Storage-Devices-Restrict domain group and add the computer accounts for which you want to restrict the use of USB drives. This group is specified in your GPP policy in the Item Level Targeting -> Security Group section with the Computer in Group option. This will apply the USB blocking policy to computers that are added to this AD group.

gpp targeting to security group

Similarly, you can create your own policies for device classes that are not listed in this list. You can find out the device class ID in the driver properties in the value of the Device Class GUID attribute.

Disable the USB Storage Driver via Registry

You can completely disable the USBSTOR (USB Mass Storage Driver) driver, which is required to correctly detect and mount USB storage devices.

On a stand-alone computer, you can disable this driver by changing the value of the Start registry parameter from 3 to 4. You can do this through PowerShell:

Set-ItemProperty "HKLM:\SYSTEM\CurrentControlSet\services\USBSTOR" -name Start -Value 4

disable usbstor service in registry

Restart your computer and try to connect your USB storage device. Now it shouldn’t appear in File Explorer or Disk Management console, and in Device Manager you will see a device driver installation error.

You can disable the USBSTOR driver from running on domain computers using Group Policy Preferences. To do this, you need to make changes to the registry through the GPO.

These settings can be deployed to all domain computers. Create a new Group Policy, link it to the OU with computers and in the Computer Configuration -> Preferences -> Windows Settings -> Registry section, create a new parameter with the values:

  • Action: Update
  • Hive: HKEY_LOCAK_MACHINE
  • Key path: SYSTEM\CurrentControlSet\Services\USBSTOR
  • Value name: Start
  • Value type: REG_DWORD
  • Value data: 00000004
gpo to disable usbstor driver on domain computers

Allow Only a Specific USB Storage Device to be Connected

You can use a certain registry setting to allow a specific (approved) USB storage drive to connect to your computer. Let’s take a quick look at how this can be configured.

When you connect any USB storage device to the computer, the USBSTOR driver installs the device and creates a separate registry key under the  HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Enum\USBSTOR. This registry key contains information about the USB drive (for example, Disk & Ven_Kingstom & Prod_DT_1010_G2 & Rev_12.00).

usbstor registry key

You can list the USB drives that have ever been connected to your computer with the following PowerShell command:

Get-ItemProperty –Path HKLM:\SYSTEM\CurrentControlSet\Enum\USBSTOR\*\*| select FriendlyName

usbstor - usb devices connection history in registry

You can delete all registry keys for previously connected USB flash drives, except for those you need.

Then you need to change the permissions on the USBSTOR registry key so that everyone (including SYSTEM and administrators) has only read permissions. As a result, when you connect any USB drive, except the allowed one, Windows won’t be able to install the device.

Leave a Reply