What it does. 'Implements USB device control policies to restrict unauthorized removable Part of mukul975/Anthropic-Cybersecurity-Skills (817 security skills) (mukul975/Anthropic-Cybersecurity-Skills).
Install
npx skills add mukul975/Anthropic-Cybersecurity-Skills --skill implementing-usb-device-control-policy, or copy the skill folder into ~/.claude/skills/implementing-usb-device-control-policy/.
- Raw file:
curl -sL https://raw.githubusercontent.com/mukul975/Anthropic-Cybersecurity-Skills/HEAD/skills/implementing-usb-device-control-policy/SKILL.md
SKILL.md (verbatim)
name: implementing-usb-device-control-policy
description: 'Implements USB device control policies to restrict unauthorized removable
media access on endpoints, preventing data exfiltration and malware introduction
via USB devices. Use when deploying device control via Group Policy, Intune, or
EDR platforms to enforce USB restrictions. Activates for requests involving USB
control, removable media policy, device control, or data loss prevention via USB.
'
domain: cybersecurity
subdomain: endpoint-security
tags:
- endpoint
- USB-control
- device-control
- data-loss-prevention
- removable-media
version: 1.0.0
author: mahipal
license: Apache-2.0
nist_csf:
- PR.PS-01
- PR.PS-02
- DE.CM-01
- PR.IR-01
mitre_attack:
- T1055
- T1547
- T1059
- T1036
- T1048
Implementing USB Device Control Policy
When to Use
Use this skill when:
- Restricting USB storage devices to prevent data exfiltration or malware introduction
- Implementing device control policies via GPO, Intune, or EDR device control modules
- Creating USB whitelists for authorized devices while blocking all others
- Meeting compliance requirements for removable media control (PCI DSS, HIPAA)
Do not use for network-based DLP or cloud storage restrictions.
Prerequisites
- Active Directory GPO or Microsoft Intune for policy deployment
- Device Instance IDs of authorized USB devices
- EDR with device control module (CrowdStrike, Microsoft Defender for Endpoint)
- Understanding of USB device classes (mass storage, HID, printer, etc.)
Workflow
Step 1: Inventory Current USB Usage
# Enumerate currently connected USB devices
Get-PnpDevice -Class USB | Select-Object InstanceId, FriendlyName, Status
# Query USB storage history from registry
Get-ItemProperty "HKLM:\SYSTEM\CurrentControlSet\Enum\USBSTOR\*\*" |
Select-Object FriendlyName, ContainerID, HardwareID
# Collect USB usage across fleet (via EDR or scripts)
# CrowdStrike: Investigate → USB Device Activity
# MDE: DeviceEvents | where ActionType == "UsbDriveMounted"
Computer Configuration → Administrative Templates → System → Removable Storage Access
- All Removable Storage classes: Deny all access → Enabled
(Block read AND write for all removable storage)
OR for granular control:
- CD and DVD: Deny read access → Enabled
- Removable Disks: Deny write access → Enabled (read-only USB)
- Tape Drives: Deny all access → Enabled
- WPD Devices: Deny all access → Enabled
To allow specific approved USB devices:
Computer Configuration → Administrative Templates → System → Device Installation
→ Device Installation Restrictions
- Prevent installation of devices not described by other policy settings → Enabled
- Allow installation of devices that match any of these device IDs → Enabled
Add approved Device IDs: USB\VID_0781&PID_5583 (example: SanDisk Cruzer)
Step 3: Deploy via Microsoft Defender for Endpoint
<!-- MDE Device Control policy (XML format) -->
<PolicyGroups>
<Group Id="{d9a81dc0-1234-5678-9abc-def012345678}"
Type="Device" Name="Approved USB Devices">
<MatchClause>
<MatchType>VID_PID</MatchType>
<MatchData>0781_5583</MatchData> <!-- SanDisk -->
</MatchClause>
</Group>
</PolicyGroups>
<PolicyRules>
<Rule Id="{rule-guid}" Name="Block unapproved USB storage">
<IncludedIdList>
<PrimaryId>RemovableMediaDevices</PrimaryId>
</IncludedIdList>
<ExcludedIdList>
<GroupId>{d9a81dc0-1234-5678-9abc-def012345678}</GroupId>
</ExcludedIdList>
<Entry>
<Type>Deny</Type>
<AccessMask>63</AccessMask> <!-- All access -->
<Options>4</Options> <!-- Show notification -->
</Entry>
</Rule>
</PolicyRules>
Step 4: Audit and Monitor
# Monitor USB events in SIEM:
# Windows Event ID 6416 - New external device recognized
# Windows Event ID 4663 - File access on removable media
# MDE: DeviceEvents where ActionType contains "Usb"
# Generate USB activity reports monthly
# Track: blocked attempts, approved device usage, exception requests
Key Concepts
| Term |
Definition |
| VID/PID |
Vendor ID and Product ID that uniquely identify USB device models |
| Device Instance ID |
Unique identifier for a specific physical USB device |
| Device Control |
EDR/endpoint feature restricting device access based on type, vendor, or serial number |
| USB Class |
USB device category (mass storage 08h, HID 03h, printer 07h) |
- Microsoft Defender Device Control: MDE module for USB restriction policies
- CrowdStrike Falcon Device Control: EDR-based USB policy enforcement
- Group Policy (Removable Storage Access): Built-in Windows USB restriction via GPO
- Endpoint Protector: Third-party device control and DLP solution
Common Pitfalls
- Blocking all USB without exception: Keyboards and mice are USB HID devices. Block only mass storage class, not all USB.
- Not communicating policy to users: USB blocks without user notification generate helpdesk tickets. Display a notification explaining the policy.
- Ignoring USB-C and Thunderbolt: Modern devices use USB-C for docking, charging, and storage. Policies must distinguish between USB storage and USB peripherals.
- No approved device process: Users with legitimate USB needs (presentations, field data collection) require an exception process with approved, encrypted devices.
Other files in this skill
assets/template.md (verbatim)
USB Device Control Policy Template
Policy Configuration
| Setting |
Value |
| Default Action |
Block all removable storage |
| Enforcement Mode |
Audit / Enforce |
| Notification |
Display user message |
Approved Devices
| Device Name |
VID:PID |
Serial |
Issued To |
Expiry |
|
|
|
|
|
Exception Register
| User |
Business Justification |
Device |
Approved By |
Expiry |
|
|
|
|
|
Sign-Off
| Role |
Name |
Date |
| Security |
|
|
| IT Ops |
|
|
references/api-reference.md (verbatim)
API Reference: USB Device Control Policy Audit
Libraries Used
| Library |
Purpose |
subprocess |
Execute PowerShell, udevadm, and registry query commands |
json |
Parse device inventory and policy status |
platform |
Detect operating system for platform-specific checks |
re |
Parse device IDs and USB vendor/product codes |
Installation
# No external packages — uses standard library and OS tools
Windows USB Device Audit
List Connected USB Devices (PowerShell)
import subprocess
import json
def list_usb_devices_windows():
cmd = [
"powershell", "-Command",
"Get-PnpDevice -Class USB | Select-Object Status, Class, FriendlyName, InstanceId | ConvertTo-Json"
]
result = subprocess.run(cmd, capture_output=True, text=True, timeout=30)
return json.loads(result.stdout) if result.stdout else []
Check USB Storage Policy (Registry)
def check_usb_storage_policy():
"""Check if USB mass storage is disabled via registry."""
cmd = [
"powershell", "-Command",
'Get-ItemProperty -Path "HKLM:\\SYSTEM\\CurrentControlSet\\Services\\USBSTOR" -Name Start | Select-Object Start | ConvertTo-Json'
]
result = subprocess.run(cmd, capture_output=True, text=True, timeout=15)
if result.stdout:
data = json.loads(result.stdout)
start_value = data.get("Start", 3)
return {
"usb_storage_disabled": start_value == 4,
"registry_value": start_value,
"policy": "disabled" if start_value == 4 else "enabled",
"detail": {
3: "USB storage ENABLED (default)",
4: "USB storage DISABLED",
}.get(start_value, f"Unknown value: {start_value}"),
}
return {"usb_storage_disabled": False, "error": "Could not read registry"}
Check Group Policy for Removable Storage
def check_gpo_removable_storage():
"""Check GPO settings for removable storage restrictions."""
policies = {
"deny_read": r"HKLM\SOFTWARE\Policies\Microsoft\Windows\RemovableStorageDevices\{53f5630d-b6bf-11d0-94f2-00a0c91efb8b}\Deny_Read",
"deny_write": r"HKLM\SOFTWARE\Policies\Microsoft\Windows\RemovableStorageDevices\{53f5630d-b6bf-11d0-94f2-00a0c91efb8b}\Deny_Write",
"deny_execute": r"HKLM\SOFTWARE\Policies\Microsoft\Windows\RemovableStorageDevices\{53f5630d-b6bf-11d0-94f2-00a0c91efb8b}\Deny_Execute",
}
results = {}
for name, path in policies.items():
cmd = ["reg", "query", path.rsplit("\\", 1)[0], "/v", path.rsplit("\\", 1)[1]]
result = subprocess.run(cmd, capture_output=True, text=True, timeout=10)
results[name] = "1" in result.stdout if result.returncode == 0 else False
return results
USB Device History (Windows)
def get_usb_history_windows():
"""List previously connected USB storage devices from registry."""
cmd = [
"powershell", "-Command",
'Get-ItemProperty "HKLM:\\SYSTEM\\CurrentControlSet\\Enum\\USBSTOR\\*\\*" | Select-Object FriendlyName, DeviceDesc, Mfg | ConvertTo-Json'
]
result = subprocess.run(cmd, capture_output=True, text=True, timeout=30)
return json.loads(result.stdout) if result.stdout else []
Linux USB Device Audit
List USB Devices
def list_usb_devices_linux():
result = subprocess.run(
["lsusb"], capture_output=True, text=True, timeout=10
)
devices = []
for line in result.stdout.strip().split("\n"):
if line:
devices.append(line.strip())
return devices
Check USBGuard Policy
def check_usbguard_status():
"""Check if USBGuard is installed and active."""
# Check service status
result = subprocess.run(
["systemctl", "is-active", "usbguard"],
capture_output=True, text=True, timeout=10,
)
service_active = result.stdout.strip() == "active"
# List current policy rules
rules = []
if service_active:
result = subprocess.run(
["usbguard", "list-rules"],
capture_output=True, text=True, timeout=10,
)
rules = result.stdout.strip().split("\n") if result.stdout else []
return {
"usbguard_installed": service_active or result.returncode != 127,
"service_active": service_active,
"policy_rules": len(rules),
"default_policy": "block" if any("block" in r for r in rules) else "allow",
}
Check udev Rules for USB Control
def check_udev_rules():
"""Check for USB control udev rules."""
result = subprocess.run(
["find", "/etc/udev/rules.d/", "-name", "*usb*", "-type", "f"],
capture_output=True, text=True, timeout=10,
)
rules_files = result.stdout.strip().split("\n") if result.stdout.strip() else []
return {"udev_usb_rules": rules_files, "count": len(rules_files)}
Device Whitelist Management
APPROVED_DEVICES = [
{"vendor_id": "046d", "product_id": "c52b", "name": "Logitech Receiver"},
{"vendor_id": "0781", "product_id": "5583", "name": "SanDisk Encrypted Drive"},
]
def check_against_whitelist(connected_devices, approved=APPROVED_DEVICES):
approved_ids = {(d["vendor_id"], d["product_id"]) for d in approved}
findings = []
for device in connected_devices:
vid = device.get("vendor_id", "")
pid = device.get("product_id", "")
if (vid, pid) not in approved_ids:
findings.append({
"device": device.get("name", "Unknown"),
"vendor_id": vid,
"product_id": pid,
"issue": "Device not in approved whitelist",
"severity": "medium",
})
return findings
{
"platform": "windows",
"usb_storage_disabled": true,
"gpo_deny_read": true,
"gpo_deny_write": true,
"connected_devices": 3,
"unapproved_devices": 1,
"historical_devices": 12,
"findings": [
{
"device": "Unknown USB Mass Storage",
"vendor_id": "0951",
"product_id": "1666",
"issue": "Device not in approved whitelist",
"severity": "medium"
}
]
}
references/standards.md (verbatim)
Standards & References
Primary Standards
- NIST SP 800-53 MP-7: Media Use - restricting removable media types and usage
- PCI DSS 4.0 Req 3.4.2: Restrict removable electronic media for cardholder data
- CIS Control 10.4: Configure device control to prevent removable media autorun
- ISO 27001 A.8.3.1: Management of removable media
Supporting References
references/workflows.md (verbatim)
Workflows
Workflow 1: USB Device Control Deployment
[Audit current USB usage across fleet] → [Identify legitimate USB needs]
→ [Create approved device whitelist] → [Configure block policy with exceptions]
→ [Deploy in audit mode for 2 weeks] → [Review blocked events]
→ [Add missing legitimate devices] → [Switch to enforce mode]
→ [Communicate policy to users] → [Monitor and maintain]
Workflow 2: USB Exception Request
[User requests USB access] → [Verify business justification]
→ [Issue approved encrypted USB device] → [Add device ID to whitelist]
→ [Deploy updated policy] → [Log exception with expiry date]
Back to mukul975/Anthropic-Cybersecurity-Skills (817 security skills) or Agent skills.