Cursor Agent auto-ran a command that wiped an entire drive (Windows / PowerShell)

Where does the bug appear (feature/product)?

Cursor IDE

Describe the Bug

Hello Cursor team,

I am reporting a serious data-loss incident caused by Cursor Agent.

Environment

  • Cursor 3.24.18 on Windows 10 (19045), default shell: Windows PowerShell 5.1
  • Agent mode, model: Grok 4.7 High Fast
  • Date: 2026-10-17, around 18:31 (UTC+8)
  • Request ID: 2289673e-4b68-48a0-a7ea-e209cbab876a

What happened
The agent wanted to delete one small subdirectory inside my workspace. It generated and executed this command (path shortened):

cmd /c "rmdir /s /q \"D:\<workspace>\<subfolder>\""

PowerShell does not treat " as an escape, so the quoting broke. cmd.exe effectively ran "rmdir /s /q ", which deletes the root of the current drive. The command ran without any confirmation prompt, presumably because its literal text looked like a harmless deletion inside the workspace.

The command did not finish within the 30-second limit and was moved to the background. The agent then killed only the parent PowerShell process, not the child cmd.exe, and reported the deletion as successful without checking anything. In a later turn, the agent saw clear signs that files were missing (the workspace path no longer existed, and Cursor’s own bundled ripgrep binary was gone), but kept working on an unrelated question and told me nothing until my next message.

Impact
Almost the entire D: drive (1 TB NVMe SSD) was deleted: several hundred thousand files of personal and work data, and most of the software installed on that drive, including part of Cursor itself. Because TRIM is enabled, nearly all of the deleted data is unrecoverable. Only small files stored inside NTFS MFT records could be restored.

A second near-miss
Afterward, I asked the agent to write safety guidelines. While testing its own “safe delete” helper, it passed the drive-relative path “E:” with "E:" as the allowed root. “E:” resolved to the current directory, which was the folder holding the recovered data, so the helper started deleting it. Only Windows’ refusal to delete the current working directory prevented a second loss.

Requests

  1. Do not auto-run recursive or forced deletions without explicit user confirmation, regardless of how the command text looks. This includes rmdir /s, rd /s, del /s, Remove-Item -Recurse, and anything wrapped in cmd /c.
  2. Provide a real sandbox on Windows that restricts agent file writes and deletions to the workspace.
  3. Hard-block any operation that resolves to a drive root or a path outside the workspace.
  4. When a command times out or is killed, terminate the whole process tree, and warn the agent and the user that it may still be running.
  5. Make the agent stop and alert the user immediately when it sees environmental anomalies, such as paths or tools suddenly missing.

I hope this helps prevent the same thing from happening to other users.

Regards,
A Cursor user

Steps to Reproduce

Safe, non-destructive reproduction (do NOT replace “echo” with a real rmdir):

  1. On Windows 10/11, open Cursor with the default terminal shell set to Windows PowerShell 5.1.
  2. Run this in the integrated terminal, or let the Agent run it:
    cmd /c “echo rmdir /s /q "D:\test\project\Some-Folder"”
  3. Observe the output:
    rmdir /s /q \ D:\test\project\Some-Folder
    PowerShell does not treat " as an escape, so cmd.exe receives "" (the root of the current drive) as the first target.
    Without “echo”, this command deletes the entire current drive.
    What the Agent actually did in my session:
  4. In Agent mode (Grok 4.7 High Fast), I asked the agent to delete one small subdirectory inside my workspace.
  5. The agent generated: cmd /c “rmdir /s /q "D:<workspace><subfolder>"”
  6. The command auto-ran without any confirmation prompt.
  7. It did not finish within 30 seconds and was moved to the background, because it was deleting the whole D: drive.
  8. The agent killed only the parent PowerShell process (not the child cmd.exe) and reported success without verification.
    Expected: Recursive or forced deletion commands require user confirmation, and nothing outside the workspace (especially a drive root) can be deleted.
    Actual: The command ran automatically and wiped almost the entire D: drive.

Operating System

Windows 10/11

Version Information

Cursor 3.24.18

For AI issues: which model did you use?

Grok 4.7 High Fast

For AI issues: add Request ID with privacy disabled

2289673e-4b68-48a0-a7ea-e209cbab876a

Does this stop you from using Cursor

Sometimes - I can sometimes use Cursor

Hey @Newts00579 I’m really sorry. Losing almost an entire drive, especially with TRIM, is a really rough scenario. Thanks for such a detailed breakdown and for the safe repro with echo, it’s genuinely helpful.

This is an issue we’re tracking. I’ve passed your report, the Request ID, and all five suggestions to the team: confirmation for recursive or forced delete, a sandbox on Windows, blocking drive roots and paths outside the workspace, killing the full process tree on timeout, and stopping on abnormal environment changes. I also separately passed along two more points: the agent reported success after timing out and kept working even though the paths were gone, and the near-miss with E: in the safe-delete helper. There’s no timeline yet, but I’ll post here when there’s an update.

To make it easier for the team to investigate, could you please answer two questions:

  1. What Run Mode was set in Cursor Settings > Agents > Approvals & Execution at the time of the incident: Auto-review, Allowlist, or Run Everything?
  2. Did your allowlist include cmd, powershell, or other general wrappers?

Until there’s stronger protection on Windows, I’d recommend this:

  • Switch Run Mode to Allowlist and keep the list short, with only specific safe commands like npm test. No cmd, powershell, or pwsh. Anything not on the list will wait for your approval. Also note that the allowlist is best-effort, not a security boundary: Run Modes | Cursor Docs
  • Add a user-level beforeShellExecution hook in ~/.cursor/hooks.json. The hook should check the command text and return exit code 2 to block if it sees rmdir /s, rd /s, del /s, Remove-Item -Recurse, or format. That gives you a deterministic stop no matter how the model phrases the command: Hooks | Cursor Docs
  • Before you approve, read any delete command in full, especially ones using cmd /c and nested quotes
  • Keep backups of important data on a separate drive or in the cloud, and make sure the agent can’t access them

For recovery, if some projects were in a git remote or cloud sync, you may be able to restore them from there. It sounds like you’ve already recovered about as much as possible otherwise.

Let me know the Run Mode when you get a minute.

Thanks a lot for the quick and thorough follow-up, and for passing everything along to the team.

To answer your questions:

  1. Run Mode: Run Everything. Since nothing was gated, the allowlist wasn’t in play at all.
  2. That’s partly on me. I’ve gotten used to working with agents like Codex and models like Claude Opus and GPT, and I’ve never really worried about what they’re capable of. When I used Cursor last year, I carefully reviewed my allowlist. But as the models kept proving themselves, I eventually switched to Run Everything for efficiency. This incident has been a painful lesson: the models are still not reliable enough to run without guardrails.

One point I’d like the team to consider: in my experience, Codex still stops and warns before clearly destructive commands even in its fully permissive mode. “Run Everything” shouldn’t mean the agent can wipe a drive without a second thought. A last-line check for things like recursive deletes or drive-root targets would be valuable even in that mode.

Going forward, I’ll switch to Allowlist with a short list, and add a beforeShellExecution hook to block rmdir /s, rd /s, del /s, Remove-Item -Recurse and format, as you suggested. Thanks for the pointers.

On the bright side: my entire Steam library is gone, but luckily Elden Ring Nightreign, the one game I actually play, uses cloud saves. So at least my relics survived.

Thanks again, and I look forward to any update.

Thanks for the quick reply. That answers the main question.

About Run Everything: according to the docs, in this mode all tool calls run automatically, with no approval, sandbox, or classifier: Run Modes | Cursor Docs. So there was no confirmation step. I passed your suggestion to the team as separate feedback: even in Run Everything, there should be a final check for recursive or forced deletion, and for targets at the disk root. I also shared that this session was specifically using Run Everything.

The plan with an allowlist and the beforeShellExecution hook sounds good. A couple small additions:

  • In Cursor Settings > Agents > Approvals & Execution, turn on File-Deletion Protection and External-File Protection as an extra layer. But don’t rely on them for rmdir /s or rd /s through cmd /c. The main safeguard there is the hook.
  • After setup, test the hook with a safe command, for example cmd /c "echo rmdir /s /q test". The agent should get blocked, not execute it.

Glad the Nightreign saves survived at least. I’ll post here when there’s an update.