Skip to content

fix(filesystem): handle UNC share root allowlists#4219

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

fix(filesystem): handle UNC share root allowlists#4219
he-yufeng wants to merge 1 commit into
modelcontextprotocol:mainfrom
he-yufeng:fix/filesystem-root-allowed-path

Conversation

@he-yufeng
Copy link
Copy Markdown

Fixes #3756.

UNC share roots keep a trailing separator after Windows path normalization. The allow-list check then appended another separator before the prefix comparison, so a file under \\server\share\ was compared against \\server\share\\ and rejected.

This keeps the existing equality check and only adds a separator when the normalized allowed directory does not already end with one.

To verify

  • npm exec -w src/filesystem -- vitest run tests/path-validation.test.ts --testNamePattern "UNC paths"
  • npm exec -w src/filesystem -- vitest run tests/path-validation.test.ts
  • npm run build -w src/filesystem
  • git diff --check

@he-yufeng
Copy link
Copy Markdown
Author

Closing this older branch in favor of #4265, which keeps the UNC share-root fix and also covers the mapped-drive-to-UNC allow-list case from #4129. Keeping one PR should make review easier.

@he-yufeng he-yufeng closed this May 30, 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.

isPathWithinAllowedDirectories fails for UNC paths on Windows (network drives)

1 participant