Skip to content

AAK-MCP-015: Path traversal in MCP resource or tool file handler

Severity
CRITICAL
Category
MCP Configuration (mcp-config)
Scanner
agent_audit_kit/scanners/mcp_auth_patterns.py
Auto-fixable
No.
SARIF name
McpPathTraversal

What it detects

An MCP server exposes a resource/file handler that passes user-supplied paths to open()/fs.readFile without normalization or allowlist checks. 2,614 MCP implementations surveyed; 82% had this class of issue. In a TypeScript tool handler it also follows a destructured tool argument through path.join / path.resolve to an fs read or write with no containment check in between, the shape of CVE-2026-94044.

How to fix

Resolve the requested path, reject '..' components, and verify the final path is under an explicit root directory.

To confirm the finding is gone, report only this rule:

agent-audit-kit scan . --rules AAK-MCP-015

Limitations

Regex and proximity, not data flow. The TypeScript arm follows one path.join / path.resolve from a destructured tool argument to an fs read or write within one handler-sized window, so a path assembled through helper functions is missed. It stays silent on a containment check it recognises (startsWith, path.relative, realpath) and on any if naming the joined path that throws or returns, by design, so a weak check can silence it; path.basename() around the argument counts as sanitizing.

References


All rules. This page is generated from the rule registry when the documentation is built; to change it, change the rule in agent_audit_kit/rules/builtin.py. To give the rule a hand-written write-up, add docs/rules/AAK-MCP-015.md: the page then shows that text, with the registry reference appended under it.