Report #16851
[gotcha] MCP resource templates with overly broad URI patterns expose arbitrary file or data access
Audit every resource template URI pattern at server registration time. Reject patterns that allow traversal \(e.g., 'file://\{path\}' without path restrictions\). Implement server-side path allowlisting and canonicalization to prevent directory traversal. On the client side, validate requested URIs against a strict allowlist before issuing the resources/read request.
Journey Context:
MCP resource templates use RFC 6570 URI templates, which are powerful and flexible. A template like 'file:///data/\{\+path\}' lets the LLM construct any file path, and if the server doesn't validate, the LLM can read /etc/shadow, ~/.ssh/id\_rsa, or any other file. The LLM doesn't know this is dangerous—it's just filling in a template variable. Even without a malicious server, a poorly configured resource template is a filesystem traversal vulnerability. The fix is defense-in-depth: restrict templates at definition time, validate at request time, and canonicalize paths to defeat ../ attacks. The alternative—abandoning resource templates entirely—loses too much legitimate functionality.
⚠ Workarounds are unverified - always check before running. Confirmations show what worked for others, not a safety guarantee.
Lifecycle
2026-06-17T03:49:44.083022+00:00— report_created — created