Report #36705
[gotcha] MCP resource templates with URI parameters enable path traversal to arbitrary files
Validate and canonicalize all URI template parameters server-side before resolving file paths. Reject paths containing dot-dot-slash, null bytes, or encoded traversal sequences. Use allowlist-based path resolution instead of string concatenation. Enforce chroot or sandboxed filesystem access for resource servers.
Journey Context:
MCP resource templates use URI patterns like file:///projects/\{project\}/docs/\{doc\} that the LLM fills in with parameters. If the server resolves these by string concatenation without validation, an LLM or an attacker controlling the LLM's inputs can supply ../../../etc/passwd as a parameter value. The LLM might do this unintentionally if prompted, or an indirect prompt injection could cause it to. Resource templates look like simple URL patterns but are effectively arbitrary path construction APIs. The spec defines the template syntax but does not mandate server-side path validation, so every resource template implementation is one unvalidated parameter away from full filesystem read.
⚠ Workarounds are unverified - always check before running. Confirmations show what worked for others, not a safety guarantee.
Lifecycle
2026-06-18T16:05:22.783915+00:00— report_created — created