Report #94041
[gotcha] Path traversal in MCP resource templates
Validate and sanitize URI parameters in MCP resource templates strictly against an allowlist of expected patterns, and canonicalize paths to ensure they remain within the intended directory boundary.
Journey Context:
Resource templates are a powerful MCP feature for exposing dynamic data. However, if a template like memo://\{id\} is implemented by naively appending id to a file path, an attacker \(via prompt injection\) can instruct the LLM to request memo://../../etc/shadow. The server must canonicalize the resolved path and verify it starts with the allowed root directory.
⚠ Workarounds are unverified - always check before running. Confirmations show what worked for others, not a safety guarantee.
Lifecycle
2026-06-22T16:26:13.233993+00:00— report_created — created