Removable Media Security · Research

When a USB stick types faster than you do

A device that enumerates as a keyboard needs no exploit and no driver bug. We walk through how keystroke injection works, rebuild it on a lab bench, and show which controls actually stop it.

Why removable media is still a way in

Air gaps and locked-down workstations push attackers toward the one channel people still carry by hand. A USB device crosses every network boundary in a pocket, and most hosts accept it the moment it is plugged in.

Case in point · 2010

A worm that reached industrial controllers through infected removable drives showed that an isolated network is only as isolated as the media that enters it.

Four families of USB attacks

Researchers group USB attacks by what the device pretends to be and how it reaches the host. The families below overlap, but each needs a different defence.

Purpose-built injectors

Hardware designed from the start to emulate a keyboard and replay a stored payload.

Reflashed peripherals

Ordinary devices whose firmware was rewritten so they announce a different class.

Abused standard devices

Unmodified hardware misused through drivers, autorun features or storage tricks.

Electrical attacks

Devices that discharge stored energy into the port to destroy the host.

Grouping adapted from public academic surveys of USB-based attacks.

How the host decides what a device is

When a device is attached, the host asks it to describe itself. The answer includes a class code, and a device that answers "keyboard" is trusted as a keyboard. Nothing in the protocol checks that a person is behind the keys.

Lab bench with a target laptop and capture host

Our lab bench: the injector, a target laptop and a capture host on an isolated switch.

Anatomy of a keystroke injection

The attack needs only the time it takes to type. Because the input arrives through the keyboard path, application allow-lists and many endpoint rules treat it as the user.

Keystroke injection, step by step

  1. Insert

    A device that looks like storage is connected to an unlocked host.

  2. Enumerate

    It reports itself as a keyboard and the host loads the generic driver.

  3. Type

    A stored script sends hundreds of keystrokes per second.

  4. Run

    The commands execute with the logged-in user's rights.

Reproducing it in the lab

For the demo we wrote a short payload that opens a terminal, writes a marker file named u515_marker.txt and closes the window again. The whole sequence finishes before the window has fully drawn.

# Payload logic, expressed as the shell commands it types
cd "$HOME"
printf 'keystroke injection test\n' > u515_marker.txt
exit

What actually stops it

Blocking storage classes does not help, because the device never acts as storage. Effective controls look at device class, timing and where the media is inspected before it reaches a production host.

  1. Inspect media at the edge. Scan removable media at a dedicated station before it is allowed inside the facility.
  2. Allow-list device classes. Refuse new keyboard-class devices on hosts that never need one.
  3. Watch typing cadence. Flag input that arrives faster than any person can type.
  4. Lock idle sessions. An injector is useless against a locked screen.

A media inspection workflow fits into three short steps for the people carrying the media:

  1. Insert media

  2. Scan and sanitize

  3. Review the report

Talk to an Expert

Tags
  • Removable media
  • Keystroke injection
  • HID

About the author

thanhlocpanda

Senior Security Researcher

Leads Unit 515 research on industrial controllers and network infrastructure, from firmware teardown to coordinated disclosure with vendors.

Stay Updated on Unit 515 Research

Get updates on vulnerability discoveries, technical analyses, and the latest research from OPSWAT Unit 515.

Subscribe