Skip to content

fix(security): validate external links in the main process - #3755

Merged
setchy merged 2 commits into
mainfrom
fix/validate-external-links
Dec 1, 2026
Merged

setchy merged 2 commits into
mainfrom
fix/validate-external-links

Conversation

@setchy

@setchy setchy commented Nov 30, 2026 •

Copy link
Copy Markdown
Member

Summary

  • Validate OPEN_EXTERNAL IPC payloads in the main process and pass only parsed HTTP(S) URLs to shell.openExternal.
  • Extract URL validation into a reusable sanitizeExternalUrl() util in src/main/utils.ts.
  • Reject URLs with embedded credentials (https://user:pass@host) or an empty hostname, in addition to unsupported schemes.
  • Preserve the foreground/background preference and plain HTTP support for self-hosted forges.
  • Handle browser-launch failures without logging the URL.
  • Add regression tests for allowed and rejected URLs, malformed payloads, and browser-launch failures.

Addresses SonarCloud finding AaGwmIFxnXzPJD976klB (tssecurity:S5144).

Validation

  • Targeted main-process tests: 42 passed (src/main/utils.test.ts, src/main/handlers/system.test.ts).
  • vp check passed for changed files (format, lint, types).
  • SonarCloud verification is pending CI.

@setchy
setchy requested a review from afonsojramos as a code owner November 30, 2026 22:05
@github-actions github-actions Bot added the bug Something isn't working label Nov 30, 2026
Extract external URL validation into a sanitizeExternalUrl util so it can be unit tested and reused. Reject URLs with embedded credentials or an empty hostname in addition to non-HTTP(S) schemes.
@setchy
setchy force-pushed the fix/validate-external-links branch from 4f220e8 to c8b059c Compare December 1, 2026 03:59
@sonarqubecloud

sonarqubecloud Bot commented Dec 1, 2026

Copy link
Copy Markdown

@setchy
setchy merged commit 5fd9286 into main Dec 1, 2026
20 checks passed
@setchy
setchy deleted the fix/validate-external-links branch December 1, 2026 04:28
@github-actions github-actions Bot added this to the Release 8.3.1 milestone Dec 1, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working

Development

Successfully merging this pull request may close these issues.

1 participant