{"record":{"id":"dd6bc7531e5da2dc","repo":"modelcontextprotocol/servers","slug":"access-denied-windows-style-path-received-on-a-p","errorCode":null,"errorMessage":"Access denied - Windows-style path received on a POSIX host: ${requestedPath}","messagePattern":"Access denied - Windows-style path received on a POSIX host: (.+?)","errorType":"exception","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"src/filesystem/lib.ts","lineNumber":146,"sourceCode":"      return path.join(currentPath, ...relativeParts.slice(index));\n    }\n\n    currentPath = await fs.realpath(path.join(currentPath, equivalentMatches[0]));\n    if (!isPathWithinAllowedDirectories(normalizePath(currentPath), allowedDirectories)) {\n      throw new Error(`Access denied - symlink target outside allowed directories: ${currentPath} not in ${allowedDirectories.join(', ')}`);\n    }\n  }\n\n  return currentPath;\n}\n\nexport async function validatePath(requestedPath: string): Promise<string> {\n  const expandedPath = expandHome(requestedPath);\n  // Do not silently reinterpret a Windows drive path as a relative POSIX path.\n  // This would create a literal filename such as `C:\\\\Users\\\\...` inside the\n  // allowed root and report success for the wrong location.\n  if (process.platform !== 'win32' && /^(?:[A-Za-z]:)(?:[\\\\/]|$)/.test(expandedPath)) {\n    throw new Error(`Access denied - Windows-style path received on a POSIX host: ${requestedPath}`);\n  }\n  const absolute = path.isAbsolute(expandedPath)\n    ? path.resolve(expandedPath)\n    : resolveRelativePathAgainstAllowedDirectories(expandedPath);\n\n  const normalizedRequested = normalizePath(absolute);\n\n  // Security: Check if path is within allowed directories before any file operations\n  const isAllowed = isPathWithinAllowedDirectories(normalizedRequested, allowedDirectories);\n  if (!isAllowed) {\n    throw new Error(`Access denied - path outside allowed directories: ${absolute} not in ${allowedDirectories.join(', ')}`);\n  }\n\n  // Security: Handle symlinks by checking their real path to prevent symlink attacks\n  // This prevents attackers from creating symlinks that point outside allowed directories\n  try {\n    const realPath = await fs.realpath(absolute);\n    const normalizedReal = normalizePath(realPath);","sourceCodeStart":128,"sourceCodeEnd":164,"githubUrl":"https://github.com/modelcontextprotocol/servers/blob/579c3903f30044eb702a599a74b3ae77588e722e/src/filesystem/lib.ts#L128-L164","documentation":"On POSIX hosts validatePath rejects Windows-style absolute paths (drive letter followed by \\ or /, or a bare drive like 'C:'). Accepting them would silently create a literal file named 'C:\\\\Users\\\\...' inside the allowed root while reporting success for the wrong location. The error is thrown before any filesystem access.","triggerScenarios":"Passing a path like 'C:\\\\Users\\\\me\\\\file.txt' or 'C:/Users/me' to any filesystem tool while the server runs on Linux/macOS — typically from a config or script authored on Windows.","commonSituations":"Sharing MCP client configs or tool arguments between Windows and POSIX machines; WSL sessions receiving Windows paths from the Windows side; hardcoded paths in CI scripts copied from Windows developers.","solutions":["Convert the path to its POSIX form (e.g. '/mnt/c/Users/me/file.txt' under WSL) before calling the tool","Use a POSIX absolute or home-relative path like '~/file.txt' that exists on the host","Fix the caller/config to detect the platform and emit platform-appropriate paths"],"exampleFix":"// before (on Linux)\nawait read_file('C:\\\\Users\\\\me\\\\notes.txt');\n// after\nawait read_file('/mnt/c/Users/me/notes.txt'); // WSL, or a native POSIX path","handlingStrategy":"validation","validationCode":"const WIN_PATH = /^(?:[A-Za-z]:)(?:[\\\\/]|$)/;\nif (process.platform !== 'win32' && WIN_PATH.test(p)) {\n  throw new Error(`Refusing Windows-style path on POSIX host: ${p}`);\n}","typeGuard":"function isWindowsStylePath(p: string): boolean {\n  return /^(?:[A-Za-z]:)(?:[\\\\/]|$)/.test(p);\n} // guard callers before invoking the tool","tryCatchPattern":null,"preventionTips":["Normalize paths to the host platform before calling filesystem tools","In WSL use /mnt/c/... forms, not C:\\\\...","Keep per-platform path constants in config instead of hardcoding","Lint configs/scripts for drive-letter patterns when deploying to POSIX"],"tags":["filesystem","path-format","platform-mismatch","windows","posix"],"backgroundTag":"windows-path-on-posix","analyzedSha":"579c3903f30044eb702a599a74b3ae77588e722e","analyzedAt":"2026-09-01T06:06:22.520Z","contentChangedAt":"2026-09-01T06:06:22.520Z","schemaVersion":2},"datasetVersion":"2026-09-14T00:17:10.932Z"}