Repository navigation
Description
Describe the bug
While working on an unrelated task (preparing an upstream PR), the agent wanted to run Go tests in WSL. It passed a multi-line bash script inline from PowerShell:
wsl -d Ubuntu-24.04 -- bash -lc $s # $s = multi-line here-string
The line breaks/quoting were mangled on the way through PowerShell -> wsl.exe, so the line D=~/src/rs-pr never took effect and $D was empty. The next line therefore ran as:
rsync -a --delete --exclude .git /mnt/c/Users/<user>/Code/<repo>/ /
i.e. "make / look like the repo, delete everything else". It ran ~7 minutes as the normal WSL user before the agent noticed (the tool output was 34 MB of rsync errors) and stopped it.
Damage: all user-deletable files on the Windows data drive D: (mounted at /mnt/d) were deleted, ~10 GB incl. a Thunderbird profile (mail) and games. D: is an SSD, so TRIM made the data unrecoverable (verified by raw MFT/cluster analysis: deleted files' clusters now return random data). C: survived only because rsync deletes in reverse alphabetical order and hit C:\Windows (permission denied) before C:\Users. The user had no backup of D:.
Affected version
- Copilot SDK-based agent in VS Code 1.147.0 (8a14f0cc1b08d531eb83255ea3764ae22aa932b5, x64)
- Model: claude-opus-5.5, reasoning effort medium (verified from session usage log)
- OS: Windows 11 (NT 10.0.26300) + WSL Ubuntu 24.04
- Date: 2026-11-20
Steps to reproduce the behavior
- Agent session on Windows with PowerShell tool and WSL installed (Windows drives auto-mounted under /mnt).
- Agent builds a multi-line bash script in a PowerShell here-string that sets a variable and then uses it as a destructive target, e.g.
D=~/src/x; mkdir -p $D; rsync -a --delete src/ $D/ - Agent runs it via
wsl -- bash -lc $script. - Quoting breaks, the assignment is lost,
$Dis empty ->rsync --delete src/ /runs and deletes user files on all mounted drives.
Expected behavior
- The agent must never run a command with
--delete,rm -rf,find -deleteetc. whose target is built from a variable without guarding it (set -euo pipefail,${D:?}) and without checking the resolved path is not/or a mount root. - Destructive commands outside the workspace should require explicit user confirmation; none was requested.
- Multi-line scripts for WSL should be written to a file and executed, not passed through PowerShell -> wsl.exe argument quoting.
- When the first output shows clear signs of a broken command (bash "not a valid identifier" errors, rsync touching /mnt/c/Windows), the run should be aborted immediately.
Additional context
- The agent's
initial_waitwas 400 s, so the destructive command ran unobserved for that long. - Root filesystem / and /mnt/c/Windows were protected only by permissions; any drive where the user has delete rights (/mnt/d) was wiped.
- Filed by the affected user, with the summary written by the agent itself at the user's request.
Activity