Skip to content

fix(security): restrict external links to web URLs - #23

Merged
DysektAI merged 3 commits into
masterfrom
fix/external-link-safety
Jul 28, 2026
Merged

fix(security): restrict external links to web URLs#23
DysektAI merged 3 commits into
masterfrom
fix/external-link-safety

Conversation

@DysektAI

@DysektAI DysektAI commented Jul 27, 2026

Copy link
Copy Markdown
Member

What changed

  • add one ExternalLinkLauncher entry point that accepts only absolute HTTP(S) URLs
  • route surviving UI, logger, and WebView external-link launches through it
  • add regression coverage for executable paths, UNC paths, local files, custom protocols, malformed URLs, and valid web URLs

Why

Several link targets originate in remote catalog data and were passed directly to Windows ShellExecute. That permits non-web targets such as local executables, UNC paths, and registered protocol handlers to reach the shell.

Impact

Normal HTTP(S) links continue opening in the default browser. Unsafe or malformed targets are logged and ignored without taking down the WebView render path.

Validation

  • dotnet tool restore
  • dotnet csharpier check .
  • dotnet build RatScanner.sln --no-restore — 0 warnings, 0 errors
  • dotnet test RatScanner.sln --no-build --no-restore — 246 passed

Summary by cubic

Restricts external links to absolute HTTP(S) URLs and routes all opens through a safe ExternalLinkLauncher. Strengthens logging by redacting rejected targets and sanitizing accepted ones to prevent data leaks.

  • Bug Fixes
    • Added ExternalLinkLauncher with strict URL validation and safe open.
    • Routed UI, logger, and WebView link opens through the launcher.
    • Logging: redacts rejected targets as "" or ""; for accepted links removes credentials, queries, fragments, and control chars; omits exception details.
    • Tests cover URL filtering and log redaction for both rejected and accepted targets.

Written for commit cf2dbb8. Summary will update on new commits.

Review in cubic

@coderabbitai

coderabbitai Bot commented Jul 27, 2026

Copy link
Copy Markdown

Review Change Stack

📝 Walkthrough

Walkthrough

Changes

A shared ExternalLinkLauncher validates absolute HTTP(S) URLs, sanitizes warning targets, launches approved links through the shell, and suppresses failures. Logger, page, and hyperlink-navigation paths now delegate to it, with tests covering accepted, rejected, and failed launches.

External link safety

Layer / File(s) Summary
Launcher validation and tests
src/App/ExternalLinkLauncher.cs, tests/RatScanner.Tests/ExternalLinkLauncherTests.cs
Adds absolute HTTP(S) validation, sanitized warning handling, shell launching, and tests for safe, unsafe, malformed, missing, and failed launches.
Application link integration
src/App/Logger.cs, src/App/Pages/App/Credits.razor, src/App/Pages/App/Index.razor, src/App/View/BlazorUI.xaml.cs
Replaces direct process launches with ExternalLinkLauncher.Open across logger, page helpers, and hyperlink navigation.

Estimated code review effort: 3 (Moderate) | ~20 minutes

Sequence Diagram(s)

sequenceDiagram
  participant UI
  participant ExternalLinkLauncher
  participant Shell
  UI->>ExternalLinkLauncher: Open(url)
  ExternalLinkLauncher->>ExternalLinkLauncher: Validate absolute HTTP(S) URL
  ExternalLinkLauncher->>Shell: Start validated URL
Loading
🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 18.18% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
Title check ✅ Passed The title clearly captures the main change: restricting external links to safe web URLs.
Description check ✅ Passed The description matches the change set and accurately summarizes the safe-linking refactor and tests.
✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch fix/external-link-safety

Comment @coderabbitai help to get the list of available commands.

@codeant-ai

This comment was marked as resolved.

coderabbitai[bot]

This comment was marked as resolved.

@DysektAI
DysektAI marked this pull request as ready for review July 27, 2026 16:36
@cubic-dev-ai

This comment was marked as resolved.

devin-ai-integration[bot]

This comment was marked as resolved.

cubic-dev-ai[bot]

This comment was marked as resolved.

@DysektAI DysektAI self-assigned this Jul 28, 2026
@DysektAI
DysektAI merged commit e992893 into master Jul 28, 2026
15 checks passed
@DysektAI
DysektAI deleted the fix/external-link-safety branch July 28, 2026 02:50
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