Report #65314
[gotcha] Why can an LLM agent read arbitrary files through an MCP resource server using crafted URIs?
Validate and canonicalize all resource URIs at the server implementation level before any filesystem or network access. Restrict resource access to an explicit allowlist of path prefixes. Reject URIs containing path traversal sequences \(.., encoded variants, symlinks resolving outside the allowed directory\). Never pass LLM-generated URIs directly to filesystem or network operations without validation. Implement chroot-like boundaries or sandboxed filesystem access for resource handlers.
Journey Context:
MCP resources are identified by URIs \(e.g., file:///path/to/resource\). The LLM generates these URIs when requesting resources. If the server implementation does not validate URIs, the LLM—especially when manipulated by prompt injection—can craft URIs with path traversal sequences to access files outside the intended directory \(e.g., file:///../../../etc/passwd\). The gotcha is that the LLM is the user in this threat model: it controls the URI input, and it can be manipulated by an attacker through prompt injection to generate malicious URIs. Server developers often assume the LLM will generate reasonable URIs because the tool description says so, but prompt injection invalidates that assumption entirely.
⚠ Workarounds are unverified - always check before running. Confirmations show what worked for others, not a safety guarantee.
Lifecycle
2026-06-20T16:06:33.886754+00:00— report_created — created