Where does the bug appear (feature/product)?
Cursor IDE
Describe the Bug
Priority: P0 — Agent Shell safety (platform), not “prompt hygiene”
Where: Editor / Agent Chat (in-editor Agent + Task subagent) + Terminal & commands
Summary
On Windows, a Cursor Task subagent ran Agent Shell:
cmd /c "rmdir /s /q \"d:\Cursor_Projects\quiz-check\_tmp_xlsx_inspect\""
Intent: delete one temp folder after Excel→MD conversion.
cwd of that Shell session was inside the folder being deleted (D:\Cursor_Projects\quiz-check\_tmp_xlsx_inspect).
Due to Windows cmd quoting (\ before closing " escapes the quote) combined with /s /q and cwd-inside-target, recursion escaped the declared target and walked the volume root D:\.
In ~40 seconds USN recorded ~210,201 FILE_DELETE events. Unlocked files on the work volume were wiped; locked paths (running Cursor, cwd, some .venv binaries) remained as skeletons. Agent treated exit_code: 32 + TMP_STILL_EXISTS as “cleanup failed,” while stderr already showed volume-root paths (\CursorData, \Program Files\cursor, \System Volume Information).
This is a platform safety gap in Agent Shell on Windows: destructive recursion must not be able to leave the declared target, and stderr outside-target paths must abort/surface hard failure.
Environment
| Field | Value |
|---|---|
| OS | Windows 10/11 |
| Cursor version | 3.13.25 |
| Workspace | D:\Cursor_Projects\quiz-check |
| Model | Grok 4.5 High (cursor-grok-4.5-high) |
| Features | in-editor Agent + Task subagent + Shell tool |
| Incident local time | 2026-07-28 19:58:11–19:58:52 Omsk (UTC+6) |
| Incident UTC | 2026-07-28 13:58:11–13:58:52 |
IDs
| ID | Value |
|---|---|
| Request ID (primary subagent run, ~19:51 Omsk) | 21363e0a-106d-4eb3-be2b-1d2ce262f9e6 |
| Request ID (tool call at rmdir start, ~19:58:11) | bacf250d-bff4-49e3-88c7-f405b64d63b0 |
| Request ID (subagent completion after wipe, ~19:58:55) | d09dcf84-5df4-4899-96d4-21ea4057902c |
| Parent chat | 848c746d-a51a-4aa7-8940-557828b9067a |
| Subagent | e51e8558-3f0b-4dab-9eca-e7374d8c1140 |
| Terminal session | 618164 (pid 33664) |
Privacy: Share Data enabled.
Exact Shell metadata (terminal 618164)
cwd: D:\Cursor_Projects\quiz-check\_tmp_xlsx_inspect
command: cmd /c "rmdir /s /q \"d:\Cursor_Projects\quiz-check\_tmp_xlsx_inspect\""
started_at: 2026-07-28T13:58:11.439Z
ended_at: 2026-07-28T13:58:52.263Z
elapsed_ms: 40824
exit_code: 32
marker: TMP_STILL_EXISTS
stderr path classes (volume-root walk — not limited to temp)
\CursorData\...\Cursor_Projects\...(incl. other repos /.venv)\Program Files\cursor\...\System Volume Information
Root cause (as observed)
- Windows quoting:
"D:\path\folder\"— trailing\before"escapes the closing quote; path parsing breaks. - cwd inside target: Shell cwd = folder being deleted with
rmdir /s /q. /s /q: recursive + quiet → mass deletes succeed silently; only failures print.- Agent interpretation:
exit_code: 32/ sharing violation /TMP_STILL_EXISTStreated as benign cleanup failure despite stderr showing outside-target volume-root paths.
Not the cause
- Disk failure / NTFS corruption (volume stayed online; after reboot Ntfs healthy)
- Wise / cleanmgr / intentional format (0 hits in System/Application 18–21 Omsk)
- AppData→D: junction as intentional wipe tool
- Explicit user command to wipe
D:\
Impact
- Work volume
D:largely emptied of unlocked data (~75+ GB free after; only Cursor remnants visible at top level). - USN peak ~210k deletes / ~40s.
- Cursor
main.log@ 19:58:23:Watcher shutdown because watched path got deleted. - SSD TRIM: many recovered MFT entries zero-filled → poor undelete prospects.
- Cursor marked unusable for normal work until environment rebuilt.
Follow-up attachments after post: proof_rmdir_peak.txt, main_log_watcher_1958.txt.
Ask
Treat as P0 Agent Shell safety on Windows, not user error. Please harden Shell path handling + cwd-vs-target checks + outside-target stderr abort for recursive deletes.
Steps to Reproduce
WARNING: disposable VM/volume only. Never on a real work disk.
- Create
D:\repro_safe\_tmp_xlsx_inspect\with dummy files. - Agent Shell cwd = that folder.
- Run:
cmd /c "rmdir /s /q \"D:\repro_safe\_tmp_xlsx_inspect\"" - Observe recursion escaping toward volume root; stderr may show
\CursorData,\Program Files,\System Volume Information.
Safer contrast: cd to a parent above the target first; path without trailing \ before closing ".
Expected Behavior
- Block recursive deletes (
rmdir /s,Remove-Item -Recurse,rm -rf) when cwd is inside the delete target. - Normalize Windows paths so trailing
\before"cannot widen delete scope. - Hard-deny recursive deletes of volume roots / sensitive trees (
D:\,\System Volume Information). - Abort and surface hard failure if stderr shows paths outside the declared target (do not treat as “temp busy”).
Ask: Treat as P0 Agent Shell safety on Windows, not user error. Please harden Shell path handling + cwd-vs-target checks + outside-target stderr abort for recursive deletes.
Operating System
Windows 10/11
Version Information
Version: 3.13.25 (user setup)
VS Code Extension API: 1.128.0
Commit: 31e8d61c448c7472e371505838a0fe34083dad50
Date: 2026-07-28T06:17:45.069Z
Layout: IDE
Build Type: Stable
Release Track: Default
Electron: 40.10.3
Chromium: 144.0.7559.236
Node.js: 24.15.0
V8: 14.4.258.32-electron.0
xterm.js: 6.1.0-beta.256
OS: Windows_NT x64 10.0.22621
For AI issues: which model did you use?
Grok 4.5 High (cursor-grok-4.5-high), Task subagent + Shell
For AI issues: add Request ID with privacy disabled
21363e0a-106d-4eb3-be2b-1d2ce262f9e6
Additional Information
USN ~210201 FILE_DELETE in ~40s. Terminal 618164, subagent e51e8558-…, parent 848c746d-…. Attachments after post: proof_rmdir_peak.txt, main_log_watcher_1958.txt
Request IDs (Share Data enabled):
- Primary subagent run (~19:51 Omsk / 13:51 UTC): 21363e0a-106d-4eb3-be2b-1d2ce262f9e6
- Tool-call window at rmdir start (~19:58:11 Omsk / 13:58:11 UTC): bacf250d-bff4-49e3-88c7-f405b64d63b0
- Subagent completion right after wipe (~19:58:55 Omsk / 13:58:55 UTC): d09dcf84-5df4-4899-96d4-21ea4057902c
Local correlation IDs:
- Parent chat: 848c746d-a51a-4aa7-8940-557828b9067a
- Subagent (composer): e51e8558-3f0b-4dab-9eca-e7374d8c1140
- Terminal session: 618164 (pid 33664)
Does this stop you from using Cursor
Yes - Cursor is unusable