-
Notifications
You must be signed in to change notification settings - Fork 1.5k
Security: Validate Cursor deeplink URLs and use safer Windows API #2348
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Security: Validate Cursor deeplink URLs and use safer Windows API #2348
Conversation
- Add URL scheme validation to reject non-cursor:// URLs - Replace subprocess cmd.exe call with os.startfile() on Windows - Add tests for scheme validation and error handling
WalkthroughModified deeplink handler in cursor module to validate cursor scheme, replace subprocess with os.startfile for Windows, and expand error handling to OSError. Changes include new imports for os and urlparse. Changes
Poem
Pre-merge checks and finishing touches❌ Failed checks (1 warning)
✅ Passed checks (2 passed)
✨ Finishing touches
🧪 Generate unit tests (beta)
📜 Recent review detailsConfiguration used: CodeRabbit UI Review profile: ASSERTIVE Plan: Pro ⛔ Files ignored due to path filters (1)
📒 Files selected for processing (1)
🧰 Additional context used📓 Path-based instructions (2)src/**/*.py📄 CodeRabbit inference engine (AGENTS.md)
Files:
**/*.py📄 CodeRabbit inference engine (AGENTS.md)
Files:
🔇 Additional comments (4)
Comment |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@ColeMurray thank you for this PR!
Summary
The
open_deeplinkfunction in the Cursor CLI integration accepted arbitrary URLs without validation and usedcmd.exeon Windows to open them. This fix adds URL scheme validation and replaces the Windows subprocess call with a safer API.Changes
cursor://scheme before opening them. URLs with other schemes (http, https, file, etc.) are rejected.subprocess.run(["cmd", "/c", "start", ...])withos.startfile(), which is the standard Python API for opening files and URLs on Windows and doesn't involve shell interpretation.Why This Matters
The original implementation on Windows passed user-controlled input directly to
cmd.exe, which could potentially be exploited through command injection. While the actual attack surface depends on how deeplinks are constructed in practice, this defense-in-depth fix ensures that:cursor://URLs are processedThe fix maintains backward compatibility while improving security posture.