Skip to content

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

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

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

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