One trailing quote.
The path the server checked wasn’t the path it opened. This is how I found that in the official MCP filesystem server, and what it was really worth.
The short version.
The filesystem server in modelcontextprotocol/servers is only supposed to touch folders you allow. Before every operation it validates the path. I noticed it cleaned the path up before checking it, then used the original, uncleaned path for the real file call.
The clean-up strips a trailing quote or space. So when I asked for /allowed/proj', the check saw /allowed/proj and said yes, while the filesystem opened a different folder that happens to end in a quote.
Two strings, one request.
Where it lives.
All of it is in validatePath in src/filesystem/lib.ts. The normalizer:
p = p.trim().replace(/^["']|["']$/g, "");
The check runs on the cleaned copy:
const normalizedRequested = normalizePath(absolute); const isAllowed = isPathWithinAllowedDirectories(normalizedRequested, allowedDirectories);
The file call runs on the raw one:
const realPath = await fs.realpath(absolute);
return realPath;
There is a second check after realpath, but it runs through the same normalizer, which strips the same character again, so it passes too. Every tool that takes a path goes through this function: read, write, edit, move, list and search.
Proving it.
I imported the real validatePath from the server’s compiled output, made an allowed folder and a sibling whose name ends in a quote, and asked for the sibling:
const allowedProj = path.join(sandbox, "allowed/proj");
const siblingEvil = path.join(sandbox, "allowed/proj'");
await fs.writeFile(path.join(siblingEvil, "SECRET.txt"), "OUTSIDE");
const validated = await validatePath(sandbox + "/allowed/proj'", [allowedProj]);
// validated ends in proj' — outside the allowlist, and readable
What it was really worth.
I scored it 9.3. The maintainers rescored it to 4.2, and they were right. The only place I could reach was a sibling folder whose name is the allowed folder plus a trailing quote or space, and that folder has to exist already. It is a real boundary break, but a narrow one.
I’d rather tell you that than call it a full sandbox escape.
How it went.
I reproduced it against the latest main.
I reported it privately through GitHub Security Advisories.
The maintainers confirmed it on 2.0.0 and wrote a fix.
Advisory published, fix released in 2.0.1, CVE requested.
The lesson.
Validate the thing you’re going to use, not a cleaned-up copy of it.
The fix does exactly that: it checks the path in the same spelling the filesystem call uses. If you’re on an old date-versioned release (2025.x or 2026.x), your package manager won’t offer 2.0.1 as an upgrade, so install it explicitly.
I used AI assistance while preparing the report, and the advisory says so. The finding, the reproduction and this write-up are mine to answer for.