fix(cursor): reject desktop launcher forwarders#4371
fix(cursor): reject desktop launcher forwarders#4371christopheraaronhogg wants to merge 2 commits into
Conversation
|
Important Review skippedAuto reviews are disabled on this repository. Please check the settings in the CodeRabbit UI or the ⚙️ Run configurationConfiguration used: Repository UI Review profile: CHILL Plan: Pro Plus Run ID: You can disable this status message by setting the Use the checkbox below for a quick retry:
✨ Finishing Touches🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
There was a problem hiding this comment.
Cursor Bugbot has reviewed your changes using high effort and found 1 potential issue.
❌ Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, enable autofix in the Cursor dashboard.
Want fixes drafted automatically? Bugbot Autofix can create code changes for findings. A team admin can enable Autofix in the Cursor dashboard.
Reviewed by Cursor Bugbot for commit ad61bd0. Configure here.
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: ad61bd01e4
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
| } | ||
|
|
||
| export function isCursorDesktopAgentForwarderScript(script: string): boolean { | ||
| return /^[^\S\r\n]*(?!(?:#|::|rem(?:[^\S\r\n]|$)))(?:(?:exec|@?call|&)[^\S\r\n]+)?@?(?:"[^"\r\n]*[\\/]cursor(?:\.exe|\.cmd|\.bat)?"|cursor(?:\.exe|\.cmd|\.bat)?)[^\S\r\n]+agent(?:[^\S\r\n]|$)/im.test( |
There was a problem hiding this comment.
Match unquoted Cursor launcher paths
When a shim calls the desktop cursor binary through an unquoted path, such as exec /usr/local/bin/cursor agent "$@" or C:\...\cursor.exe agent %*, this pattern returns false because the unquoted branch only accepts the bare command name cursor. Those wrappers then fall through to runCursorAboutCommand, so provider refresh can still spawn the desktop launcher that this guard is intended to reject.
Useful? React with 👍 / 👎.
There was a problem hiding this comment.
Fixed in b1069cd. The detector now accepts unquoted POSIX and Windows paths; regression tests cover /usr/local/bin/cursor and C:\tools\cursor.exe.
ApprovabilityVerdict: Needs human review This PR introduces new validation logic that changes runtime behavior by rejecting certain Cursor configurations. An unresolved review comment questions whether the regex correctly handles all forwarder patterns, which warrants human verification. You can customize Macroscope's approvability policy. Learn more. |

What Changed
cursor agent, the desktop editor launcher.Why
Cursor's supported standalone command is
cursor-agent. A local shim such ascursor-agent.cmdcontainingcursor agent %*launches the desktop editor instead of ACP. T3's five-minute provider refresh then opens Cursor repeatedly and can leave expensive editor processes running.This is a follow-up safety guard to #4094 and covers the desktop-launcher failure mode reported in #2516. Correct standalone Cursor CLI binaries and ordinary wrappers remain unchanged.
Official CLI installation: https://cursor.com/docs/cli/installation
Verification
vp test run apps/server/src/provider/Layers/CursorProvider.test.ts -t 'rejects desktop forwarder|recognizes shell wrappers'vp lint apps/server/src/provider/Layers/CursorProvider.ts apps/server/src/provider/Layers/CursorProvider.test.ts --report-unused-disable-directivesvp fmt --check apps/server/src/provider/Layers/CursorProvider.ts apps/server/src/provider/Layers/CursorProvider.test.tsvp run --filter t3 typecheckThe full Cursor provider test file also runs 22/25 tests on native Windows; its three existing ACP fixture tests fail with
spawn EFTYPEbecause they execute.shwrappers directly. The new tests pass on native Windows.Checklist
Note
Low Risk
Scoped guard in Cursor provider status checks with file-size limits; legitimate standalone CLI binaries are unchanged.
Overview
Cursor provider health checks now block desktop-launcher shims so periodic refreshes no longer spawn wrappers that open the editor instead of ACP.
Before
agent about,checkCursorProviderStatusresolves the configured binary withresolveCommandPath, reads only small regular files (≤64 KiB), and usesisCursorDesktopAgentForwarderScriptto detect batch/shell scripts that forward tocursor agent. Matches returninstalled: false,status: "error", and a message pointing users to the standalonecursor-agentCLI—without executing the shim.Regression tests cover POSIX/Windows forwarder patterns, the script predicate (including commented lines), and a no-spawn assertion when a forwarder is configured.
Reviewed by Cursor Bugbot for commit b1069cd. Bugbot is set up for automated code reviews on this repo. Configure here.
Note
Reject desktop launcher forwarder scripts in
checkCursorProviderStatusisCursorDesktopAgentForwarderScriptto detect shell/batch wrappers that forward to thecursor agentdesktop launcher via a case-insensitive regex.checkCursorProviderStatusthat reads the configured binary, checks if it is a forwarder script, and returns an error probe withinstalled=falsewithout spawning any subprocess.Macroscope summarized b1069cd.