Skip to content

[Data loss] Subagent ran rsync -a --delete with an empty destination variable via wsl.exe, wiping the WSL root and the mounted Windows drive; TaskStop did not stop the Linux process #109735

Open

Description

@yangjeonsik

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).

Activity

  1. dooly6276 commented on Nov 14, 2026

    @dooly6276

    The wsl.exe -- bash -lc '...' detail is the important one: the line is read by a Linux shell before the inner bash runs, so $R is expanded there, where it was never set, and both the in-string assignment and set -u come too late. rsync -a --delete src/ "${R:?}/" fails safely in every shell layer, and wsl --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, and rm -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 inside wsl ... -- bash -lc '...' deliberately does not count, so the command from this report is blocked as written. To check a command without installing anything:

    npx -y claude-bulkhead@0.4.0 explain -- 'rsync -a --delete src/ $R/'
    

    It reads the command text only, so the same delete inside a script file the agent runs is not seen.

  2. EomNamKyu commented on Nov 14, 2026

    @EomNamKyu

    Sorry this happened. Losing the WSL root and the mounted Windows drive to one command is brutal.

    If $DEST expanded to empty, rsync -a --delete "$SRC/" "$DEST/" targets /, and --delete removes 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?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions