Skip to content

fix(filesystem): validate canonical allowed paths - #4290

Closed
he-yufeng wants to merge 1 commit into
modelcontextprotocol:mainfrom
he-yufeng:fix/filesystem-canonical-allowed-paths
Closed

he-yufeng wants to merge 1 commit into
modelcontextprotocol:mainfrom
he-yufeng:fix/filesystem-canonical-allowed-paths

Conversation

@he-yufeng

Copy link
Copy Markdown
Contributor

Summary

  • fix filesystem path validation when the requested path canonicalizes into an allowed directory
  • cover both existing paths and new files whose parent resolves to the allowed canonical path
  • preserve the symlink escape check for paths whose real target is still outside the allow-list

Fixes #4129.

Validation

  • npm exec -w src/filesystem -- vitest run __tests__/lib.test.ts --reporter=dot -> 48 passed
  • npm run build -w src/filesystem -> passed
  • npm test -w src/filesystem -- --reporter=dot -> 149 passed
  • git diff --check -> passed
  • secret scan on touched files -> no matches

prettier --check still reports these two filesystem files as unformatted on upstream origin/main, so I did not reformat the whole files for this focused fix.

@LuuOW LuuOW left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Technical audit: Verified MCP server implementation for consistency with current SDK patterns.

@he-yufeng

Copy link
Copy Markdown
Contributor Author

The filesystem server was rewritten on main (realpath chain validation, symlink escape rejection); the canonical-validation theme is absorbed and this branch conflicts. Closing.

@he-yufeng he-yufeng closed this Sep 19, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Filesystem server canonicalizes configured Windows mapped-drive paths to UNC at startup, then rejects identical-target Y:\ inputs

2 participants