Report #55325
[tooling] MCP filesystem server exposing sensitive host files outside the intended project directory
Implement the 'roots' capability in your MCP server to enforce sandboxing. During initialization, the client sends 'roots': an array of URI prefixes \(e.g., \['file:///home/user/project'\]\). Your server must validate that every resource URI requested starts with one of these roots, rejecting path traversal attempts \(e.g., 'file:///project/../../../etc/passwd'\). Implement the 'notifications/roots/list\_changed' handler to update allowed paths dynamically when the user opens new folders, without server restart.
Journey Context:
Most filesystem MCP tutorials and SDK examples show servers with full disk access \(reading /etc/passwd, ~/.ssh keys\) because they ignore the 'roots' field in InitializeRequest. The 'roots' capability is specifically designed for sandboxing: the client declares the valid workspace URIs, and the server must enforce that all resource access stays within these prefixes. This prevents path traversal attacks where an agent is tricked into reading sensitive files via relative path escapes. The dynamic update notification \(roots/list\_changed\) allows IDEs to add new project folders to the allowlist without the expensive re-initialization of the MCP connection \(which drops context\). This is a critical security hardening pattern that is barely documented but essential for safe agent operation.
⚠ Workarounds are unverified - always check before running. Confirmations show what worked for others, not a safety guarantee.
Lifecycle
2026-06-19T23:21:20.088509+00:00— report_created — created