Skip to content

fix: prevent unsafe browser targets from issue tracker links - #2475

Merged
love-linger merged 1 commit into
sourcegit-scm:developfrom
ChiahongHong:unsafe-link
Jun 24, 2026
Merged

fix: prevent unsafe browser targets from issue tracker links#2475
love-linger merged 1 commit into
sourcegit-scm:developfrom
ChiahongHong:unsafe-link

Conversation

@ChiahongHong

Copy link
Copy Markdown
Contributor

This PR prevents repository-provided issue tracker links from being passed to the Windows command shell when opening them in a browser. Shared .issuetracker rules can turn commit text into clickable links, we now validate browser targets before opening them and only allows well-formed absolute http, https, and ftp URLs.

On Windows, browser targets are now opened with UseShellExecute instead of cmd /c start, which avoids command-line parsing of link text and prevents characters in a URL from being interpreted as shell syntax. Unsafe targets are blocked with a notification instead of being opened.

I know IsWellFormedUriString is a bit picky in some cases, but given the security concerns, this approach seems reasonable, and the common URL formats I’ve tested so far should work properly.

Before

A maliciously crafted .issuetracker rule could inject shell syntax into the generated browser target:

[issuetracker "Github ISSUE"]
	regex = "#(\\d+)"
	url = https://github.com/sourcegit-scm/sourcegit/issues/$1\\\" & calc.exe
unsafe_url.mp4

After

@love-linger love-linger self-assigned this Jun 24, 2026
@love-linger love-linger added the enhancement New feature or request label Jun 24, 2026
@love-linger
love-linger merged commit 7cce752 into sourcegit-scm:develop Jun 24, 2026
14 checks passed
@ChiahongHong
ChiahongHong deleted the unsafe-link branch June 24, 2026 03:23
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request

2 participants