Dev.to Security 🔐 Cybersecurity 👁 2 📖 12 min read

usb2shell (CVE-2026-98232): How to Check and Lock Down Linux Devices With Open USB Ports

On November 30, the Italian security firm Drivesec published usb2shell, a write-up for CVE-2026-98232. The short version from their page: "A malicious USB device can make the Linux kernel run a command of its choice as r

On November 30, the Italian security firm Drivesec published usb2shell, a write-up for CVE-2026-98232. The short version from their page: "A malicious USB device can make the Linux kernel run a command of its choice as root. Nobody needs to log in, mount anything or click anything." The Hacker News thread passed 280 points within a day.

The bug needs physical access to a USB port. That sounds like a small risk. Then count the Linux boxes with a port that a stranger can touch: point-of-sale terminals, kiosks, EV chargers, car infotainment units and industrial screens. Drivesec names all of these on its own page.

This article is a practical checklist. It explains the bug in plain words and shows how to check a kernel. It also shows why the version number alone can mislead you. Then it walks through the mitigations: update, remove the USB storage drivers, or switch USB to default-deny. I did not run the exploit. Everything below about the attack comes from Drivesec's write-up and the official CVE record. The command examples were run on a test machine where noted.

What the bug is, in plain words

Linux 6.5 (released August 27, 2023) added support for Command Duration Limits (CDL), a feature that lets a disk give some commands a time budget. When the kernel finds a new storage device that says it is an ATA disk with CDL support, it calls a function named scsi_cdl_enable().

That function asks the device for a block of settings (a "mode page") and copies the reply into a 64-byte buffer on the kernel stack. The reply carries its own length fields. According to the CVE record, the kernel used those lengths without checking them. A device can report a total length shorter than its own header, so the subtraction wraps around (an unsigned number going below zero becomes a huge number), and the pointer into the buffer can land outside it.

The CVE text lists two effects during the automatic scan:

  • The kernel can "clear the low two bits of a target-selected out-of-bounds stack byte". In other words, the device picks a byte on the kernel stack and changes it.
  • The kernel can copy "up to 64 bytes from outside the buffer" back to the device. The device gets to read part of the kernel stack.

The read is enough to defeat KASLR (kernel address space layout randomization, which hides where kernel code sits in memory). The small write is the starting point. Drivesec says its chain "builds fake kernel structures to turn the one-byte overwrite into a controlled write."

All of this happens before any program on the machine sees a disk. No filesystem is mounted, and nobody needs to be logged in.

What the proof of concept showed

Drivesec's demo used a Cynthion, an open USB research board, as the attacking device. The target was a stock Debian machine running kernel 6.12.22+bpo-amd64, attacked through a real USB port with KASLR enabled. In the demo video caption, the first two attempts miss and retry without a crash, and the third runs whoami and uname as root. Per the write-up, the command runs when the device is unplugged.

Two details matter for planning:

  • The exploit is probabilistic, but quiet. Drivesec says failed attempts do not crash the target. A missed attempt leaves no kernel panic for anyone to notice.
  • Android is a leak, not a takeover. Android kernels on 6.6 and later are affected, but the builds Drivesec checked (Android GKI and the Samsung Galaxy A16 shipping kernel) use compiler bounds checks that keep the write inside the buffer. The device still reads kernel stack contents.

An AI review bot saw it first

The credits on the usb2shell page include an unusual line. On July 17, 2026, an automated reviewer called Sashiko AI Review replied on the linux-scsi mailing list to a patch that fixed the same kind of bug in a different function (cache_type_store() in sd.c). In its list of pre-existing issues, the bot flagged "[Critical] Stack out-of-bounds read and write in scsi_cdl_enable" because the device-supplied lengths were not validated.

Drivesec says it found the bug on its own on August 26 and had root on physical hardware by August 28. It reported privately on September 2, sent the patch on September 4, and the fix was committed on September 9. The Linux CNA (the kernel's own CVE issuer) published the CVE on October 6. The public write-up came on November 30.

The lesson for anyone fixing a bug: when it comes from a pattern ("trust the device's length field"), search nearby code for the same pattern. That is what the bot did.

Who is exposed

Drivesec lists three conditions. A system is exposed when all of them are true:

  • It runs Linux 6.5 or later without the fix.
  • It has USB mass storage support (the usb-storage or uas driver), built in or loaded automatically.
  • Someone can plug a device into one of its USB ports.

The fixed upstream releases are 6.6.158, 6.12.112, 6.18.54, 7.2.8 and 7.3. The 7.2.8 release came out on September 25, 2026, and its changelog includes "scsi: core: Validate MODE SENSE lengths in scsi_cdl_enable()".

Older kernels are not affected, because the CDL code did not exist before 6.5. One HN commenter noted that much of their IoT and car hardware runs kernels far older than that. Old devices have other problems, but not this one.

Some replies said a malicious USB stick can just pretend to be a keyboard. That attack is real, and this comment points to USB authorization and USBGuard as the defense. But usb2shell attacks the kernel driver itself. It works on a locked screen, or on a machine where nobody is logged in and typed keystrokes would do nothing. A third commenter noted that machines using USB/IP (USB devices shared over a network) could make this a remote problem. That is a commenter's view, not Drivesec's, but check it if you run USB/IP.

Step 1: Check the kernel, then check the vendor

Drivesec publishes a small checker script. Download it, read it, then run it:

curl -fsSLO https://usb2shell.com/tools/usb2shell-check.sh
less usb2shell-check.sh
sh usb2shell-check.sh

The script is short and easy to audit. It compares the kernel version against the fixed releases, checks whether the usb-storage or uas modules exist, and prints the USB authorized_default setting. On Debian it reads the real upstream version from uname -v, because the release string (6.12.22+bpo-amd64 style) can differ from the package version.

You can also pass a version as an argument. A few test runs:

$ sh usb2shell-check.sh 6.1.120
result: not affected (the bug was added in 6.5)

$ sh usb2shell-check.sh 6.6.150
result: vulnerable, unless your vendor backported the fix

$ sh usb2shell-check.sh 6.12.112
result: fixed (fix is in 6.12.112)

$ sh usb2shell-check.sh 7.3-rc4
result: unknown, use the final 7.3 release or later

The exit code is 0 for fixed or not affected, 1 for vulnerable and 2 for unknown, so you can run it across a fleet with any remote shell tool and collect the codes.

Do not stop at the script's verdict. Distributions backport fixes into their own kernel versions, and the script can only compare upstream numbers. A test run on an Ubuntu 24.04 machine with kernel 6.8.0-147-generic printed "vulnerable, unless your vendor backported the fix", because 6.8 is not one of the upstream stable branches in the script. The answer is on the vendor's tracker:

  • Ubuntu's CVE page rates it Medium and lists 24.04 LTS as fixed in 6.8.0-149.149 and 26.04 LTS as fixed in 7.0.0-42.42. Ubuntu 22.04 is listed as not affected. So that 6.8.0-147 machine needs the update, and 6.8.0-149 or later is fine.
  • Debian's tracker lists trixie as fixed in 6.12.113-1 (DSA-6568-1) and bookworm's default 6.1 kernel as not affected ("Vulnerable code not present"). Bookworm machines that run the backported linux-6.12 package need 6.12.113-1~deb12u1 (DLA-4850-1).

For vendor kernels on appliances (POS boxes, chargers, head units), ask the vendor directly for their status on CVE-2026-98232, or search their kernel source for the fix commit 3d676e458fe0.

Step 2: Update and reboot

The real fix is a patched kernel. On Debian and Ubuntu:

sudo apt update
sudo apt full-upgrade
sudo reboot
# after the reboot
uname -r

A new kernel package does nothing until the machine boots into it. Check uname -r after the reboot and compare it against the fixed version on your vendor's tracker. On machines that rarely reboot, such as kiosks, the installed kernel and the running kernel can differ for months.

If you run a maintained distribution and reboot after updates, you may already be fine. One HN commenter pointed out that 7.2.8 shipped in September, so anyone updating more often than every couple of months likely has the fix already.

Step 3: If you cannot update yet, remove the USB storage drivers

Drivesec's first mitigation is simple: do not build or auto-load usb-storage and uas where mass storage is not needed. The attack path runs through the storage scan. No storage driver means no scan.

First, find out whether the drivers are modules or built into the kernel:

grep -E 'CONFIG_USB_STORAGE=|CONFIG_USB_UAS=' /boot/config-$(uname -r)

=m means a loadable module, and the steps below work. =y means built in, and modprobe rules cannot remove it. In that case go to Step 4.

For modules, add a modprobe rule:

# /etc/modprobe.d/no-usb-storage.conf
install usb-storage /bin/false
install uas /bin/false

The install line tells modprobe to run a command instead of loading the module. The modprobe.d manual describes it as: "This command instructs modprobe to run your command instead of inserting the module in the kernel as normal." Pointing it at /bin/false turns every load attempt into a no-op. A plain blacklist line is weaker: per the same manual it only makes modprobe ignore the module's internal aliases, which is how automatic loading finds it. Using install also blocks explicit loads and loads pulled in as a dependency.

You can check the rule without touching the running system. Modprobe's -n (dry run) and -v (verbose) flags show what it would do:

$ modprobe -n -v usb-storage
install /bin/false

Then finish the job:

# unload if already loaded (fails if a USB disk is in use)
lsmod | grep -E '^(usb_storage|uas)'
sudo modprobe -r uas usb_storage

# rebuild the initramfs so early boot follows the same rule
sudo update-initramfs -u      # Debian / Ubuntu
sudo dracut -f                # Fedora / RHEL

The trade-off: USB sticks stop working on that machine. For a POS terminal or a charger that never needs a USB stick, that is fine. For a machine that takes firmware updates from a USB stick, it is not. Patch that one.

Step 4: Switch USB to default-deny

The second mitigation from Drivesec is USB allow-listing: USBGuard or authorized_default=0. Both rely on the kernel's USB authorization feature, which the USBGuard project says has been in Linux since 2007. The kernel documentation explains that a USB device is normally configured and made available as soon as it is connected, and that "By default, all USB devices are authorized." A device that is not authorized is not configured, so no driver binds to it and no storage scan runs.

Check the current setting per USB controller:

cat /sys/bus/usb/devices/usb*/authorized_default

1 means every new device is trusted. You can switch to deny at runtime:

for host in /sys/bus/usb/devices/usb*; do
  echo 0 | sudo tee "$host/authorized_default"
done

A runtime change does not cover devices that are plugged in before it runs. To deny from the first moment of boot, set the kernel parameter usbcore.authorized_default=0. The kernel parameters list documents the values: 0 = not authorized, 1 = authorized, 2 = authorized only if connected to an internal port. Value 2 depends on the firmware labelling internal ports correctly (USBGuard's config notes it needs ACPI tables that do this), so test it on your exact hardware. Test any deny setting on a bench unit first: a headless box with an internal USB modem or touchscreen needs an allow rule for those devices, or they stop working too.

Writing sysfs values by hand does not scale, which is what USBGuard is for. It is a daemon that sets the default to deny and authorizes devices from a rule file. Its default configuration ships with AuthorizedDefault=none (every new device starts out deauthorized) and ImplicitPolicyTarget=block. The current release is 1.1.4. The usual start is to generate rules from the devices that are attached right now, review them, then install them:

sudo usbguard generate-policy > rules.conf
# read rules.conf before using it
sudo install -m 0600 -o root -g root rules.conf /etc/usbguard/rules.conf
sudo systemctl enable --now usbguard

One warning matters for this bug. A "mass storage only" USBGuard policy does not stop this attack. The documentation's first example policy is:

allow with-interface equals { 08:*:* }

Class 08 is mass storage. That rule allows any USB stick and blocks everything else, which is a good defense against keyboard-emulating devices. But the usb2shell device is a mass storage device. It passes that rule.

Allowing only specific vendor and product IDs is better, but not a hard wall either. The kernel documentation says it plainly: "Anybody with access to a device gadget kit can fake descriptors and device info. Don't trust that." A board like the Cynthion can present any IDs it likes. USBGuard's via-port attribute helps on fixed hardware, where a known device sits in a known port, but an attacker can unplug that device and use the port.

So for this bug, the honest rule is:

  • The machine never needs USB storage: block class 08 entirely (no allow rule for it), or remove the drivers as in Step 3.
  • The machine needs USB storage sometimes: allow-listing lowers the odds but does not close the hole. Patch the kernel.

Step 5: Stronger isolation, if you need it

Two designs came up in the HN thread. These are commenters' suggestions, not tested advice. A QubesOS user described how Qubes gives USB controllers to a disposable, unprivileged VM, so a kernel bug in USB handling hits that VM instead of the main system. Another commenter pointed to usbsas, a "tool and framework for securely reading untrusted USB mass storage devices" that works in user space. Keep in mind that usb2shell fires during the kernel's device scan, before any mount. A user-space reader only helps if the kernel storage drivers never touch the untrusted device.

The short checklist

  • List every Linux device with a USB port that people outside your team can reach.
  • Run the usb2shell checker on each, and save the exit codes.
  • For each "vulnerable" result, look up the exact package version on the vendor tracker (Debian, Ubuntu, or the appliance vendor).
  • Update the kernel and reboot. Confirm with uname -r.
  • Where the update has to wait and USB storage is not needed, add the install ... /bin/false rules and rebuild the initramfs.
  • Where the drivers are built in, set usbcore.authorized_default=0 and use USBGuard with an allow list for the internal devices only.
  • Do not treat a "mass storage only" USBGuard rule as protection against this bug.

Sources

Which Linux box in your setup has a USB port that anyone walking past could reach, and when did it last boot a new kernel?

📰 Read the original article on Dev.to Security

Originally published by Dev.to Security. Aggregated on AIWithGhost for educational purposes — full credit and traffic to the original publisher.