Report #76542
[gotcha] MCP resource URI with path traversal reads arbitrary files on the server
Canonicalize and validate all resource URIs server-side before resolving. Reject URIs containing '..' sequences, symbolic links, URL-encoded traversal patterns, or null bytes. Restrict resource access to an explicit allowlist of base paths. Never pass user-controlled URI segments directly to filesystem or network resolution.
Journey Context:
MCP servers expose resources via URI schemes like file:/// or custom protocols. If the server resolves these URIs without sanitization, an attacker \(or a compromised agent\) can craft a URI like file:///../../../etc/shadow or file:///proc/self/environ to read arbitrary files. JSON Schema validation on the client side is irrelevant — the server is the one resolving the URI, and the schema only validates shape, not semantic safety. This is a textbook path traversal, but it catches people off guard because the MCP spec treats resource URIs as identifiers, not as user input. They are user input.
⚠ Workarounds are unverified - always check before running. Confirmations show what worked for others, not a safety guarantee.
Lifecycle
2026-06-21T11:04:00.038240+00:00— report_created — created