fix(#118): validate URL scheme before calling shell.openExternal#137
fix(#118): validate URL scheme before calling shell.openExternal#137anshul23102 wants to merge 1 commit into
Conversation
…rnal Both the app:open-external IPC handler and the visualizer-action open-url path passed caller-supplied URLs directly to shell.openExternal without any scheme check. On Windows, registered custom protocols such as ms-settings:, ms-officecmd:, or search-ms: are handled by the OS shell, so a renderer that can invoke either path could silently launch arbitrary system applications or trigger OS actions. Added an ALLOWED_EXTERNAL_SCHEMES allowlist (https: and http:) checked inside openExternalUrl before the shell call. Strings that are not valid URLs or that use any other scheme return immediately without reaching shell.openExternal. All callers go through the same central function so the guard applies uniformly to both the IPC handler and the tray action path. Fixes SamXop123#118
|
@anshul23102 is attempting to deploy a commit to the Dot_NotSam's projects Team on Vercel. A member of the Team first needs to authorize it. |
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: defaults Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (1)
📝 WalkthroughWalkthroughThe pull request hardens the ChangesExternal URL Scheme Validation
Estimated code review effort🎯 2 (Simple) | ⏱️ ~8 minutes Poem
🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches🧪 Generate unit tests (beta)
Warning There were issues while running some tools. Please review the errors and either fix the tool's configuration or disable the tool if it's a critical failure. 🔧 ESLint
ESLint skipped: no ESLint configuration detected in root package.json. To enable, add 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 |
Summary
Both the
app:open-externalIPC handler and thevisualizer-actionopen-urlpath passed caller-supplied URLs directly toshell.openExternalwithout any scheme validation. On Windows, registered custom protocols such asms-settings:,ms-officecmd:, andsearch-ms:are dispatched to the OS shell, allowing a malicious or compromised renderer to silently launch arbitrary system applications or trigger privileged OS actions without user consent. Electron's own security documentation explicitly requires scheme validation before callingshell.openExternal.Closes #118
Root Cause
openExternalUrlcalledshell.openExternal(url)unconditionally.Fix
Added an
ALLOWED_EXTERNAL_SCHEMESallowlist (https:andhttp:) insideopenExternalUrl. The function parses the URL withnew URL()and returns early if the resulting protocol is not in the allowlist. Invalid URL strings (parse errors) also return early without reachingshell.openExternal. All callers go through the same central function so the guard applies uniformly.Files Changed
main.js: AddedALLOWED_EXTERNAL_SCHEMESconstant and scheme validation at the top ofopenExternalUrl.How to Test
window.paralineApp.openExternal('ms-settings:')should do nothing.window.paralineApp.openExternal('https://github.com')should open the browser as before.window.paralineApp.openExternal('javascript:alert(1)')should do nothing.Checklist
https:orhttp:URLs.Summary by CodeRabbit