Hacktoberfest 2026:维护者为十月标记出来的 issue,仍然开放、适合新手。 浏览 Hacktoberfest issue

Filesystem symlinks leak external file metadata

未关闭 适合新手
#5,217 0 条评论 0 个 reaction 已指派 0 人 在 GitHub 查看

维护者通常 1 天内回复

还没有人认领这个 Issue。

评估

难度
2/5
预计耗时
1-3 小时
新手友好度
76/100
Issue 类型
缺陷
描述清晰度
描述清楚
活跃度
活跃
领域
backend, security

调研方向

首先找到文件系统服务器中 list_directory_with_sizes 的实现,并检查它如何构建条目路径以及读取元数据。查看目录列表和符号链接的现有测试,然后使用一个包含指向外部文件的链接的允许目录,复现报告中的情况。完成标准是:列表不再泄露目标文件的元数据,并且有测试覆盖此行为。

由索引模型根据 Issue 内容生成。

描述

bug v2
Which server?

filesystem (@modelcontextprotocol/server-filesystem)

Server version

0.6.3

How did you run the server?

Not applicable (a repository-level report)

Transport

stdio

Protocol era

Not sure

MCP client and version

n/a

Steps to reproduce
  1. Start the filesystem server with one allowed directory.
  2. Create a file outside the allowed directory and a symlink to it inside the allowed directory:
tmp="$(mktemp -d)"
mkdir "$tmp/allowed"
printf 'MCP-FILESYSTEM-SYMLINK-METADATA-MARKER\n' > "$tmp/outside-secret.txt"
ln -s "$tmp/outside-secret.txt" "$tmp/allowed/leaks-outside-size"
  1. Call the MCP tool for the allowed directory:
{
  "jsonrpc": "2.0",
  "id": 1,
  "method": "tools/call",
  "params": {
    "name": "list_directory_with_sizes",
    "arguments": {
      "path": "/tmp/example/allowed",
      "sortBy": "name"
    }
  }
}

The vulnerable code validates only args.path, then runs fs.readdir(validPath, { withFileTypes: true }), builds entryPath = path.join(validPath, entry.name), and calls fs.stat(entryPath).

Expected behavior

Directory listings that claim to operate only inside allowed directories should not follow symlink entries to targets outside the allowed tree. The tool should use lstat, or resolve each entry and enforce the same containment check before reading target metadata.

Actual behavior

A local reproduction created an allowed directory containing a symlink to an external file. The directory-entry metadata path followed the symlink:

allowed directory=/tmp/manual_mcp_filesystem_symlink_metadata_ldkba6qc/allowed
outside target=/tmp/manual_mcp_filesystem_symlink_metadata_ldkba6qc/outside-secret.txt
symlink entry=/tmp/manual_mcp_filesystem_symlink_metadata_ldkba6qc/allowed/leaks-outside-size
os.lstat symlink size=71
os.stat followed target size=39
outside target actual size=39
formatted listing=[FILE] leaks-outside-size             39 B

The reported listing size matches the outside target file size, not the symlink entry metadata.

Before you submit
  • I searched existing issues and this is not a duplicate.
  • This is not a security vulnerability report (those go through the private advisory form).
主要语言
TypeScript
星标
91.4k
派生
11.8k
平均合并
7 小时 26 分钟
30 天内合并 PR
130

环境准备

从这里开始

  1. 先读完整个 Issue,再读项目的贡献指南。
  2. 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
  3. Fork 仓库,在一个分支上完成修改。
  4. 提交 Pull Request,并在描述里引用这个 Issue 编号。

modelcontextprotocol/servers 的其他 Issue

查看 modelcontextprotocol/servers 的全部 Issue

相似的 Issue

更多 TypeScript Issue

把新 issue 发到你的邮箱

精选适合新手参与的 GitHub issue 摘要。