Skip to content
Failwallfailwall.dev

← Back to the wall

Filed
Case no.
gh-anthropics-sclaude-hcode-s109735

Claude Code subagent ran rsync --delete with an empty destination and wiped a WSL drive

Received Nov 14, 2026, 12:17 AM UTC

Guard rsync --delete destinations with a literal path or "${R:?}", even inside wsl.exe. A TaskStop that only kills wsl.exe leaves rsync running. Don't treat a quiet log as proof nothing was deleted.

Agents repeating the same mistakes? Scout gives every agent one current, shared record.

Share on X

What happened

Exhibit AGitHub issue
## Summary
During an autonomous, multi-agent session in the Claude desktop app (Code tab) on Windows, a subagent ran a destructive `rsync --delete` whose destination was a shell variable. The variable expanded to an empty string, so rsync synced into `/` and deleted user files on the Windows drive mounted in WSL (`/mnt/d`). The user never requested or approved this command. Files deleted through WSL do not go to the Recycle Bin.

## Environment
- Claude desktop app, Code tab; subagent transcript reports Claude Code 2.1.321 (CLI on the same machine reports 2.1.274)
- Model: claude-opus-5-5 (coordinator and subagents)
- Windows 11 Pro 10.0.26300, WSL2 Ubuntu-24.04, target drive NTFS mounted at `/mnt/d`
- Session was in an auto/unattended mode (the user had asked the agent to keep working overnight without waiting for approvals)

## What the model did
The subagent wanted a WSL copy of a project folder and ran (from a Windows shell tool):

```
wsl -d Ubuntu-24.04 -- bash -lc 'set -u; R=~/some-dir; mkdir -p $R; rsync -a --delete --exclude ... /mnt/d/<project>/ $R/; cd $R; ...'
```

`$R` was expanded to an empty string before the inner `bash` ran (the command line passed through `wsl.exe -- ...` was re-interpreted by a shell), so `set -u` did not help. The effective command was:

```
rsync -a --delete /mnt/d/<project>/ /
```

rsync then deleted everything under `/` that the non-root user could delete, including `/tmp` and folders on the user's Windows data drive under `/mnt/d`.

## Model mistakes (no user data included)
1. Used a **variable as the destination of a destructive command** (`rsync --delete`) without an empty-value guard (`${R:?}`) or a fixed-path check, and without considering that `wsl.exe -- bash -lc '...$VAR...'` can be expanded by another shell layer first.
2. The coordinator agent had **not given subagents any rule against destructive sync/delete commands on variable paths** before the incident (it added one only after the damage).
3. **Stopping did not stop the damage**: the coordinator stopped the subagent's task (TaskStop), which ended `wsl.exe` on the Windows side, but `rsync` kept running inside WSL for about two more minutes until it was killed manually from inside WSL.
4. The subagent's first damage report was **wrong** ("the user's document folder was not touched, checked"); it based this only on the absence of error lines in rsync output, while successful deletions are not logged. The real scope was found hours later.

## Impact
Permanent deletion of multiple folders of the user's business documents, design files, analysis videos and months of backups on the mounted Windows drive. Recovery is being attempted with Windows File Recovery; files overwritten by later writes may not be recoverable.

## Expected behavior / suggestions
- Block or require explicit confirmation (even in auto/unattended modes) for delete/sync commands (`rsync --delete`, `rm -rf`, `find -delete`, etc.) whose target is `/`, a drive root, `/mnt/<drive>`, `~`, or an unexpanded/empty variable.
- When a task that launched `wsl.exe` is stopped, also terminate its child processes inside WSL.
- Treat `wsl.exe -- bash -lc '<script with $VARS>'` as high risk; prefer running a script file inside WSL.
- Damage reports after a destructive command should not claim "not affected" from the absence of errors.

## Session details
Session and subagent IDs and full transcripts are available to Anthropic support on request (a separate support ticket has been filed).

Source. Posted publicly by yangjeonsik on GitHub (opens in a new tab). Quoted as posted; the title and lesson are Failwall's.