Skip to main content

Linux USB Policy V2

Overview

The Linux USB Policy V2 lets administrators allow or block USB devices and individual USB functions on managed Linux devices.

Instead of applying one setting to every USB connection, the policy uses rules. Each rule can match:

  • One or more Linux USB events

  • A whole USB device or an individual USB interface

  • A USB class, such as mass storage, video, printer, or HID

  • An optional vendor ID

  • An optional product ID

The rule then authorizes or deauthorizes the matching device or interface.

Common use cases include:

  • Blocking USB mass-storage devices while leaving keyboards and mice available

  • Blocking USB cameras or printers

  • Blocking one specific model of USB device

  • Controlling one function of a composite device without disabling its other functions

  • Reauthorizing an approved device or interface

The policy is available for both company-owned and BYOD Linux devices.

Important: Test USB restrictions on a nonproduction device before broad deployment. A rule that blocks HID devices, hubs, wireless controllers, or a whole composite device can disable keyboards, mice, docks, network adapters, Bluetooth hardware, or other required peripherals.

Supported Platforms

Capability

Supported platform

USB device authorization rules

Linux

USB interface authorization rules

Linux

Company-owned devices

Supported

BYOD devices

Supported

The effective behavior depends on the Linux kernel, USB device descriptors, drivers, hardware topology, and distribution configuration.

How the Policy Works

Linux exposes an authorization state for USB devices and USB interfaces. A device or interface with an authorized value of 1 is allowed to operate. Setting the value to 0 deauthorizes it.

Linux supports control at two levels:

  • Device level: Authorizes or deauthorizes the entire USB device.

  • Interface level: Authorizes or deauthorizes one function exposed by a device.

Linux kernel documentation explains both authorization levels in Authorizing USB devices to connect to the system.

Swif creates Linux USB authorization rules from the settings in this policy. When a configured USB event occurs and the device or interface matches the rule, Swif applies the selected authorization state.

The policy controls the operating system's use of USB devices. It does not:

  • Physically disable or remove power from a USB port.

  • Prevent a device from appearing in hardware inventory.

  • Guarantee that an unauthorized device cannot expose identifying descriptors.

  • Control Thunderbolt, PCIe, Bluetooth, or other non-USB devices unless they present a matching USB function.

  • Encrypt data stored on an allowed USB device.

  • Scan an allowed device for malware.

  • Prevent data transfer through network, cloud, or other non-USB channels.


Device Rules and Interface Rules

Selecting the correct rule level is essential.

USB Device

A rule with Rule Level set to usb_device evaluates the class in the device descriptor and changes authorization for the entire USB device.

Use this level when:

  • The entire device should be allowed or blocked.

  • The device has a useful device-level class code.

  • Vendor ID and product ID identify the exact hardware to control.

  • No function exposed by a composite device should remain available.

Blocking a whole composite device can disable every function it provides. For example, blocking a USB dock at the device level can affect storage, Ethernet, audio, video, and connected peripherals.

USB Interface

A rule with Rule Level set to usb_interface evaluates the class in an interface descriptor and changes authorization for that individual function.

Use this level when:

  • You need to control a class commonly declared at the interface level.

  • You want to block storage while preserving another function on the same physical device.

  • A device reports class 00, meaning its class information is stored in its interface descriptors.

For broad USB mass-storage control, use usb_interface with class 08 Mass Storage. Many flash drives and composite devices expose storage as an interface rather than as the whole device's class.

Note: Some drivers require several interfaces to operate together. Blocking one interface can cause the whole peripheral or one of its other functions to behave unexpectedly. Reauthorizing an interface may also require a reconnect or driver reprobe. Test representative hardware before production deployment.

Before You Begin

Before creating the policy:

  1. Confirm that each target device is enrolled in Swif and online.

  2. Inventory required USB peripherals, including internal USB-connected hardware.

  3. Identify each required device's class, vendor ID, and product ID.

  4. Determine whether the required match belongs at the device or interface level.

  5. Ensure that administrators retain a non-USB recovery path, such as a built-in keyboard, remote access, or console access.

  6. Test the intended rules on the Linux distributions, kernels, device models, docks, and peripherals used in production.

  7. Inform BYOD users which personal peripherals may be restricted.

Do not begin testing by broadly blocking HID devices, hubs, or wireless controllers.

Identify a USB Device

Connect the device and run:

lsusb

Example output:

Bus 001 Device 004: ID 0781:5581 Example USB Storage

In this example:

  • Vendor ID: 0781

  • Product ID: 5581

Enter vendor and product IDs as exactly four hexadecimal characters without 0x.

To inspect the USB topology and interface classes:

lsusb -t

For more detailed descriptor information:

sudo lsusb -v

Detailed USB output may contain serial numbers and other hardware identifiers. Redact sensitive values before sharing logs or screenshots.

Create the Policy

  1. In the Swif Admin Dashboard, go to Device Management > Policies.

  2. Create a new policy.

  3. Select Linux USB Policy V2.

  4. Enter a descriptive policy name.

  5. Under USB Rules, add a rule.

  6. Select one or more Trigger Actions.

  7. Choose the Rule Level.

  8. Select the USB Class Code.

  9. Set Authorization to allow or block the match.

  10. Optionally enter a four-digit Vendor ID.

  11. Optionally enter a four-digit Product ID.

  12. Add additional rules only when needed.

  13. Assign the policy to one test device or a small test device group.

  14. Reconnect the test peripheral and verify the result.

  15. Expand deployment only after confirming that required peripherals continue to work.

Recommended Baseline

For a company-owned workstation that must block removable USB storage:

Setting

Recommended value

Trigger Actions

add, bind, and change

Rule Level

usb_interface

USB Class Code

08 Mass Storage

Authorization

Blocked (false)

Vendor ID

Leave empty

Product ID

Leave empty

This rule targets mass-storage interfaces without intentionally blocking unrelated HID, audio, video, or network interfaces.

Test phones, cameras, docks, card readers, encrypted drives, and multifunction devices separately. A device can expose more than one class, and its behavior may differ between operating modes.


Policy Settings

USB Rules

USB Rules is a list of individual authorization rules. Each rule contains its own event, scope, class, authorization, and optional hardware identifiers.

Keep the rule set as small and specific as possible. Avoid overlapping allow and block rules for the same hardware unless you have tested the effective result. Conflicting rules can make behavior dependent on which device or interface event is processed.

Trigger Actions

Trigger Actions specifies the Linux USB events that cause a rule to be evaluated.

Value

Meaning

add

A USB device or interface is added to the Linux device tree, commonly after connection or discovery.

bind

A driver binds to the device or interface.

change

The device or interface reports a change event.

For general USB control, select add, bind, and change so the rule can respond across normal discovery and driver activity.

If a device was already connected before the policy was applied, disconnect and reconnect it during a controlled test to ensure that a new event occurs.

Rule Level

Rule Level determines which USB descriptor and authorization target the rule uses.

Value

Behavior

usb_device

Matches the whole device's class and authorizes or deauthorizes the entire device.

usb_interface

Matches an individual interface's class and authorizes or deauthorizes only that function.

Use usb_interface for classes normally declared on interfaces, including HID, mass storage, printer, audio, and video. Use usb_device when you intentionally need to control the entire hardware device.

USB Class Code

USB Class Code identifies the type of USB device or function to match.

Code

Class

00

Use class information in the interface descriptors

01

Audio

02

Communications and CDC Control

03

HID (Human Interface Device)

05

Physical

06

Image

07

Printer

08

Mass Storage

09

Hub

0a

CDC-Data

0b

Smart Card

0d

Content Security

0e

Video

0f

Personal Healthcare

10

Audio/Video Devices

11

Billboard Device

12

USB Type-C Bridge

13

USB Bulk Display Protocol

14

MCTP over USB Protocol Endpoint

3c

I3C Device

dc

Diagnostic Device

e0

Wireless Controller

ef

Miscellaneous

fe

Application Specific

ff

Vendor Specific

USB class information can appear in a device descriptor, an interface descriptor, or both, depending on the class. The USB Implementers Forum maintains the authoritative USB defined class codes.

Class 00 does not mean that a device has no function. At the device level, it commonly means that the actual functions must be read from the interface descriptors.

Authorization

Authorization determines what happens to a matching device or interface.

Value

Behavior

Allowed (true)

Authorizes the matching USB device or interface.

Blocked (false)

Deauthorizes the matching USB device or interface.

Use Blocked to prevent Linux from using the matched target.

Use Allowed only as part of a tested rule design, such as reauthorizing an approved target. Linux authorizes USB devices and interfaces by default unless another rule or system configuration changes that behavior. An allow rule by itself is not a complete default-deny USB allowlist.

Vendor ID

Vendor ID optionally limits the rule to a USB vendor.

The value must contain four hexadecimal characters.

Example:

0781

Leave the field empty when the rule should match the selected class across all vendors.

Vendor IDs are device-provided identifiers. They help narrow a rule but should not be treated as cryptographic proof that a peripheral is trusted.

Product ID

Product ID optionally limits the rule to a USB product.

The value must contain four hexadecimal characters.

Example:

5581

For a model-specific rule, configure both Vendor ID and Product ID. Leave this field empty when the product does not need to be narrowed.

A product ID can be reused across device revisions, and a programmable device can imitate descriptor values. Treat vendor and product IDs as matching attributes rather than strong device identity.


Example Configurations

Block All USB Mass-Storage Interfaces

Setting

Value

Trigger Actions

add, bind, change

Rule Level

usb_interface

USB Class Code

08 Mass Storage

Authorization

Blocked

Vendor ID

Empty

Product ID

Empty

This is the recommended starting point when the goal is to prevent USB storage while retaining other USB classes.

Block One Specific USB Storage Model

Setting

Example value

Trigger Actions

add, bind, change

Rule Level

usb_interface

USB Class Code

08 Mass Storage

Authorization

Blocked

Vendor ID

0781

Product ID

5581

Replace the example IDs with the values reported by lsusb.

Block USB Camera Interfaces

Setting

Value

Trigger Actions

add, bind, change

Rule Level

usb_interface

USB Class Code

0e Video

Authorization

Blocked

Vendor ID

Empty

Product ID

Empty

Test conferencing devices before deployment. A single physical device may expose video, audio, and HID interfaces separately.

Block an Entire Known Composite Device

Setting

Example value

Trigger Actions

add, bind, change

Rule Level

usb_device

USB Class Code

Match the device descriptor reported by the hardware

Authorization

Blocked

Vendor ID

Device vendor ID

Product ID

Device product ID

Use this configuration only when every function of the matched device should be unavailable.

High-Risk Class Restrictions

Use extra caution with these classes:

Class

Potential impact

03 HID

Can disable USB keyboards, mice, barcode scanners, security tokens, or accessibility devices.

09 Hub

Can disable a dock or every device connected through a USB hub.

02 Communications / 0a CDC-Data

Can disable modems, serial adapters, mobile-device networking, or communications hardware.

0b Smart Card

Can disable smart-card readers used for authentication.

e0 Wireless Controller

Can affect USB Bluetooth or wireless-controller hardware, including internally connected components.

ef Miscellaneous / ff Vendor Specific

Can affect many unrelated or proprietary device functions.

Internal webcams, fingerprint readers, Bluetooth adapters, cellular modems, and other built-in components may connect internally through USB. A restriction can affect them even when the user did not plug anything into an external port.


Company-Owned and BYOD Considerations

Company-Owned Devices

For company-owned Linux devices:

  • Begin with a specific business objective, such as blocking removable storage.

  • Prefer interface-level class rules when only one function must be restricted.

  • Test all standard docks, keyboards, authentication devices, cameras, printers, and network adapters.

  • Maintain remote or console recovery access.

  • Document approved exceptions and hardware identifiers.

  • Review the policy when deploying new device models or peripherals.

  • Use encryption, endpoint protection, data-loss prevention, and network controls in addition to USB authorization.

BYOD Devices

For personally owned devices:

  • Disclose which USB functionality the organization will restrict.

  • Limit the policy to controls required to protect organizational data.

  • Avoid broad rules that interfere with personal peripherals unrelated to work.

  • Test unenrollment and policy-removal behavior.

  • Provide a support and exception process.

  • Confirm that the restriction is consistent with the organization's BYOD agreement and applicable requirements.

This policy affects the Linux operating system, not only a work container or work profile.

Verify the Policy

After applying the policy:

  1. Confirm that the policy reports as installed in Swif.

  2. Disconnect the test USB device.

  3. Reconnect it to generate a new USB event.

  4. Confirm whether the intended function is available.

  5. Verify that unrelated required USB peripherals still work.

  6. Test the same class with more than one device model.

  7. Restart the Linux device and repeat the test.

  8. Test through any approved docks or hubs.

  9. Confirm that the device remains online and manageable in Swif.

Inspect USB Inventory

List connected devices:

lsusb

Show USB topology and interface drivers:

lsusb -t

Review recent kernel messages:

sudo journalctl -k --since "10 minutes ago"

Depending on distribution logging and permissions, USB event details may also be available through:

sudo udevadm monitor --kernel --udev --property

Start monitoring before reconnecting the test device. Stop it with Ctrl+C.

Do not publish unredacted logs that contain device serial numbers or other sensitive identifiers.


Troubleshooting

A Mass-Storage Rule Does Not Block the Device

  1. Confirm that the rule uses usb_interface.

  2. Confirm that the class is 08 Mass Storage.

  3. Select add, bind, and change.

  4. Disconnect and reconnect the device.

  5. Run lsusb -t and confirm that the relevant interface reports mass-storage class behavior.

  6. Check whether the device is using another protocol, mode, or class.

  7. Confirm that the policy is installed and the Swif agent is running.

  8. Review Swif policy command history and Linux system logs.

Some phones and cameras use media-transfer, image, vendor-specific, or networking interfaces rather than USB mass storage.

The Device Appears in lsusb Even Though It Is Blocked

This can be expected. USB deauthorization prevents the operating system from using the matched device or interface; it does not necessarily hide all descriptor or connection information from hardware inventory.

Verify whether the corresponding storage, video, network, printer, or other function is actually usable.

A Composite Device Is Only Partially Blocked

This is expected when an interface-level rule matches only one function.

  • Run lsusb -t or inspect detailed descriptors.

  • Identify every relevant interface class.

  • Add only the additional rules required by the security objective.

  • Use usb_device only when the entire physical device should be disabled.

An Approved Device Is Also Blocked

  • Check whether a broad class rule matches the approved device.

  • Confirm the device's vendor ID, product ID, device class, and interface classes.

  • Review the policy for overlapping allow and block rules.

  • Test a narrower vendor-and-product-specific rule design on one device.

  • Confirm whether another local USB security tool or system rule is also enforcing restrictions.

Do not assume that an allow rule automatically overrides every block rule. Avoid conflicting matches unless their effective behavior has been validated.

A Keyboard, Mouse, Dock, or Bluetooth Adapter Stops Working

  1. Use built-in input, remote access, or console access if available.

  2. Review rules for class 03 HID, 09 Hub, e0 Wireless Controller, ef Miscellaneous, ff Vendor Specific, or a matching device-level rule.

  3. Unassign or correct the high-impact rule through the approved management path.

  4. Reconnect the peripheral or restart the device after the correction.

  5. Confirm that internal USB-connected hardware also works.

Do not deploy the same rule to additional devices until the cause is understood.

Reauthorizing an Interface Does Not Restore It Immediately

Linux kernel behavior may require the driver to probe the interface again after reauthorization.

Try:

  1. Disconnecting and reconnecting the device.

  2. Restarting the affected device during a maintenance window.

  3. Confirming that every interface required by the driver is authorized.

  4. Reviewing kernel and udev logs.

Do not manually change sysfs authorization values on production devices unless you understand the affected hardware and have a recovery path.

The Rule Works Only After Reconnecting the Device

The configured trigger actions correspond to USB events. A device that was already present may not generate a matching new event until it is reconnected, rebound, changed, or the system restarts.

Verify the policy with a controlled disconnect and reconnect. If behavior remains inconsistent, collect the policy result, distribution and kernel version, lsusb output, lsusb -t output, and relevant kernel logs for Swif Support.

Vendor or Product Matching Does Not Work

  • Enter exactly four hexadecimal characters.

  • Do not include 0x, a colon, or spaces.

  • Confirm that the vendor and product values were copied from the same device.

  • Check whether the peripheral changes product ID when switching modes.

  • Inspect both the physical device and its interfaces.

  • Confirm the selected class and rule level.

Example:

Vendor ID: 0781 Product ID: 5581

The Policy Reports Installed but the Rule Has No Effect

  • Confirm that the Swif agent is online.

  • Verify that the target is Linux.

  • Confirm that the rule contains the intended action, level, class, and authorization.

  • Reconnect the peripheral.

  • Check for another USB-control product, custom udev rule, kernel security configuration, or container boundary.

  • Review agent, udev, and kernel logs.

  • Test with a simple, known peripheral on a nonproduction device.

USB Device Not Detected in a Virtual Machine

  • Confirm that the USB device is selected and enabled in the virtual machine's USB device settings (for example, VirtualBox > Devices > USB).

  • Some hypervisors require a USB controller to be added to the virtual machine configuration before USB passthrough works.

  • Run lsusb and ls /sys/bus/usb/devices before and after plugging in the USB device. If no new entry appears after connecting, the host is not passing the device through to the guest.

  • Resolve the virtual machine USB passthrough configuration before testing the Swif policy. A policy cannot control a device that the guest operating system does not see.

  • If the device appears in lsusb but authorization is not changing, proceed with the other troubleshooting steps in this article.

Do not assume a policy bug when the USB device is not visible to the guest operating system. Verify USB passthrough first.

Collecting Diagnostic Information

When troubleshooting an unexpected policy result, collect the following before contacting Swif Support:

  1. Confirm USB passthrough or physical connection.

  2. Run lsusb and ls /sys/bus/usb/devices before and after plugging in the USB device and include both outputs.

  3. If the device is found, run the following to capture full device descriptors:
    lsusb -v -d $VENDOR_ID:

    Replace $VENDOR_ID with the four-character hexadecimal vendor ID reported by lsusb.

  4. Share the content of the udev rules file:

cat /etc/udev/rules.d/99-swifteam-block-usb.rules

This file shows the rules Swif applied. If the file does not exist, the policy may not have been installed or may have already been removed.

Include the policy JSON from the Swif Admin Dashboard, the Linux distribution and kernel version, and any relevant agent or kernel logs alongside the diagnostic output above.

Security and Compliance Impact

USB authorization rules can reduce exposure to removable-media data transfer, unapproved peripherals, and some classes of malicious USB devices. They are one layer of endpoint control.

For a secure deployment:

  • Apply least privilege to USB functionality.

  • Prefer narrowly scoped interface rules.

  • Use vendor and product IDs to narrow a rule when appropriate.

  • Treat descriptor values as untrusted, device-supplied data.

  • Encrypt approved removable storage.

  • Scan approved media and files with endpoint security controls.

  • Restrict local administrative access that could change system enforcement.

  • Monitor policy failures and exception use.

  • Maintain recovery access that does not depend on a blocked USB class.

  • Review rules after hardware, kernel, driver, or distribution changes.

USB class, vendor ID, and product ID are not strong device authentication. Linux kernel documentation warns that device descriptors can be imitated. Do not rely on this policy alone when cryptographic peripheral identity or complete data-loss prevention is required.

This policy can support device-control and data-protection objectives, but it does not independently make an organization compliant with a particular framework.

Notes

  • Linux USB Policy V2 is rule-based.

  • Trigger actions are add, bind, and change.

  • Rule levels are usb_device and usb_interface.

  • Authorization can allow or block a match.

  • Vendor ID and product ID are optional four-digit hexadecimal filters.

  • A device can expose several USB interfaces with different class codes.

  • Class 00 commonly directs the system to inspect interface descriptors.

  • Blocking an interface does not necessarily block the entire physical device.

  • Blocking a whole device can disable every function it exposes.

  • A blocked device may remain visible in hardware inventory.

  • Reauthorization can require reconnecting the device or reprobe of its driver.

  • USB descriptors are not cryptographic identity.

Summary

Linux USB Policy V2 controls USB access with rules based on event, scope, class, and optional hardware identifiers.

For most organizations that need to block removable USB storage:

  1. Select add, bind, and change.

  2. Set Rule Level to usb_interface.

  3. Select 08 Mass Storage.

  4. Set Authorization to blocked.

  5. Leave vendor and product IDs empty to match all vendors, or enter both values to target a specific model.

  6. Test representative devices, docks, and internal USB hardware.

  7. Keep a non-USB recovery path available.

  8. Deploy gradually and monitor exceptions.

Related Resources

Did this answer your question?