Arbitrary Local File Read and Write in claude-faf-mcp
The claude-faf-mcp MCP server exposes arbitrary file read and write primitives through unconfined path parameters, allowing LLM-based prompt injection to access sensitive local files or modify system files.
The claude-faf-mcp package (versions 5.7.1 and earlier) contains a critical path traversal vulnerability in its Model Context Protocol (MCP) tools. The server process fails to confine user-supplied path arguments to a trusted project directory, instead resolving paths directly into the local filesystem. By providing absolute paths or directory traversal sequences like ../, an attacker or a prompt-injected LLM can bypass intended project restrictions to read or write files anywhere the server process has operating system permissions. This vulnerability, identified during a security audit, permits unauthorized access to sensitive local credentials, including SSH keys, cloud configuration files (e.g., ~/.aws/credentials), and .env files. The issue was remediated in version 5.7.2 by implementing strict path canonicalization and directory confinement guards in safe-path.ts.
Attack Chain
- An attacker influences an LLM agent to interact with the
claude-faf-mcpserver by hosting malicious content in a project file, ticket, or web page. - The LLM agent receives the content, triggering a malicious tool call to
faf_readorfaf_writevia the MCP interface. - The attacker-controlled tool call includes a crafted
pathargument, such as/home/user/.ssh/id_rsaor../../../../etc/passwd. - The server's
getProjectPath()function receives the path and processes it usingpath.resolve()without checking against a restricted project root. - The server executes the filesystem operation on the target path, as it assumes the request is within the legitimate
.fafproject context. - For
faf_read, the server returns the contents of the unauthorized sensitive file to the LLM agent, where the attacker can then exfiltrate it. - For
faf_write, the server overwrites or creates arbitrary files on the local disk using the permissions of the user running the MCP server.
Impact
Successful exploitation results in arbitrary local file disclosure and unauthorized file modification. An attacker can access critical secrets, API keys, and environment variables stored on the host system. Furthermore, the ability to write files allows for potential persistence or lateral movement by overwriting configuration files or adding malicious scripts to accessible directories. The impact affects any developer or system running a vulnerable version of claude-faf-mcp in an environment where the agent processes untrusted, attacker-controlled data.
Recommendation
- Upgrade
claude-faf-mcpto version 5.7.2 or later immediately to apply the path confinement logic insafe-path.ts. - If upgrading is delayed, configure the
FAF_ALLOWED_ROOTSenvironment variable to restrict the server to a single, hardened project directory. - Audit logs for unauthorized tool execution patterns or suspicious file paths (e.g., directory traversal strings
../or common secret paths) passed to the MCP server. - Ensure the MCP server process runs with the least privilege necessary, avoiding execution as a root or high-privilege user to minimize the impact of file system writes.
Immediate actions
Upgrade claude-faf-mcp to 5.7.2
Mitigations
Set FAF_ALLOWED_ROOTS to a restricted project directory
claude-faf-mcp (<= 5.7.1)