How to disable USB sticks and limit access to USB storage devices on Windows systems

Submitted by Hannes Schmidt on Sat, 08/20/2005 - 09:50.

USB storage - a possible security risk?

Decent IT administrators secure their networks behind firewalls. They install mail filters on their SMTP servers and deploy anti-virus software on all client workstations. But securing the network is not sufficient -- what happens if the users bring their own USB memory sticks and connect them to the computers at their office? A 1 Gb USB stick can sometimes hold an entire company's vital data. Within minutes or even seconds an employee has all the files they need in order to start up their own business and take all the customers with them. Alternatively, what happens if a careless user accidentally compromises the network with an infected USB stick?

What does Microsoft have to say about it?

If you, the administrator, want to establish a minimum level of security, it is absolutely necessary to control which users can connect USB memory sticks to a computer. Unfortunately, a default Windows XP or Windows 2000 installation comes with no limitations on who is able to install and use USB storage media. Microsoft knowledge base article 823732 contains instructions on how to disable USB storage access for a certain group of users; however, the article only distinguishes between whether or not a USB storage device has been installed on a particular computer. Furthermore, the instructions are limited to a stand-alone computer. According to the general rule of thumb "If it's tedious, there is a better way", I try to avoid techniques that force me to repeat certain tasks for each computer that I manage. That's what group policy objects (GPO) are for.

Suggestions?

Mark Heitbrink describes how to disable USB storage devices entirely on all or some computers in the network. He employs an ADM template in a group policy object that disables the USB storage driver (USBSTOR). The ADM template simply sets the registry value HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\UsbStor\Start to 4 (Disable). But his technique has a serious drawback. It only works if the USB storage driver is already installed. If it has not yet been installed, Windows' plug & play subsystem automatically resets the Start value to 3 (Manual) when it installs USBSTOR after a USB storage device is plugged in for the first time. In that case, USBSTOR remains enabled until the GPO is re-applied, usually at the next reboot. If the storage device is plugged in during that reboot, it will still be available because the USBSTOR driver is started before any GPOs are processed.

The Howto!

If we combine Mark Heitbrink's approach with the one outlined in knowledge base article 823732, we get a more reliable solution. Firstly, we need to prevent USBSTOR from being installed unless the currently logged on user is allowed to use USB storage. We do that by restricting access to USBSTOR.INF and USBSTORE.PNF in a GPO such that PNP can't automatically install the driver. This is possible because when PNP installs a driver, the installation is performed using the priviledges of the currently logged on user. Secondly, we need to make sure that USBSTOR is not started when a USB storage device is plugged in. For that we use Mark's ADM template. The only minor drawback of my solution is that users with access to USB storage need to manually start USBSTOR before connecting USB storage devices.

  1. In Active Directory Users and Computers, open an existing GPO or create a new one and open it. Use the security settings of that GPO to specify which computers it affects.
  2. In that GPO, go to Computer Configuration – Windows Settings – Security Settings – File System and create a new entry (right-click File System and select Add File). Specify the location of USBSTOR.INF (usually SystemRoot%\Inf\USBSTOR.INF)
  3. Change the security settings of the new entry. The security settings that you specify here will be enforced on the USBSTOR.INF of every computer to which the GPO is applied. This process is not additive, which means that the previous security settings of USBSTOR.INF will be overwritten by the ones given in the GPO. It is therefore recommended to grant full control to SYSTEM and local administrators. But unlike in the default security settings of USBSTOR.INF, you should not grant any priviledges to Everybody. You do not need to explicitly deny access – just omit an entry for Everybody. Optionally, you can grant read access to a certain group. Members of this group will be able to use USB storage.
  4. Repeat the above two steps for USBSTOR.PNF.
  5. Download USBSTOR.ADM.
  6. Back in the GPO, right-click Administrative Templates under Computer Configuration and select Add/Remove Templates. Click Add and browse to the location of USBSTOR.ADM. Close the dialog.
  7. You should now have an additional entry called Services and Drivers in Administrative Templates. Click on it. If it is empty, select View from the menu and uncheck Show Policies Only. Click back on Services and Drivers in Administrative Templates. It should now show the USB Storage policy. Double click it, select Enabled and pick Disabled from the Startup Type drop down. Again, the policy must be enabled wheras Startup Type must be Disabled.
  8. Close the dialog as well as the GPO and boot/reboot one of your workstations. Make sure no USB strorage device is connected to that computer. Log on with administrative privileges and check the permissions of USBSTOR.INF and USBSTOR.PNF. Check the value of the HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\UsbStor\Start. It should be 4. It is also ok if the UsbStor key doesn't exist at all.
  9. On the same workstation, log off and back on as a user that should not have access to USB storage. Connect a USB memory stick or a similar device. Nothing should happen. Remove the memory stick.
  10. Log on as a user that should have access to USB storage and execute net start usbstor in a command shell or at Start – Run before connecting the memory stick. The memory stick should initialized and mapped to a drive letter. If USBSTOR fails to start, it's probably because this is the first time a memory stick is plugged into the workstation in which case USBSTOR is not yet installed. Nevertheless, the memory stick should be initialized and mapped correctly but you need to reboot in order to reapply the administrative template such that USBSTOR is disabled again. Alternatively, you can disable it manually by downloading and double clicking USBSTOR.REG as well as executing net stop usbstor.
  11. Instruct the users with access to USB storage that they need to execute net start usbstor before they can connect a USB storage device.
AttachmentSize
usbstore.adm530 bytes
usbstore.reg258 bytes
( categories: Windows | Administrator )
Submitted by Anonymous on Sat, 05/10/2008 - 20:42.
Hello All, Me too facing some problem during disabling USB Storage on network...lemme explain my scenario....we have windows 2003 Server as DC and workstation as win 2000 Pro, win XP Pro and aslo recently we have added couples of Win Vista machines. So, cud anyone suggest me how can i disable USB mass Storage devices on all systems thru GPO under User Configuration ...admin templates but dey still sud be able to use USB keyboard and mice. Thnx in adv, Sridhar
Submitted by Anonymous on Wed, 01/30/2008 - 06:11.
Pretty much. Once i have installed a verbatim USB, and after completing the instalation i tried with another USB that is of the same Verbatim type. The second USB could not install and so not work, while the first one was working fine.
Submitted by Anonymous on Thu, 01/24/2008 - 18:58.
was just wondering,tried this method on a test group,all looked good,but when I ran gpupdate,then gpresult,showed the GPO was rejected,empty,any idea's?
Submitted by Anonymous on Fri, 01/18/2008 - 01:47.
Try the following registry entry which allow only Read access to user.User can not copy the data from machin to any portable usb disk.but other usb device (KB,Mouse) were work fine. Make new key HKEY_LOCAL_MACHINE\System\CurrentControlSet\Control\StorageDevicePolicies Create the following value (DWORD): WriteProtect and give it a value of 1. done! but this work only on windows XP sp2
Submitted by Hannes Schmidt on Thu, 01/17/2008 - 15:56.
Thanks for suggesting that method. Are you positive that it really only allows one type of USB device and not the entire class of devices supported by a driver? -- Hannes
Submitted by Anonymous on Thu, 01/17/2008 - 04:24.
To give usage to only one device i use this way. Fist you uninstall every device installed previously if there are. At cmd prompt you give these 2 commands: set devmgr_show_nonpresent_devices=1 start devmgmt.msc The fist commant will let you see installed driver that are not present at the system at that moment when you start the Device Manager which is done by the second command. When the DM is started you go to view - Show hidden devices and than at storage device you can see all the drivers that have been installed. Uninstall them all if there are any. After this you plug in the Device that you will use on that PC. after the driver is installed than you disable access to everyone on USBSTOR.* In this method you can not use the reg file since that will disable every USB device that has been installed. The good of this is that you let PPL use the USB and you also limit others from using USB's on that PC. Also the USB devices have each a their code of installation so even if they are the same type, only the allowed device can work on that PC.
Submitted by Anonymous on Mon, 01/14/2008 - 19:15.
We are small company wihtout IT department, and we want to block the evil USB port. Currently we block untrusted USB device by MyUSBOnly, found here. It works without an IT administrator, just prompt you for a password when untrusted USB is inserted into a computer.
Submitted by Anonymous on Thu, 12/20/2007 - 04:40.
At the office where I work, the admins use this software http://www.gfi.com/endpointsecurity/ and it seems to be doing the job! I can’t even connect my iPod to transfer some music and files to my office pc. L They can assign who can use external devices and what they use.
Submitted by Anonymous on Tue, 12/04/2007 - 09:59.

We use another way of blocking usb devices. Our desktop management system - desktop authority handles this task quite well. After upgrading to new version several weeks ago we have some nice new abilities for managing anuthorized access to usb ports. Now we can block or allow only particular devices by the serial numbers or manufacturer IDs.

Submitted by Anonymous on Tue, 08/21/2007 - 06:54.

Hi,
This is the exact post what I was trying to find. I did all the steps as mentioned above. It is not working for me.. I can see the 'Services und Drivers' under Administrative Templates. I can enable the 'USB Storage'. But it is in red color. But it is showing 'Enabled' under Settings. What could be the problem..? can u pls help me out...?

Submitted by Anonymous on Wed, 08/08/2007 - 21:35.

Hi Hannes and expert,
There is a system error 1058 has occured during execute "net start usbstor" on command prompt. The explanation given "The service cannot be started, either because it is disabled or because it has no enabled devices associated with it."

I have double confirmed the value of the HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\UsbStor\Start is set to 0x0000000(4) after reboot the machine.

Appreciate for you guys assistance on this matter.

Jeff Q

Submitted by Anonymous on Tue, 08/07/2007 - 03:47.

I can confirm this works - had to figure that out for myself but adding an additional line at the end corrects the above issue. If you follow the step-by-step guide (pcs 'must' be rebooted as the policy you are applying is to computers on the network and policies are applied on connection to a network which happens during the boot-up process).

FYI - running the 'net start usbstor' command will error if there is no USB device plugged in. Just run the command with the usb storage device plugged in and all should be well :)

Minh N.

Submitted by Hannes Schmidt on Mon, 08/06/2007 - 05:55.

Hi Jeff,

Are you by any chance using 2k3 with Group Management Console SP1? If so, try adding an empty line at the end of the ADM file. See this post for details. I also changed the file attached to this article to include a newline at the end.

-- Hannes

Submitted by Anonymous on Sun, 08/05/2007 - 23:54.

Hi Hannes,
The following error occured during i'm performing step 7 that written by you. The error message as below:
----------------------------------------------------------------------
\\domain.com\SysVol\domain.com\Policies\{02F4FCEF-6DF0-4030-961F-32A95E778085}\aDM\USBSTOR.ADM ONLINE 17:

eRROR 51 unexpected keyword

Found: CATEGOR
Expected: CATEGORY

The file can not be loaded
----------------------------------------------------------------------

I have double confirmed the "CATEGORY" is written correctly in usbstor.adm file (line 17) but no idea why system found it spell wrongly. Really appreciate ur assistance on this matter. Thanks

Jeff

Submitted by Anonymous on Thu, 07/05/2007 - 07:00.

Hi there,i read your article. Thanks for such wonderful efforts.I am creating an application in which I want to enable and disable USB drive. I tried it in following way. I changed the registry entries for start and image path under key HKEY_LOCAL_MACHINE/system/current control set/services/USBSTOR. But I need to restart the computer for these changes to take effect. How should I avoid the restarting of the system?Is there any windos service to be stopped? When I tried to use net stop usbstor ,it gives me error that cant execute this command.
Can you please let me know how can I do it?
My requirement is something like this.

(1) USB1 is inserted in USB port1.
(2) Run [my exe] USB.exe (Parameter as disable).
(3) Insert another USB i.e. USB 2 in usb port 2. It should be disabled.
(4) Again Run USB.exe (parameter as enable).
(5) Insert USB. It should be enabled.

Kindly reply as early as you can as this is very urgent for me.
Thanks in advance.
Abhijit

Submitted by Hannes Schmidt on Tue, 05/22/2007 - 23:24.

The solution described here did work for me. Otherwise I wouldn't have written this article. But everyone's mileage varies. I'm happy to hear that you found a solution that works for you.

-- Hannes

Submitted by Anonymous on Tue, 05/22/2007 - 04:58.

Yes, I was right, locking files won't work. Here's a kind of solution:
http://www.intelliadmin.com/blog/2007/01/disable-usb-flash-drives.html
Drony

Submitted by Anonymous on Tue, 05/22/2007 - 03:57.

Hannes,
I think you are not quite right. I assume that PNP driver is installed by System account that has F rights to both registry and files mentioned. I'm still playing with it, but I can't stop USB from working under regular accounts.
Actually, the only thing we need is to prevent SYSTEM acc to write into HKLM\SYSTEM\CurrentControlSet\Services\USBStor\Start _value_, but we can restrict writing to the _key_ only, so SYSTEM would not be able to install driver even for permitted users.
So far I can't find the solution...
Drony

Submitted by Anonymous on Fri, 05/04/2007 - 03:19.

I am having some problems getting this to work. The GPO seems to be being applied correctly, the security permissions on the two files mentioned are correct, and the registry key is set to 4.
However, when I log on as a standard user the usb keys work. If I then log on as an administrator again, the key has changed back to 3.

Any ideas would be greatly appreciated

Alex

Submitted by Hannes Schmidt on Sat, 04/07/2007 - 00:37.

I don't quite agree with your line of reasoning here and usually I don't tolerate "URL drops" in comments but I'll make an exception this time because the software you mention seems legit and has its purpose.

-- Hannes

Submitted by Anonymous on Thu, 04/05/2007 - 13:20.

We don't want to roll out any settings through GPOs that aren't easy to roll back or control on a per-PC basis so we're gonna update our PCs remotely using a great FREE utility by IntelliAdmin:

http://www.intelliadmin.com/blog/2007/01/disable-usb-flash-drives.html

It is free, changes the USBSTOR registry setting, and renames the usbstor.inf and usbstor.pnf files so the driver won't work. Also, it is easily reversible with the same utility and I don't have to leave my chair to hit every PC in the domain. I love it!

Submitted by Anonymous on Thu, 02/15/2007 - 16:45.

Unfortunately the block works fine for USB Pen Drives and Hard Disk, but today phones can be conected to syncronize with email and used as a storage device. Windows XP does not understand that phones are also storage devices.

Submitted by Anonymous on Tue, 01/09/2007 - 22:51.

Hi,

The USBstore.reg is really working for me, but on executing locall systems only, planning to convert the same to MSI package and implement through GP on 2003.

If it works it would be great for me.

Thanks & Regards,
Aravind

Submitted by Anonymous on Thu, 12/21/2006 - 16:51.

Have a look at www.securewave.com they have a tool called Sanctuary Device Control: it is extremely secure and allows customised access to certain brands / models of usb keys. it also allows you to encrypt usb keys as soon as they are plugged in. NICE!

Submitted by Anonymous on Wed, 11/29/2006 - 15:46.

I am having the same problem as Derek, my clients are XP machines and I can see that the GPO is being applied correctly but I can still add new USB devices to the computer.

Submitted by Hannes Schmidt on Tue, 10/17/2006 - 08:47.

You can grant users the right to control a service using the Security Settings - System Services setting of a Group Policy. This is a starter How To Configure Group Policies to Set Security for System Services

-- Hannes

Submitted by Anonymous on Tue, 10/17/2006 - 04:34.

Hello!

you say: "The only minor drawback of my solution is that users with access to USB storage need to manually start USBSTOR before connecting USB storage devices." ok, but how can do that user what not a member administrators group? when login and type "net start usbstor" gave "access denied" message. and when i login with administrative rights message is: "service is disabled or..." ok its correct because in registry set 4 (disable). In this situation you must after "net start..." place new registry value, and (reboot is necesary?) then start service? so this article is good for completly disable USB storage - or meybe i'm not read carefully...

ps.
sorry english is not my natice langage
.

greets

Submitted by Hannes Schmidt on Wed, 08/23/2006 - 23:35.

Have you actually tried it? Because this article is about disabling usbstor.sys which stands for USB storage. Usbstor.sys is not responsible for talking to HID devices. I have used this method on plenty boxes with both USB mouse and keyboard. If it disables your USB mouse/keyboard you must have either picked the wrong file or something else is messed up on your system. Sorry.

-- Hannes

Submitted by Anonymous on Wed, 08/23/2006 - 07:14.

It seems this method also blocks USB-keyboards and USB-mice. Many PC's today do not have a PS2 port anymore for keyboard and mouse. Therefore an USB port must be used. How to distinguish between an allowed keyboard and a forbidden USB memory stick?

Submitted by Anonymous on Mon, 05/22/2006 - 07:21.

Sorry - just discovered the check box to un-check in 'View' - doh!

Submitted by Anonymous on Mon, 05/22/2006 - 04:20.

This is just what we are looking for. The only thing is the 'usbstor.adm' is not merging completely. The "Security and Devices" heading is going in, but no 'parts'. Also I noticed that the final line in the file was not 'terminated', so I just pressed 'Return' to go to a new line, then it went into AD, but still no 'parts'

Submitted by Anonymous on Fri, 05/19/2006 - 02:58.

I'm also facing same problem in windows 2003 server can u people help me out with this problem.

Submitted by Hannes Schmidt on Tue, 04/25/2006 - 11:23.

Hi Derek,

I have some troubleshooting tips for you. Verify the security settings of USBSTOR.INF and .PNF on the local hard drive. If they are readable by anyone without admin rights, the GPO is not applied correctly or the GPO's file system security settings are not setup properly. The reasons for a GPO not being applied are manifold. Microsoft's gpresult tool may help here.

Also verify that HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\UsbStor\Start is really set to 4. If it isn't, either a reboot is necessary or the GPO is not applied.

Last but not least, if you're trying restrict access to USB storage connected to your server you do NOT need to use GPOs. The GPO solution is really only necessary for multiple clients. If you are trying to do this only for the server, it's enough to set the above registry value and restrict the security setting of USBSTOR.INF and .PNF on the server drive. OTOH, I have never used this on WS2003 so this technique might not work. But if your ARE doing this for many clients, you should do it via GPO's and in that case it doesn't really matter what OS the server runs, as long as the GPOs are applied.

-- Hannes

Submitted by Anonymous on Tue, 04/25/2006 - 08:44.

I have had some troubles getting this to work with Windows Server 2003 and active directory. Everything seems to install properly but the usb stick is still able to be used. My account does not have admin rights and is still able to use the USB stick. We also removed everyone and the only people that have access are the system and admins.

Derek Warner