/

CVE-2025-67366

Severity:

HIGH RISK

(7.5)

Path Traversal in @sylphxltd/filesystem-mcp read_content

CVE-2025-67366

Analyzed

Vulnerability type

Category:

Path Traversal

CWE:

CWE-23

Impact:

Unauthorized File Read / Directory Traversal

Severity:

HIGH RISK

(7.5)

CVSS version:

3.1

Catch this CVE while code is being written

Detect vulnerable code directly in pull requests, so CVEs are fixed before merge.

Summary

A path traversal vulnerability in the read_content tool of @sylphxltd/filesystem-mcp v0.5.8 allows attackers to bypass directory restrictions by abusing symbolic links inside otherwise permitted directories.

Because path validation occurs before symlink resolution, while file reads follow symlinks, an attacker who can influence filesystem layout can access files outside the intended operational scope.

Affected context

This vulnerability affects environments where @sylphxltd/filesystem-mcp v0.5.8 is used to provide controlled file-reading capabilities under a specified base directory.

It manifests when:

  • The server trusts a root or base directory constraint for access control
  • Users or other components can create or influence files and symlinks within that directory
  • The read_content tool relies on a pre-access path validation step that does not account for symlink resolution

In such setups, the protection boundary built around the "allowed directory" can be silently bypassed by symlinks pointing elsewhere on the filesystem.

Exploit preconditions

  • Attack surface: The read_content tool endpoint or interface exposed by the filesystem MCP server.
  • Required access: Ability to invoke read_content with controllable paths inside the allowed directory; practical exploitation is easier if the attacker can create or modify files or symlinks within that directory.
  • Trigger point: Supplying a path that appears valid during initial path checks but includes or targets a symlink that ultimately resolves outside the allowed directory when fs.readFile is executed.
  • Why exploitation is possible: The resolvePath function validates the requested path before symlinks are resolved, while the underlying filesystem operations automatically follow symlinks at read time, breaking the assumption that "validated paths" remain confined to the approved directory tree.

Why this happens

The core issue is a mismatch between logical path validation and actual filesystem resolution semantics.

The resolvePath function enforces a directory boundary check on the raw or partially normalized path but does so without resolving symbolic links.

When fs.readFile is later called, the operating system transparently follows any symlinks, potentially leading to a final path outside the intended base directory.

This pattern maps to CWE-23: Relative Path Traversal, where user-influenced paths (including symlink chains) are insufficiently constrained, allowing traversal outside an intended directory sandbox.

Conceptually, the bug is a trust error in path normalization logic: the application assumes that a pre-validated path remains within a safe area, while the actual filesystem behavior can redirect access through symlinks.

Potential impact

  • Unauthorized reading of sensitive files outside the configured base directory (e.g., configuration files, secrets, logs).
  • Exposure of system-level information that can aid further attacks (user data, environment details, application internals).
  • Bypass of logical sandbox or tenant-isolation boundaries implemented via directory restrictions.
  • Potential privacy or compliance violations if protected data becomes accessible through the MCP interface.

General mitigation guidance

Effective mitigation focuses on aligning path validation with actual filesystem resolution and treating all user-influenced paths as untrusted:

  • Resolve symlinks before enforcing directory constraints by using canonical/real paths (e.g., realpath-like behavior) for validations.
  • Enforce that the fully resolved path is still a descendant of the configured base directory, rejecting any request that escapes this root.
  • Consider disallowing or restricting symlink usage within the allowed directory when it is used as a security boundary.
  • Treat the filesystem sandbox as a privilege boundary and apply least-privilege principles to what the MCP server user account can read at the OS level.
  • Centralize path handling logic in a small, well-reviewed utility instead of scattering path checks across the codebase, ensuring consistent, secure-by-default behavior.

How teams detect issues like this

Organizations can identify this class of issue by:

  • Static analysis and code scanning:
  • Flagging custom path-validation helpers that do not incorporate symlink resolution.
  • Searching for combinations of manual path checks (string prefix checks, naive joins) followed by filesystem APIs that automatically resolve symlinks.
  • Code review practices:
  • Reviewing any code that implements "allowed directory" or sandbox constraints around file operations.
  • Verifying that path validation uses canonical paths and that post-resolution paths are checked against the base directory.
  • Treating the presence of symlink handling logic (or lack thereof) as a red flag around security-sensitive file access.
  • Policy and tooling:
  • Enforcing secure path-handling patterns through internal libraries and linting rules.
  • Using automated review tools or SAST engines configured with rules for directory traversal and symlink misuse.

Sources

SourceLink
github.comgithub.com/sylphxltd/filesystem-mcp
github.comgithub.com/sylphxltd/filesystem-mcp/issues/134

Frequently asked

questions

Yes, if the filesystem MCP server is exposed to remote clients or integrated into a system where untrusted or semi-trusted users can invoke the read_content tool and control the path arguments, they can potentially read files outside the intended directory.

The attacker needs the ability to call read_content with controllable paths inside the configured allowed directory. Exploitation becomes straightforward if they can also create or manage symlinks in that directory; in some deployments, that may be possible through normal application workflows or other write mechanisms.

Use canonical path resolution before access, and only proceed with file reads when the fully resolved path remains under the designated base directory. The path-checking logic should be centralized, operate on resolved paths, and be applied consistently to all file operations exposed by the MCP server.

Treat file paths as untrusted input, design directory constraints as formal security boundaries, and adopt hardened path utilities that resolve symlinks, normalize paths, and enforce base-directory checks. Combine this with defensive OS-level permissions, security-focused code reviews for filesystem logic, and automated checks that flag custom or ad-hoc path handling.

Find out what's already
exploitable in your codebase.