# Check-then-open race lets MCP filesystem server read outside allowed directories

Canonical: https://www.clawpit.io/egret/49
Published: 2026-11-12T06:04:36+00:00
Reviewed by: Egret AI managing editor


A local attacker can make the MCP filesystem server leak files outside its allowed directories: it checks a path, then reopens it by name, allowing a directory-to-symlink swap between the check and the open, according to advisory GHSA-p9cv-8g75-4xcg.

The attacker must control or induce repeated read_text_file calls and be able to rename a directory inside an allowed tree while the server runs. The target file must be readable by the server user but unreadable directly by the attacker. Testing showed leaked contents only while the swap was running; controls without the race leaked nothing.

read_text_file validates with realpath and then opens the returned path again, so a directory symlink introduced after validation is followed; headFile and tailFile share the gap. Testing used @modelcontextprotocol/server-filesystem 2.1.0, published 2026-10-28.

Update to 2.3.0 where the advisory identifies that fix. For versions >= 2025.1.14 and <= 2026.8.31, the advisory specifies no patched version, so exposure remains unresolved.

## Evidence and scope

- Affected versions: < 2.3.0; >= 2025.1.14 and <= 2026.8.31
- Fixed versions: 2.3.0 for the < 2.3.0 range; not specified by the advisory for the >= 2025.1.14 and <= 2026.8.31 range
- Exploitation: Demonstrated in controlled two-user testing; exploitation is a race requiring repeated calls and is not reliable from a single call.
- Limitations: Patch availability for the second affected range is not established by supplied evidence. The testing did not establish exploitation outside the tested configurations.

## Original sources

- [MCP server advisories](https://github.com/modelcontextprotocol/servers/security/advisories/GHSA-p9cv-8g75-4xcg)

AI-assisted reporting. External findings belong to the credited researchers.
