Skip to content

Path Traversal Arbitrary File Read Vulnerability in azer/react-analyzer-mcp #3

Description

@gongyanyugyy

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

  • react-analyzer-mcp 0.1.0

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions