keystroke injection
termKept in this browser · My desk
An attack in which a device presents itself to a computer as a USB keyboard and types a prepared script with the logged-in user's privileges.
USB's human interface device class lets any device declare itself a keyboard, and hosts accept it without authentication; a 2018 systematization of USB attacks called this the trust-by-default nature of the ecosystem. Programmable keystroke devices appeared in 2010, with Adrian Crenshaw's Teensy-based dongle at DEF CON 18 and Hak5's USB Rubber Ducky. The FBI warned in January 2022 that the FIN7 group mailed such devices to US companies.
How it works. A boot-protocol keyboard sends eight-byte reports holding modifier bits and up to six key codes; the host translates them through the HID usage tables, so a device that sends the right codes opens a Run dialog or a terminal and types commands. What it cannot do. It acts only while plugged in, needs the target's keyboard layout and a logged-in session to do most things, and is visible on screen while it types. Variants. Tools add mass storage or network adapters (the Bash Bunny), hide inside cables (the O.MG Cable), or come from reprogrammed ordinary peripherals (BadUSB). Defences. Policy against unknown devices; macOS's accessory approval on Apple silicon laptops; Linux USB authorization through USBGuard rules; Windows device installation policies and device control, noting that blocking removable storage does not stop a keyboard; keystroke-timing checks such as Google's UKIP, which tools counter with random delays; logging of new devices (Windows event 6416). Law. In Brazil, article 154-A of the Penal Code punishes intrusion, and its paragraph 1 producing or selling a device intended to enable it.
Also known as: keystroke injection attack, HID attack, HID injection, hotplug attack, injeção de teclas
Sources
- USB Implementers Forum, Device Class Definition for HID 1.11, 27 June 2001 (read 2026-11-16): boot keyboard subclass; eight-byte input report (modifiers, reserved, six key codes); one-byte LED output report
- Tian, Scaife, Kumar, Bailey, Bates and Butler, SoK: Plug & Pray Today, IEEE S&P 2018 (read 2026-11-16): all USB attacks abuse the trust-by-default nature of the ecosystem; no existing defence is complete
- InfoconDB, DEF CON 18, Adrian Crenshaw, Programmable HID USB Keystroke Dongle, 31 July 2010 (read 2026-11-16): Teensy-based device typing stored keystrokes on plug-in, after a delay or on sensor triggers
- Hak5 documentation, USB Rubber Ducky (read 2026-11-16): Hak5 says it introduced keystroke injection in 2010 with the USB Rubber Ducky; hardware mark I (2011) and II (2022)
- WaterISAC, FBI FLASH: FIN7 Cyber Actors Target US Businesses Through USB Keystroke Injection Attacks, 11 January 2022 (read 2026-11-16): packages with BadUSB or Bad Beetle USB devices; the device injects keystrokes to download and execute malware
- Google Open Source Blog, USB Keystroke Injection Protection, 10 March 2020 (read 2026-11-16): UKIP measures keystroke timing, monitor and hardening modes, not a silver bullet