←新闻详情

Johann Rehberger / Embrace The Red更新于 10月14日 12:43

Anthropic Filesystem MCP Server 存在目录访问绕过漏洞

Anthropic Filesystem MCP Server: Directory Access Bypass via Improper Path Validation · Embrace The Red

AI 导读

Anthropic 的 Filesystem MCP Server 因 validatePath 函数仅用 .startsWith 校验路径、未强制路径为目录,导致允许 /mnt/finance/data 时 Claude 也能访问 data-archived 等同前缀目录。作者于 2025 年 6 月 1 日报告该漏洞,Anthropic 在支持 MCP roots 功能的重写版本中已修复。

正文

当前显示原文,中文全文译文尚未就绪。

A few months ago I was looking at the filesystem MCP server from Anthropic.

The server allows to give an AI, like Claude Desktop, access to the local filesystem to read files or edit them and so forth.

I was curious about access control and in the documentation there is a configuration setting to set allowedDirectories, which the AI should be allowed access to:

As you can see the example shows two folders being allowlisted for access.

Since the source code is public, I decided to review it quickly. That’s when I noticed the following vulnerability in the path validation, where it does a .startsWith comparison in the validatePath function of index.ts.

At no point is it enforced that the path is a directory, it only checks that it starts with one of the allowlisted path strings.

This is the code:

This means that if there are sibling directories or files that start with the same name, Claude has access to them.

For instance, consider a folder structure like this:

Now imagine a user wants to give Claude access to only the /mnt/finance/data directory, nothing else.

If a user follows the instructions in the README.md and adds that path /mnt/finance/data to the allowed directories list, then Claude also has access to the data-archived folder, and any other file starting with /mnt/finance/data.

Video Walkthrough

Responsible Disclosure and Fix

I reported this vulnerability to Anthropic on June 1, 2025 and the team highlighted that they are already tracking the issue.

Recently, after the Claude Desktop Extensions came out, I noticed that Anthropic had rewritten large parts of the filesystem server to support the roots feature of MCP. That rewrite and updated release also fixed this vulnerability.

Shout out to Elad Beber, who also had identified this vulnerability, and reported it to Anthropic first.

Conclusion

This bug highlighted an interesting vulnerability that I consider a typical classical security issue. In the beginning of my career, I worked on filesystem drivers at Microsoft (WinFS and SQL Server), and back then I learned that file system security is actually quite difficult to get right.

My main take-away is that AI system at large, but especially MCP servers, often suffer from “classic” vulnerability types that we sometimes haven’t seen in a long time.

References

Newer →; Contact me; ← Older

来源

Johann Rehberger / Embrace The Red