[BUG] Cowork: FUSE Mount Cache Coherency Failure on Host-Side File Writes
Preflight Checklist
- [x] I have searched existing issues and this hasn't been reported yet
- [x] This is a single bug report (please file separate reports for different bugs)
- [x] I am using the latest version of Claude Code
What's Wrong?
Summary
The Cowork sandbox's file mount layer (virtiofs + bindfs) does not invalidate cached file-size metadata when files are modified on the host side (e.g., by MCP servers). This causes the sandbox to see corrupted file content: null-byte padding when files shrink, hard truncation when files grow.
Affected Configuration
- Platform: Windows 11
- Client: Claude desktop app (Cowork mode)
- Mount stack: NTFS → virtiofs (host↔Linux VM) → bindfs (FUSE) → sandbox
- Trigger: Any MCP server that writes to files in the mounted workspace folder
Symptoms
When an MCP server (running on the Windows host) writes to a file in the workspace folder:
- The write is correct on the host filesystem — verified by reading back through the MCP.
- The sandbox sees stale file size — the FUSE cache retains the previous size known from the last sandbox-originated operation.
- Content is corrupted in the sandbox view:
- File shrinks → new content + null bytes (
\x00) padded to old size - File grows → content hard-truncated at old size
- Equal size → no corruption (no size change = no cache mismatch)
- New file (no prior cache entry) → no corruption
- Modify time is not updated in the sandbox
statoutput after host-side writes, confirming the FUSE cache is stale.
Cascade: How This Causes Real Data Loss
The stale cache alone would be annoying but survivable. The real damage occurs through read-modify-write:
- MCP writes file (correct on host disk)
- Claude reads file from sandbox (stale FUSE cache → null-padded or truncated)
- Claude writes back the corrupted view (via sandbox filesystem tools)
- Now the host disk is genuinely corrupted — the FUSE write propagates through virtiofs to NTFS
This is how vault files were permanently corrupted in production use before the root cause was identified.
Workaround
Avoid using MCP tools for file writes. Use only the sandbox filesystem tools (Read/Edit/Write) for all file I/O. Since these go through the FUSE mount, the cache stays consistent with its own writes. MCP read-only operations (e.g., search) remain safe.
Root Cause Analysis
Full test suite and analysis: available on request (13 tests, hex dumps, inode tracking, timing analysis). The definitive test (Test 13) proved the corruption is purely a cache view issue by showing correct content via MCP read and corrupted content via sandbox read on the same file, immediately after a host-side write.
Environment Details
bindfs on /sessions/.../mnt/Work type fuse.bindfs (rw,nosuid,nodev,relatime,user_id=0,group_id=0,default_permissions,allow_other)
IO Block: 262144, Blocks: 0 (characteristic of FUSE/virtiofs, not native filesystem)
What Should Happen?
The external write file event should invalidate the FUSE cache and force a new read from the filesystem
Error Messages/Logs
Steps to Reproduce
Reproduction Steps
Setup
Open a Cowork session with a workspace folder mounted.
Test (requires any MCP that can write files)
- From sandbox, write a file with known content (~235 bytes). Verify with
wc -c. - Via MCP (host-side write), overwrite the same file with shorter content (~17 bytes).
- From sandbox, read the file:
wc -creports 235 bytes (stale cached size)xxdshows 17 bytes of correct new content + 218 null bytesstatshows unchanged mtime
- Via MCP read, verify the file on host is correct (17 bytes, no null bytes).
Reverse test (expanding)
- From sandbox, write the file with short content (17 bytes). Verify.
- Via MCP, overwrite with longer content (~240 bytes).
- From sandbox,
wc -creports 17 bytes. Content is truncated at byte 17. - Via MCP read, verify the file on host has the full ~240 bytes.
Key observation
The FUSE cache always reflects the last sandbox-originated file size, regardless of host-side changes.
Claude Model
Not sure / Multiple models
Is this a regression?
I don't know
Last Working Version
_No response_
Claude Code Version
2.1.87
Platform
Anthropic API
Operating System
Windows
Terminal/Shell
Other
Additional Information
_No response_
This issue has 4 comments on GitHub. Read the full discussion on GitHub ↗