Contents

USB2Shell Gets Root on Linux From One USB Plug-In Without a Login

 

Ethical Hacking Complete Course Zero to Expert

Hack like black hat hackers. Penetration testing, Kali Linux, WiFi and web hacking, and the hacker mindset behind it.

→ Take the full course
 
Contents

A USB device plugged into a Linux PC ran its own command as root, without a login. The PC only had to scan it. The bug has been in the kernel since 2023, and that scan has set it off since June 2024.

# TL;DR

When a USB stick goes into a Linux computer, the kernel, the core of the operating system, starts talking to it before anything shows up on the screen. It asks the stick what kind of device it is and what it can do, and it uses the answers to set the stick up. One of those answers could be false in a way the kernel did not check. For more than two years, that was enough for a USB device to run its own command as root, the account with full control over the machine.

The bug is called USB2Shell, and its official name is CVE-2026-98232. The research team at Drivesec, an Italian company that tests cars and connected devices for security holes, found it on August 26. Two days later they had root on a physical PC. On November 30 they put their findings online, with a video of the attack.

In that video, a small USB board goes into a PC with a standard Debian kernel, version 6.12.22+bpo-amd64. The first two tries miss, and the PC keeps running without a crash. On the third try, the PC runs whoami and uname, and both answer as root. The board is a Cynthion, an open tool from Great Scott Gadgets for building and testing USB devices. With its software, it acts as a USB device that you program yourself.

The attack goes off during the check Linux does on a new USB storage device, before the system shows a disk, so there is no login and the drive is never opened.

That is why the researchers point at machines with a USB port that other people can reach:

  • โ†’ infotainment and telematics units in cars
  • โ†’ chargers for electric cars
  • โ†’ payment terminals at a shop counter
  • โ†’ kiosks
  • โ†’ entertainment screens in airplanes
  • โ†’ control panels of industrial machines
  • โ†’ smart-home hubs

Your own Linux laptop, desktop or server can be in the same position. A machine is exposed when it runs a kernel with this bug and without the fix, has the drivers for USB storage built in or loaded automatically, and has a USB port someone can plug a device into. Those drivers are called usb-storage and uas.

Linux 6.5 came out on August 27, 2023. It brought support for a feature in some hard drives that sets a time limit on how long a read or write may take. It is called Command Duration Limits, or CDL, and the kernel’s own documentation says it is off by default. The code that handles it was written in May 2023, and the hole was in it from the start. At first, though, the kernel only ran that code when someone changed the CDL setting by hand, through a settings file. A USB stick going in did not reach it.

That changed in June 2024. A drive can start up with CDL already switched on while the kernel assumes it is off. To keep the two in line, the developer who wrote the CDL code added a call to it in the scan itself, so the kernel sets CDL on the device the moment the device shows up.

The change was meant to keep CDL off by default. From then on, the unchecked code ran each time a device that claims CDL support was plugged in. The developer wrote the change on June 7, 2024, and it reached the 6.6 kernels with 6.6.35 on June 21, 2024. It stayed there until the fixes in September and October 2026.

When a new storage device shows up, Linux asks it a series of questions. If the device says it is an ATA device, the kind of interface ordinary hard drives use, and says it supports CDL, the kernel asks for the page that holds the CDL setting. It does that with a command called MODE SENSE. A programmable USB board can claim both, and answer with whatever its owner wrote into it.

The kernel puts that answer in a small piece of memory, a buffer of 64 bytes. The buffer sits on the kernel stack, the scratch memory a function uses while it runs. Right outside those 64 bytes, the stack holds other kernel data.

The answer starts with a header. In it, the device itself states how long the full answer is and how long an extra block after the header is, called the block descriptor. The kernel decides the size of the header itself. It used those numbers to find the CDL setting inside the buffer, and to decide how many bytes to send back to the device afterwards. It never checked whether they made sense. This is the code from before the fix, as the researchers show it:

1
2
3
4
5
len = min_t(size_t, sizeof(buf),
            data.length - data.header_length -
            data.block_descriptor_length);   /* can wrap -> 64 */
buf_data = buf + data.header_length +
        data.block_descriptor_length;         /* can point past buf */

To work out how many bytes to send back, the kernel takes the total length and subtracts the header and the block descriptor. A device can report a total that is smaller than those two together. These numbers are unsigned, which means they cannot go below zero, so the result wraps around to a very large number instead of a negative one, and a cap in the code brings that back down to 64.

To find the CDL setting, the kernel adds the header and the block descriptor to the start of the buffer. With the right values, that points past the end of the 64 bytes, at a spot the device picks.

The kernel then does two things at that spot. It clears the two lowest bits of the byte that sits there, as part of writing the CDL setting back. Then it sends the page back to the device with a command called MODE SELECT, up to 64 bytes, copied from outside the buffer.

So the USB board gets up to 64 bytes of kernel memory sent to it, and it can change one byte of the kernel’s memory at a place it chooses. All of that happens during the automatic scan.

That leaked memory and that one byte were enough for the researchers to get root. Linux puts its own code at a different random address each time it starts, so an attacker does not know where anything is in memory. That protection is called KASLR. The leaked bytes gave the addresses away. With those, the researchers built fake kernel structures, so that the change to one byte became a write they controlled. When the board is pulled out, the kernel runs a command the board brought with it, as root.

The attack does not hit on the first try each time, which is why the video shows two misses before the hit. A miss does not crash the machine, so the board can simply try again.

The patch itself describes a second proof, in a virtual machine running a test version of Linux 7.3. A simulated USB device set the bug off during the automatic scan. The kernel inside the virtual machine then ran a fixed command and left a file owned by root, with KASLR switched on and NX as well. NX is the protection that stops the processor from running code from memory that is meant for data.

The researchers’ site describes the chain in a few sentences. The exploit code itself is not on it.

Six weeks before the researchers found the bug, it had already come up in public. The Linux developers who maintain the storage code, the SCSI subsystem, discuss their patches on an open mailing list.

On July 17 at 19:10 UTC, a developer from the security company Artiphishell sent in a patch there for the same mistake in another function of the storage code. Thirteen minutes later, an automatic reviewer replied. Sashiko is an open-source review system from the Linux Foundation that uses AI to read the patches sent to the kernel lists. It asked whether scsi_cdl_enable() had the same out-of-bounds problem, and marked the question Critical. That evening, under a second patch from the same developer, it asked again, and added that this code runs automatically when a USB storage device is probed.

Less than two minutes after the first warning, a kernel maintainer replied to the developer’s patch in the same thread. Malicious devices are usually not part of the threat model, he wrote, because checking each action of a device would mean a large drop in performance. USB devices are the exception, because someone could plug one into a laptop, but then you have to show an exploit that works.

The researchers showed exactly that. Their write-up says the AI reviewer reported the bug first, and that their own team found it independently, wrote the fix and built the exploit. They reported it privately to the storage maintainers on September 2 and sent in the patch themselves two days later. It went into the kernel on September 9, with the reviewer listed as the reporter and a link to the maintainer’s mail from July 17.

Ubuntu scores the bug 5.4 out of 10, which counts as Medium. The score stays low because the attacker has to stand at the USB port in person. Once the board is in, it runs a command as root without a login. That physical access is the same exception the maintainer described in July.

Android phones run a Linux kernel too. On Android kernels from 6.6 on, the board still gets the stack memory back, but the write does not get through. The Android builds the researchers checked, the general Android kernel and the kernel Samsung ships on the Galaxy A16, are compiled with bounds checks that keep it inside the buffer. On those phones the bug stays a leak.

The fix makes the kernel check the device’s lengths before it uses them. This is part of the new code:

1
2
3
avail = min_t(size_t, data.length, sizeof(buf));
if (data.header_length > avail)
        return -EINVAL;

If the answer is shorter than its own header, the kernel stops and leaves the buffer alone. It does the same when the block descriptor does not fit, and it wants at least five bytes left for the CDL setting.

That fix covers scsi_cdl_enable() and nothing else. On July 17 the reviewer had also pointed at two more functions in the storage code that use the device’s lengths without checking them. cache_type_store() runs when someone writes to the cache setting of a disk, and it is the function the July 17 patch was meant to fix. That patch never went in.

sd_read_io_hints() runs on its own while Linux sets up a new disk, and there the risk is reading past the end of a 512-byte buffer. In the main kernel tree on December 1, both still calculate with the lengths the device reports, without a check.

The fixed kernel releases are 6.18.54 and 7.2.8 from September 25, 6.6.158 and 6.12.112 from October 3, and 7.3. The CVE was published on October 6. The name and the details followed on November 30, on a site of their own.

Distributions often carry a fix back into their own kernel without changing the version number, so the distribution’s own page for this CVE tells you more than the number does. On Debian 12, the standard kernel, 6.1, is not affected, but the newer 6.12 kernel for Debian 12 was affected and has the fix from 6.12.113-1~deb12u1. Debian 13 has the fix from 6.12.113. Ubuntu 24.04 has it from 6.8.0-149 and Ubuntu 26.04 from 7.0.0-42. Ubuntu 22.04 is not affected unless it runs the newer 6.8 kernel, which got the same fix.

What you can do on your own Linux machine:

  • โ†’ Check the kernel version with uname -r, or run the researchers’ checker after reading it:
1
2
3
curl -fsSLO https://usb2shell.com/tools/usb2shell-check.sh
less usb2shell-check.sh
sh usb2shell-check.sh

The checker compares the version number, looks for the USB storage drivers and shows the authorized_default setting. A distribution kernel with the fix carried back can still come out as vulnerable there. Ubuntu 24.04 with 6.8.0-149 is one example.

  • โ†’ Update to a fixed kernel
  • โ†’ If that cannot happen yet, keep usb-storage and uas from loading on machines that do not need USB storage
  • โ†’ Or let only approved USB devices through, with USBGuard or by setting authorized_default to 0, so the kernel does not scan an unknown device at all

A few commands in your own Linux terminal show which USB devices your machine has seen and which drivers it loaded for them.

My Ethical Hacking Complete Course Zero to Expert takes you there step by step: reconnaissance, scanning, exploitation and traffic analysis, hands-on, from your first day with no Linux or hacking background.

โ†’ Join my complete ethical hacking course

Hacking is not a hobby but a way of life.

Sources:

USB2Shell write-up by Drivesec | CVE-2026-98232 | scsi: core: Disable CDL by default

 
NEWSLETTER

Stay updated

Get the latest posts in your inbox every week. Ethical hacking, security news, tutorials, and everything that catches my attention. If that sounds useful, drop your email below.

By Bulls Eye

Jolanda de koff โ€ข email โ€ข donate

My name is Jolanda de Koff and on the internet, I'm also known as Bulls Eye. Ethical Hacker, Penetration tester, Researcher, Programmer, Self Learner, and forever n00b. Not necessarily in that order. Like to make my own hacking tools and I sometimes share them with you. "You can create art & beauty with a computer and Hacking is not a hobby but a way of life ...

I โ™ฅ open-source and Linux