All filesystem access tools (ctx_read, ctx_search, ctx_edit) must strictly validate and sanitize file paths to ensure that all operations are confined within the designated project_root directory. Reject any path containing traversal sequences (e.g., '../') or absolute paths, and resolve all paths before access to enforce this boundary.
Rationale
These tools expose file system operations to untrusted input via HTTP and MCP. Without strict path validation, attackers can exploit path traversal to access sensitive files.
Consideration
Failure to implement this requirement could allow attackers to read or modify arbitrary files outside the project directory, leading to data breaches, credential exposure, or system compromise.
No path traversal protection found. read_file_lossy in rust/src/tools/ctx_read.rs accepts arbitrary path strings (only enforces a max-bytes cap via LCTX_MAX_READ_BYTES). detect_project_root(path) is called only to discover where caches/graphs live — not to confine reads. Absolute paths and ../ traversal are not rejected; canonicalization + starts_with(project_root) is not performed. Same applies to ctx_search and ctx_edit. Risk: an attacker (or a prompt-injected AI agent) calling /v1/tools/call with ctx_read({"path": "/etc/passwd"}) or "../../../.ssh/id_rsa" will succeed if not blocked at MCP transport. Mitigating factor: the HTTP server is loopback+bearer by default, so practical exploitation requires an already-present MCP/HTTP client. Still, design should fail-closed.