Skip to content

Harden Markdown URL validation - #19698

Merged
James Newton-King (JamesNK) merged 1 commit into
mainfrom
fix/markdown-url-validation
Aug 26, 2026
Merged

James Newton-King (JamesNK) merged 1 commit into
mainfrom
fix/markdown-url-validation

Conversation

@JamesNK

Copy link
Copy Markdown
Member

Description

Markdown links that System.Uri can't parse were previously left unclassified. Browsers and registered protocol handlers can accept URLs that System.Uri rejects, so an unparseable URL could still be rendered instead of being removed.

This change classifies unparseable URLs as prohibited. It adds regression coverage for encoded-newline URLs using both vscode and HTTP schemes.

Security considerations

This tightens the trust boundary for Markdown links: URLs must be successfully classified before they can be rendered. The change has not had a formal threat model or security review.

Validation:

MarkdownProcessorTests: 28 passed, 0 failed, 0 skipped

Fixes # (issue)

Checklist

  • Is this feature complete?
    • Yes. Ready to ship.
    • No. Follow-up changes expected.
  • Are you including unit tests for the changes and scenario tests if relevant?
    • Yes
    • No
  • Did you add public API?
    • Yes
      • If yes, did you have an API Review for it?
        • Yes
        • No
      • Did you add <remarks /> and <code /> elements on your triple slash comments?
        • Yes
        • No
    • No
  • Does the change make any security assumptions or guarantees?
    • Yes
      • If yes, have you done a threat model and had a security review?
        • Yes
        • No
    • No

Copilot AI balanced review requested due to automatic review settings August 26, 2026 01:07
@github-actions

Copy link
Copy Markdown
Contributor

🚀 Dogfood this PR with:

⚠️ WARNING: Do not do this without first carefully reviewing the code of this PR to satisfy yourself it is safe.

curl -fsSL https://raw.githubusercontent.com/microsoft/aspire/main/eng/scripts/get-aspire-cli-pr.sh | bash -s -- 19698

Or

  • Run remotely in PowerShell:
iex "& { $(irm https://raw.githubusercontent.com/microsoft/aspire/main/eng/scripts/get-aspire-cli-pr.ps1) } 19698"

@github-actions

Copy link
Copy Markdown
Contributor

Tests selector (audit mode)

The full test matrix and all jobs still run in audit mode. The tests and jobs below are what selective CI would run under enforcement.

8 / 102 test projects · 3 jobs, from 2 changed files.

Selected test projects (8 / 102)

Aspire.Cli.EndToEnd.Tests, Aspire.Dashboard.Components.Tests, Aspire.Dashboard.Tests, Aspire.Hosting.DotnetTool.Tests, Aspire.Hosting.RemoteHost.Tests, Aspire.Hosting.Testing.Tests, Aspire.Managed.Tests, Aspire.Playground.Tests

Selected jobs (3)

deployment-e2e, extension-e2e, polyglot


How these were chosen — grouped by what changed

🔧 src/Aspire.Dashboard/Model/Markdown/MarkdownHelpers.cs (changed source)
→ 6 via the project graph: Aspire.Dashboard.Components.Tests, Aspire.Hosting.DotnetTool.Tests (2 hops), Aspire.Hosting.RemoteHost.Tests (2 hops), Aspire.Hosting.Testing.Tests, Aspire.Managed.Tests (2 hops), Aspire.Playground.Tests (2 hops)

📦 affected project Aspire.Managed
→ 1 test: Aspire.Cli.EndToEnd.Tests

🧪 tests/Aspire.Dashboard.Tests/Markdown/MarkdownProcessorTests.cs (changed test)
→ 1 directly: Aspire.Dashboard.Tests

Job reasons

Job Triggered by
deployment-e2e affected project Aspire.Managed
extension-e2e • src/Aspire.Dashboard/Model/Markdown/MarkdownHelpers.cs
• affected project Aspire.Dashboard
polyglot affected project Aspire.Managed

Selection computed for commit 7601cec.

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Pull request overview

Hardens Dashboard Markdown rendering by prohibiting URLs that System.Uri cannot classify.

Changes:

  • Treats unparseable Markdown URLs as prohibited.
  • Adds regression tests for encoded-newline vscode and HTTP URLs.

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated no comments.

File Description
src/Aspire.Dashboard/Model/Markdown/MarkdownHelpers.cs Rejects URLs when URI parsing fails.
tests/Aspire.Dashboard.Tests/Markdown/MarkdownProcessorTests.cs Verifies malformed URLs have their targets removed.

💡 Add a code-review agent skill for context-aware, tailored reviews. Learn more in the docs.

@JamesNK
James Newton-King (JamesNK) merged commit b582f80 into main Aug 26, 2026
399 checks passed
@JamesNK
James Newton-King (JamesNK) deleted the fix/markdown-url-validation branch August 26, 2026 14:12
@github-actions github-actions Bot added this to the 13.6 milestone Aug 26, 2026
@aspire-repo-bot

Copy link
Copy Markdown
Contributor

✅ No documentation update needed.

Step 5 branch taken: docs_optional → internal_refactor

Triggered signals: none (signal_count = 0 in .pr-docs-check/signals.json)

Rationale: The PR only modifies src/Aspire.Dashboard/Model/Markdown/MarkdownHelpers.cs (internal Markdown link classification logic) and its test file tests/Aspire.Dashboard.Tests/Markdown/MarkdownProcessorTests.cs. It hardens the classification of unparseable URLs (treating them as prohibited rather than unclassified) to close a security gap where a browser/protocol handler could render a URL that System.Uri rejects. There is no new or changed public API, CLI option, configuration key, environment variable, or user-visible output/format — it's an internal defensive-coding fix to existing link-sanitization behavior in the dashboard. The PR body itself notes "Did you add public API? No" and provides no user-facing usage section. No documented user-facing behavior changes as a result of this fix, so no docs update is warranted.

@github-actions

Copy link
Copy Markdown
Contributor

⚠️ CI Failure Analysis: Possible Flaky Test(s)

The CI build failed due to test failure(s) that appear unrelated to the PR changes. These may be flaky tests.

Suspected flaky test(s):

Suggested actions:

  • Re-run the failed CI jobs to confirm if the failure is intermittent
  • If the test continues to fail, consider quarantining it using /quarantine-test <test name> <issue URL>
  • Search existing issues to see if this test is already known to be flaky

You can re-run the failed jobs from the workflow run page.

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

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants