Skip to content

Fix command injection in open_web via shell=True - #3

Merged
gensyn merged 4 commits into
mainfrom
copilot/fix-code-review-suggestion
May 20, 2026
Merged

gensyn merged 4 commits into
mainfrom
copilot/fix-code-review-suggestion

Conversation

Copilot AI commented May 20, 2026 •

Copy link
Copy Markdown

open_web passed a shell-interpolated URL string to subprocess.Popen with shell=True, allowing shell metacharacters in URLs sourced from store metadata to execute arbitrary commands.

Changes

  • open_web: Replaced run_command(f"xdg-open {url}") with a direct subprocess.Popen call using an argv list, eliminating shell interpretation of the URL entirely.
  • Flatpak: flatpak-spawn --host is prepended as discrete argv elements rather than concatenated into a shell string.
# Before — URL interpolated into a shell command
run_command(f"xdg-open {url}")  # shell=True, metacharacters execute

# After — URL passed as a literal argv element
argv = ["xdg-open", url]
if is_flatpak():
    argv = ["flatpak-spawn", "--host"] + argv
subprocess.Popen(argv, ...)  # no shell, no injection surface

Copilot AI changed the title [WIP] Fix code based on review comment Fix command injection in open_web via shell=True May 20, 2026
Copilot finished work on behalf of gensyn May 20, 2026 07:20
Copilot AI requested a review from gensyn May 20, 2026 07:20
Copilot finished work on behalf of gensyn May 20, 2026 07:25
Copilot finished work on behalf of gensyn May 20, 2026 07:29
@gensyn
gensyn marked this pull request as ready for review May 20, 2026 07:50
Copilot AI review requested due to automatic review settings May 20, 2026 07:50

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR removes a command-injection path in open_web by eliminating shell=True execution and passing URLs to xdg-open as a literal argv element (with Flatpak support via flatpak-spawn --host).

Changes:

  • Reworked open_web to use subprocess.Popen([...]) (argv list) instead of shell-interpolated command strings.
  • Removed the generic run_command helper and updated the onboarding support button to call open_web directly.

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated 1 comment.

File Description
src/windows/Onboarding/OnboardingWindow.py Switches the support link handler from run_command(...) to open_web(...) and removes now-unused imports.
src/backend/DeckManagement/HelperMethods.py Removes run_command and updates open_web to launch xdg-open (and flatpak-spawn --host) without shell interpretation.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread src/backend/DeckManagement/HelperMethods.py Outdated
@gensyn

gensyn commented May 20, 2026

Copy link
Copy Markdown
Owner

@copilot I fixed the issue you found - please redo your review.

Copilot AI commented May 20, 2026

Copy link
Copy Markdown
Author

@copilot I fixed the issue you found - please redo your review.

Re-reviewed the current PR state; the launcher path now stays shell-free and missing launcher binaries are handled gracefully in open_web, so I don’t see additional issues at this point. Verified at commit dbb72a5.

Copilot finished work on behalf of gensyn May 20, 2026 08:05
@gensyn
gensyn merged commit 5a119f6 into main May 20, 2026
1 check passed
@gensyn
gensyn deleted the copilot/fix-code-review-suggestion branch May 20, 2026 08:06
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.

3 participants