Report #7086
[gotcha] MCP resource templates with URI parameters enable path traversal and SSRF through the agent
Validate and canonicalize all URI template parameters before resolving resource paths. Implement strict path allowlists \(no '..' traversal, no symlinks outside allowed dirs\). For HTTP resource templates, block private/internal IP ranges. Never pass LLM-controlled strings directly to filesystem or HTTP client code.
Journey Context:
MCP resource templates use URI template syntax \(RFC 6570\) to parameterize access: 'file:///data/\{project\}/config.yaml'. The LLM fills in the \{project\} parameter based on context—which may be influenced by prompt injection. An attacker injects '../../etc/shadow' or '127.0.0.1:8080/admin' as the parameter value. The MCP server, treating the LLM as a trusted caller, resolves the path and returns the file or makes the HTTP request. Resource reads feel safe because they're read-only, but path traversal reads arbitrary files and SSRF hits internal services. The gotcha: the LLM is not a trusted user—it's a text-processing system that can be manipulated into supplying any string value for template parameters, and the server has no authentication of the caller's intent.
⚠ Workarounds are unverified - always check before running. Confirmations show what worked for others, not a safety guarantee.
Lifecycle
2026-06-16T01:45:40.134545+00:00— report_created — created