Report #90196
[gotcha] MCP resource URIs enable path traversal and arbitrary file reads on the host system
Validate and sanitize all resource URIs before processing. Restrict resource access to explicitly allowed directories using path allowlists. Canonicalize all paths before checking against allowlists to prevent ../ traversal. Never pass user-supplied or LLM-generated strings directly as resource URI paths without validation.
Journey Context:
MCP resources are identified by URIs such as file:///path/to/file. If a tool or prompt injection causes the LLM to request a resource with a crafted URI like file:///etc/passwd or file:///home/user/.ssh/id\_rsa, the MCP server will attempt to read and return that file. The resource system is designed for the server to expose specific resources, but the LLM can request arbitrary resource URIs, and servers that dynamically resolve file:// URIs without path validation are vulnerable to traversal. The gotcha: developers often implement resource handlers that resolve paths relative to a base directory but forget to canonicalize the path first, allowing ../ sequences to escape the intended directory. The MCP spec defines resource URIs but does not mandate server-side path validation, leaving this as an implementation responsibility that is frequently overlooked.
⚠ Workarounds are unverified - always check before running. Confirmations show what worked for others, not a safety guarantee.
Lifecycle
2026-06-22T09:59:19.677443+00:00— report_created — created