Repository navigation
Description
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)
- 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 thatwsl.exe -- bash -lc '...$VAR...'can be expanded by another shell layer first. - 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). - Stopping did not stop the damage: the coordinator stopped the subagent's task (TaskStop), which ended
wsl.exeon the Windows
side, butrsynckept running inside WSL for about two more minutes until it was killed manually from inside WSL. - 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.exeis 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).
Activity
basics: an assignment inside wsl -- bash -lc does not protect a varia…
dooly6276 commentedon Nov 14, 2026
The
wsl.exe -- bash -lc '...'detail is the important one: the line is read by a Linux shell before the innerbashruns, so$Ris expanded there, where it was never set, and both the in-string assignment andset -ucome too late.rsync -a --delete src/ "${R:?}/"fails safely in every shell layer, andwsl --exec bash -lc '...'skips the extra shell.I maintain claude-bulkhead, a set of PreToolUse hooks for Claude Code (MIT, no dependencies; Windows, macOS and Linux). Version 0.4.0, released today, adds a rule for this pattern:
rsync --delete(and--delete-*,--remove-source-files) whose destination is$R/or a bare$R, andrm -rf $R/, are blocked unless the same shell set the variable to something that cannot be empty or the command already uses${R:?}. An assignment insidewsl ... -- bash -lc '...'deliberately does not count, so the command from this report is blocked as written. To check a command without installing anything:It reads the command text only, so the same delete inside a script file the agent runs is not seen.
EomNamKyu commentedon Nov 14, 2026
Sorry this happened. Losing the WSL root and the mounted Windows drive to one command is brutal.
If
$DESTexpanded to empty,rsync -a --delete "$SRC/" "$DEST/"targets/, and--deleteremoves everything there that isn't in the source. In bash,"${DEST:?}/"makes the shell exit with an error when the variable is empty or unset.Was the subagent's command shown to you before it ran, or was it covered by an allow rule from the parent session?