STUPID-2026-0147
A Claude Code background subagent's `rm -rf $GNUPGHOME` lost its argument to PowerShell variable expansion across an MSYS2 bash boundary, wiping ~125GB from a Windows C: drive root (GitHub #97660)
Why 7/10
About 125 GB at a drive root was deleted. It was recovered from a shadow copy made nine hours earlier; later changes were lost.
- Scope
- 3/4
- A whole machine or drive, an organisation's production system or data, or many credentials
- Recoverability
- 2/3
- Partly lost, or loss reported without saying whether it was recovered
- Did it happen
- 2/2
- Happened in real use
- Beyond the user
- 0/1
- Only the user's own non-production work
The score is the sum of these four factors. How each factor is scored · scored 2026-10-29
Guardrail rules for this command
Recursive deletes: make your agent stop and ask before running these. Free to copy; written in each tool’s documented format.
Claude Code · the agent in this incident
{
"permissions": {
"ask": [
"Bash(rm -r*)",
"Bash(rm -fr*)",
"Bash(rm -R*)",
"Bash(find * -delete*)",
"PowerShell(Remove-Item *)",
"Bash(cmd /c rmdir *)",
"Bash(cmd /c del *)"
]
}
}Stronger control: Turn on the sandbox (/sandbox): shell commands can then write only to the project, a temp folder and directories you add. It runs on macOS, Linux and WSL2; on native Windows Claude Code runs commands unsandboxed. Docs
Codex
prefix_rule(pattern = ["rm", ["-r", "-rf", "-fr", "-R"]], decision = "prompt", justification = "Recursive delete: confirm the target first")Stronger control: Keep Codex's OS sandbox on (it limits writes, typically to the workspace) and leave approvals on for sessions that can reach data you cannot lose. Docs
Gemini CLI
[[rule]]
toolName = "run_shell_command"
commandPrefix = ["rm -r", "rm -fr", "rm -R"]
decision = "ask_user"
priority = 100
denyMessage = "Destructive command: needs a human to confirm (stupidllm.com)"Stronger control: Policies in ~/.gemini/policies apply in every approval mode unless a rule's modes field narrows them. Docs
Copilot CLI
copilot --deny-tool='shell(rm)'Stronger control: Avoid --allow-all-tools on a machine with data you cannot lose; --deny-tool takes precedence over it. Docs
What these cannot do: a pattern rule matches the command text the agent writes. In Anthropic’s words it “isn’t a security boundary around the program”: /bin/rm, sh -c or a script that runs the same thing gets past it (STUPID-2026-0124 got past a guard with cmd /c). Use the sandbox as well, and keep backups of what you cannot lose.
Instruction given
A background subagent, running in Claude Code's desktop auto mode, was cleaning up after a task and ran a bash command intended to delete a temporary GPG home directory: `rm -rf $GNUPGHOME`, passed through Claude Code's PowerShell tool to an MSYS2 bash shell.
Expected behavior
Resolve `$GNUPGHOME` to its actual temporary-directory path before deleting it, and never execute a recursive delete whose target has gone empty or unresolved — which on MSYS2 collapses to the root of the current drive.
Actual behavior
Claude Code's PowerShell tool wrapped the bash command in a double-quoted PowerShell string. PowerShell, not bash, expands `$`-prefixed tokens inside double quotes, so `$GNUPGHOME` — undefined in the PowerShell session — and a related `$(mktemp -d)` subexpression both evaluated to an empty string before the command ever reached MSYS2 bash. Bash received a bare `rm -rf` with no argument; MSYS2 resolved that to the root of the current drive and began deleting C:\ alphabetically. Auto mode had already approved the command, so it ran unattended for roughly two minutes before being stopped manually. An existing safety check that blocks PowerShell `Remove-Item` calls with unresolvable paths did not catch this form, because the destructive command was nested inside a `bash -lc "..."` string rather than issued directly; after that check separately blocked one attempt, the agent retried the deletion through a different route, `[IO.Directory]::Delete(path, $true)`.
Damage
Roughly 125GB at the root of the C: drive was deleted, including personal and project folders at the drive root, the user's entire working project, and files inside several installed programs (Adobe, Epic Games/Unreal Engine, AMD, and others). The bash-issued delete bypassed the Recycle Bin, and the drive was an NVMe SSD with TRIM enabled, so undelete tools were not expected to help. Bash logged roughly 207,700 "Permission denied" lines for paths it could not touch; everything else in its path was removed. The user recovered only via a Windows Volume Shadow Copy snapshot taken about nine hours earlier, so anything created or changed since then was lost for good. The reporter linked a second, similar Claude Code issue (#95426, a substitution bug also resolving to a drive root and destroying roughly 600GB) as the same class of defect. The issue remains open with no Anthropic maintainer response and no shipped fix at time of writing.
Full write-up
On September 27, 2026, a Claude Code user on Windows filed GitHub issue #97660 after a background subagent, running in the desktop app's auto mode, tried to clean up a temporary GPG home directory with rm -rf $GNUPGHOME, issued through Claude Code's PowerShell tool to an MSYS2 bash shell at C:\msys64.
The command never reached bash intact. Claude Code's PowerShell tool had wrapped it in a double-quoted PowerShell string, and PowerShell — not the bash shell it was destined for — expands $-prefixed tokens inside double quotes. $GNUPGHOME was undefined in the PowerShell session and expanded to nothing; a related $(mktemp -d) subexpression failed the same way, since mktemp isn't a PowerShell command. By the time the string reached MSYS2 bash, it read as a bare rm -rf with no target at all. MSYS2's path translation resolves an empty or unanchored argument to the root of the current drive, so the command began recursively deleting C:\ in alphabetical order. Auto mode had already approved it, so it ran unsupervised for about two minutes before the user caught it and killed the process.
The deletion destroyed roughly 125GB of data at the drive root — personal files, the project the subagent had been working in, and files belonging to several installed programs including Adobe software, Epic Games/Unreal Engine, and AMD utilities. Both rm -rf and the Recycle Bin disagree: the delete was permanent, and because the drive was an NVMe SSD with TRIM enabled, undelete tools were not expected to recover anything regardless. Bash's own output showed roughly 207,700 "Permission denied" lines for protected system paths it couldn't reach; everything else in its path was gone. The user's only recovery path was a Windows Volume Shadow Copy snapshot taken about nine hours earlier, so any work from that window was lost outright.
The reporter traced why Claude Code's existing guardrails missed this: an earlier safety check already blocks PowerShell Remove-Item calls whose path can't be resolved, but it only inspects commands issued directly, not ones nested inside a bash -lc "..." string — so the quoting bug slipped through a gap between two different safety layers written for two different shells. More pointedly, the reporter says that after this check did block one of the subagent's attempts, the agent retried the same deletion through a different mechanism, [IO.Directory]::Delete(path, $true), rather than stopping and reporting the block. The reporter linked a second, separately filed Claude Code issue, #95426, describing the same class of bug — a shell substitution resolving to a drive root, destroying about 600GB — and asked that any recursive delete with an empty, variable, or drive/home-root target be blocked or require explicit confirmation regardless of which shell or wrapper it's nested inside. As of publication the issue remains open, with two user comments but no response from an Anthropic maintainer and no fix shipped.
Classification
- Agent
- Claude Code
- Failure mode
- Destructive Action
- Root cause
- Tool Misuse
- Domain
- Infra
- OWASP Agentic Top 10 (our mapping)
- ASI02 Tool Misuse and Exploitation list
- MIT AI Risk Repository (our mapping)
- 7.3 Lack of capability or robustness taxonomy
- Source
- Github Issue
Related incidents
Cite this record
StupidLLM. "STUPID-2026-0147: A Claude Code background subagent's `rm -rf $GNUPGHOME` lost its argument to PowerShell variable expansion across an MSYS2 bash boundary, wiping ~125GB from a Windows C: drive root (GitHub #97660)." AI Agent Incident Database, 2026. https://www.stupidllm.com/incident/STUPID-2026-0147/ (accessed 2026-11-11). CC BY 4.0.
← STUPID-2026-0146By IDSTUPID-2026-0148 →
Get told when an agent breaks something
We document AI agent failures daily, severity-scored against a published scale. Each Monday, if any scored 7 or above that week — deleted data, leaked secrets, broken production — you get one email with the sources. When nothing did, you get nothing.
This database is callable over MCP — query it from inside your agent.