Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                
Skip to content

Fix command injection risk in openBrowser#36

Open
ishaanxgupta wants to merge 1 commit intosupermemoryai:mainfrom
ishaanxgupta:ishaan/security
Open

Fix command injection risk in openBrowser#36
ishaanxgupta wants to merge 1 commit intosupermemoryai:mainfrom
ishaanxgupta:ishaan/security

Conversation

@ishaanxgupta
Copy link

Fixed a potential command injection vulnerability in src/lib/auth.js within the openBrowser function. Added a try-catch block to parse the provided url and verify that the protocol is exactly 'http:' or 'https:' before executing any commands to open it.
If left unfixed, execFile could potentially be exploited by passing a malicious URL or a URL with a dangerous protocol scheme (e.g., file://, javascript:, or specific shell-executable patterns), which could lead to arbitrary command execution on the user's machine (Windows explorer.exe, macOS open, or Linux xdg-open).

The fix uses the native JavaScript URL constructor to safely parse the provided URL string before attempting to open it in the browser. If parsing throws an error, or if the parsed URL’s protocol is anything other than http: or https:, the function immediately logs a warning with console.warn and returns early. This prevents invalid or unsupported URLs from being passed to execFile, reducing the risk of unexpected behavior and ensuring that no child process is launched unless the URL is well-formed and uses an allowed web protocol.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant