Skip to content
MCP Reference Servers·Indexed by this site · Originally published· Event →SelectedAttention43

list_directory_with_sizes in @modelcontextprotocol/server-filesystem follows symbolic links and leaks the sizes of files outside the directory

@modelcontextprotocol/server-filesystem list_directory_with_sizes follows symlinks and leaks outside-directory file metadata

AI summary

A GitHub security advisory disclosed that list_directory_with_sizes in @modelcontextprotocol/server-filesystem validates only the requested directory path, and then, when calling fs.stat() for each sub-item, does not validate the sub-path again; fs.stat() follows symbolic links, thereby leaking the sizes of files outside the allowed directory. Affected versions are 2025.7.1 through 2026.8.31, and 1.0.0 through before 2.0.1; 2.0.1 has fixed it. In the reproduction, a 1536-byte file outside the directory was shown as 1.50 KB through a symbolic link inside the allowed directory, while read_text_file directly reading that link was still rejected. The prerequisite is that an attacker can place a symbolic link inside the allowed directory and have the Agent call the tool, either directly or with the aid of prompt injection.

Why it was selected

The advisory provides a reproducible symlink test and a specific fix, which teams maintaining MCP file system services can use to check their directory listing logic.

Read originalgithub.com