Baike.dev
All toolsOnline toolsAI codingTrendingOpen sourceNewsSubmit
Log in
Back to tool/Back to issues
#791·DesktopCommanderMCP

Case-folding in normalizePath can bypass allowedDirectories on case-sensitive filesystems

Author: UlinoyaPedCreated Sep 27, 2026Updated Sep 27, 2026

Summary

allowedDirectories path checks currently lowercase paths on every platform:

typescript
function normalizePath(p: string): string {
    return path.normalize(expandHome(p)).toLowerCase();
}

On case-sensitive filesystems (e.g. typical Linux filesystems, or case-sensitive macOS volumes), two distinct directories can therefore compare as the same path. This can make a path outside an allowed directory pass isPathAllowed().

I understand that allowedDirectories is documented as a guardrail rather than a full sandbox, and terminal commands are intentionally outside that boundary. This report is specifically about the filesystem tools' own allowlist behaving incorrectly on case-sensitive filesystems.

Example

Suppose both of these directories exist on Linux:

/tmp/DC-Allow
/tmp/dc-allow

and the config contains:

json
{
  "allowedDirectories": ["/tmp/DC-Allow"]
}

A request for:

/tmp/dc-allow/secret.txt

is first resolved with realpath(), but the subsequent allowlist comparison lowercases both values:

/tmp/DC-Allow             -> /tmp/dc-allow
/tmp/dc-allow/secret.txt  -> /tmp/dc-allow/secret.txt

so this check becomes true:

typescript
normalizedPathToCheck.startsWith(normalizedAllowedDir + path.sep)

even though /tmp/DC-Allow and /tmp/dc-allow are different directories on a case-sensitive filesystem.

Relevant code

src/tools/filesystem.ts:

typescript
function normalizePath(p: string): string {
    return path.normalize(expandHome(p)).toLowerCase();
}

and later:

typescript
const subdirCheck = normalizedPathToCheck.startsWith(
    normalizedAllowedDir + path.sep
);

The current realpath() / symlink handling does not prevent this, because case folding happens after canonicalization during the allowlist comparison.

Impact

Filesystem tools using validatePath() may read/write/list a different same-spelling-but-different-case directory that was not actually included in allowedDirectories.

This is separate from the documented fact that terminal/interpreter execution can bypass filesystem guardrails.

Suggested fix

Only perform case folding on platforms/filesystems where path comparison is known to be case-insensitive. At minimum, avoid unconditional .toLowerCase() on POSIX.

For example, a simple platform-level improvement would be conceptually:

typescript
function normalizePath(p: string): string {
    const normalized = path.normalize(expandHome(p));
    return process.platform === 'win32'
        ? normalized.toLowerCase()
        : normalized;
}

A filesystem-aware solution would be even more accurate for case-sensitive Windows directories or case-sensitive macOS volumes.

Regression test

On a case-sensitive filesystem:

  1. Create /tmp/DC-Allow and /tmp/dc-allow.
  2. Allow only /tmp/DC-Allow.
  3. Verify that validatePath("/tmp/DC-Allow/file") is allowed.
  4. Verify that validatePath("/tmp/dc-allow/file") is rejected.

Source: wonderwhy-er/DesktopCommanderMCP

View original on GitHubView discussion on GitHub