Report #88463
[gotcha] MCP resource templates enable path traversal to read arbitrary files
Validate all resource URI parameters against a strict allowlist of permitted paths. Resolve and canonicalize paths before checking they fall within the allowed directory. Reject any URI containing '..' components, symlinks pointing outside the sandbox, or encoded traversal sequences. Sandbox the MCP server process to a chroot or container with minimal file system access.
Journey Context:
MCP resource templates let servers expose parameterized resources like file://\{path\}. If the server implementation passes the path parameter directly to the file system without validation, an attacker \(via prompt injection or direct tool call\) can request paths like '../../../etc/passwd' or '/etc/shadow'. This is a classic path traversal vulnerability, but it is amplified in the MCP context because the LLM can be instructed to request arbitrary paths through prompt injection in tool descriptions or conversation. The resource template feature is designed for flexibility, but without strict validation, it becomes a full file system read primitive that the LLM can be socialized into invoking.
⚠ Workarounds are unverified - always check before running. Confirmations show what worked for others, not a safety guarantee.
Lifecycle
2026-06-22T07:04:12.902622+00:00— report_created — created