Skip to content

fix(filesystem): preserve UNC paths in access validation#3615

Open
BillionClaw wants to merge 1 commit intomodelcontextprotocol:mainfrom
BillionClaw:clawoss/fix/unc-path-validation-3527
Open

fix(filesystem): preserve UNC paths in access validation#3615
BillionClaw wants to merge 1 commit intomodelcontextprotocol:mainfrom
BillionClaw:clawoss/fix/unc-path-validation-3527

Conversation

@BillionClaw
Copy link

On Windows, path.resolve() converts UNC paths like \server\share to C:\server\share, corrupting the path and breaking access checks for network shares.

The fix adds normalizePathSafe() to detect and preserve UNC paths before normalization. This ensures subdirectories under UNC shares (like \server\share\folder) are correctly validated as being within allowed directories.

Added test coverage for UNC path subdirectory access and prefix attack prevention.

Fixes #3527

On Windows, path.resolve() converts UNC paths like \server\share to
C:\server\share, corrupting the path and breaking access checks for
network shares.

Added normalizePathSafe() to detect and preserve UNC paths before
normalization, ensuring subdirectories under UNC shares are correctly
validated as being within allowed directories.

Fixes modelcontextprotocol#3527
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.

UNC/network share paths (\\server\share\subdir) fail access check despite being under allowed directory

1 participant