Path Traversal Arbitrary File Read in azer/react-analyzer-mcp
Summary
I found a path traversal issue in azer/react-analyzer-mcp.
The MCP tool analyze-project accepts a caller-controlled projectName. In src/index.ts, that value is used directly in:
path.join(PROJECT_ROOT, subFolder)
to construct the scan root for the project. No normalization or containment check ensures that the resolved path remains inside PROJECT_ROOT.
The resulting path is then recursively traversed, and discovered .jsx / .tsx files are read using fs.readFileSync(filePath, "utf8").
Affected Version
Relevant Code Paths
src/index.ts
listReactFiles(subFolder)
- recursive
scanDirectory(directory)
analyzeReactFileContents(filePath)
generateProjectDocs(projectName)
- MCP tool handler for
analyze-project
Impact
A malicious MCP client can escape the intended project root and cause the process to enumerate and read arbitrary React source files (.jsx / .tsx) from attacker-selected directories on the host.
Recommended Fix
- Treat
projectName as an identifier, not a path fragment
- Reject traversal sequences and absolute paths
- Canonicalize the final resolved path and verify it stays under the configured project root before traversal starts
I have a local reproduction and will add it in a follow-up comment with output and screenshot.
Path Traversal Arbitrary File Read in azer/react-analyzer-mcp
Summary
I found a path traversal issue in
azer/react-analyzer-mcp.The MCP tool
analyze-projectaccepts a caller-controlledprojectName. Insrc/index.ts, that value is used directly in:to construct the scan root for the project. No normalization or containment check ensures that the resolved path remains inside
PROJECT_ROOT.The resulting path is then recursively traversed, and discovered
.jsx/.tsxfiles are read usingfs.readFileSync(filePath, "utf8").Affected Version
react-analyzer-mcp0.1.0Relevant Code Paths
src/index.tslistReactFiles(subFolder)scanDirectory(directory)analyzeReactFileContents(filePath)generateProjectDocs(projectName)analyze-projectImpact
A malicious MCP client can escape the intended project root and cause the process to enumerate and read arbitrary React source files (
.jsx/.tsx) from attacker-selected directories on the host.Recommended Fix
projectNameas an identifier, not a path fragmentI have a local reproduction and will add it in a follow-up comment with output and screenshot.