Skip to content

Harden the WASM version checker network boundaries - #1060

Merged
carldebilly merged 12 commits into
mainfrom
dev/cdb/repl
Apr 27, 2026
Merged

carldebilly merged 12 commits into
mainfrom
dev/cdb/repl

Conversation

@carldebilly

Copy link
Copy Markdown
Member

Summary
This PR hardens the Uno.Wasm.VersionChecker network model and closes a few remaining correctness gaps in the new Repl-based architecture.

It focuses on three areas:

  • blocking SSRF-style targets and private-network pivots
  • preventing cross-origin resolution from remote uno-config.js values
  • strengthening regression coverage around compression, BOM handling, Repl rendering, and target parsing

What changed

  • Added a dedicated network policy layer for the version checker core.
  • Rejected loopback, link-local, and private-network targets during target parsing.
  • Disabled automatic HTTP redirects in the default client.
  • Added connection-time IP validation through SocketsHttpHandler.ConnectCallback to reduce DNS-rebinding and redirect/pivot risks.
  • Enforced same-origin resolution for remote paths coming from uno-config.js, including uno_app_base, uno_remote_managedpath, dotnet_js_filename, and assembly paths.
  • Sanitized userinfo from parsed target URLs.
  • Simplified Uno.Wasm.VersionChecker.Core to net10.0 only.
  • Improved BOM handling for blazor.boot.json.
  • Tightened human-mode Repl assertions and added targeted regression tests for:
    • compressed dotnet.js
    • behavior without automatic decompression
    • private target rejection
    • cross-origin package-path rejection
    • UTF-8 BOM boot config parsing

Why
The tool now runs against remote, attacker-controlled deployments. Without stricter network boundaries, it could be used to:

  • inspect private/local endpoints directly
  • follow remote configuration into another origin
  • rely on redirects or rebinding to reach unintended hosts

This PR makes the version checker safer by default while keeping the current UX intact for valid public targets.

Validation

  • dotnet build src\\Uno.Wasm.VersionChecker\\Uno.Wasm.VersionChecker.csproj
  • dotnet test src\\Uno.Wasm.VersionChecker.UnitTests\\Uno.Wasm.VersionChecker.UnitTests.csproj

Current test result:

  • 41 tests passing

Notes

  • The test project now uses AwesomeAssertions and AwesomeAssertions.Analyzers.
  • Existing unrelated package-lock.json changes in the repo are not part of this PR.

Copilot AI review requested due to automatic review settings April 23, 2026 20:27

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 refactors Uno.Wasm.VersionChecker into a Repl-hosted CLI with a new Uno.Wasm.VersionChecker.Core library, and hardens outbound networking to reduce SSRF / pivot risk when inspecting attacker-controlled deployments.

Changes:

  • Introduces VersionCheckNetworkPolicy + VersionCheckHttp to constrain targets (public-only), disable redirects, and validate resolved IPs at connect time.
  • Replaces the legacy console flow (UnoVersionExtractor) with a Repl command host and structured Repl views.
  • Expands unit test coverage around target parsing, config parsing, compression/BOM handling, and Repl rendering.

Reviewed changes

Copilot reviewed 23 out of 23 changed files in this pull request and generated 4 comments.

Show a summary per file
File Description
src/Uno.Wasm.VersionChecker/VersionCheckerReplHost.cs New Repl host wiring + command routes and error handling.
src/Uno.Wasm.VersionChecker/VersionCheckReplViews.cs Structured view models for Repl rendering (inspection/summary/assemblies).
src/Uno.Wasm.VersionChecker/UnoVersionExtractor.cs Removes legacy extractor implementation.
src/Uno.Wasm.VersionChecker/Uno.Wasm.VersionChecker.csproj Switches to net10.0 single TFM, references Core, adds Repl package.
src/Uno.Wasm.VersionChecker/Program.cs Replaces legacy Main with top-level Repl host runner.
src/Uno.Wasm.VersionChecker.UnitTests/VersionCheckerTestAssets.cs Adds test helpers for real assembly bytes + WebCIL conversion input.
src/Uno.Wasm.VersionChecker.UnitTests/Uno.Wasm.VersionChecker.UnitTests.csproj Enables nullable, adds AwesomeAssertions (+ analyzers) and Newtonsoft.Json.
src/Uno.Wasm.VersionChecker.UnitTests/Given_VersionCheckTarget.cs New parsing/normalization/private-target rejection tests.
src/Uno.Wasm.VersionChecker.UnitTests/Given_VersionCheckService.cs New end-to-end inspection regression tests (compression/BOM/same-origin).
src/Uno.Wasm.VersionChecker.UnitTests/Given_ReplHost.cs New Repl host execution + JSON/human output assertions.
src/Uno.Wasm.VersionChecker.UnitTests/Given_ParseUnoConfigFields.cs Updates tests to Core parser and expands edge-case coverage.
src/Uno.Wasm.VersionChecker.UnitTests/Given_ExtractBootConfigFromScript.cs Updates/extends boot-config extraction tests.
src/Uno.Wasm.VersionChecker.UnitTests/Given_ExtractAssembliesFromResources.cs Updates tests to new resource extraction API.
src/Uno.Wasm.VersionChecker.UnitTests/Given_DotnetScriptCandidates.cs Adds candidate ordering/deduplication tests.
src/Uno.Wasm.VersionChecker.Core/VersionCheckTarget.cs Adds hardened target parsing (scheme restriction, userinfo stripping, public-only validation).
src/Uno.Wasm.VersionChecker.Core/VersionCheckService.cs New core inspection pipeline with resource/config parsing and safe URL resolution.
src/Uno.Wasm.VersionChecker.Core/VersionCheckNetworkPolicy.cs New same-origin enforcement + public-address checks.
src/Uno.Wasm.VersionChecker.Core/VersionCheckModels.cs New core models for reports/config.
src/Uno.Wasm.VersionChecker.Core/VersionCheckHttp.cs New default HttpClient (no redirects, decompression, connect-time IP allowlist).
src/Uno.Wasm.VersionChecker.Core/Uno.Wasm.VersionChecker.Core.csproj Adds Core library targeting net10.0 with dependencies.
src/Uno.Wasm.VersionChecker.Core/Internals.cs InternalsVisibleTo for unit tests.
src/Uno.Wasm.Bootstrap.sln Adds Core project to solution.
doc/features-version-checker.md Updates documentation for Repl-based UX and new example output.

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

Copilot AI review requested due to automatic review settings April 24, 2026 13:28

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

Copilot reviewed 25 out of 25 changed files in this pull request and generated 3 comments.


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

Copilot AI review requested due to automatic review settings April 24, 2026 14: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

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

Comments suppressed due to low confidence (1)

build/ci/stage-build-packages.yml:134

  • This job publishes build artifacts twice with the same ArtifactName (uno-wasm-bootstrap-drop) and the same PathtoPublish ($(build.artifactstagingdirectory)). In Azure DevOps this can be redundant at best and can fail due to duplicate artifact names at worst. Remove one of the PublishBuildArtifacts@1 tasks or give the second one a distinct ArtifactName/path if you intend to publish separate artifacts.
  - task: PublishBuildArtifacts@1
    condition: always()
    inputs:
      PathtoPublish: $(build.artifactstagingdirectory)
      ArtifactName: uno-wasm-bootstrap-drop
      ArtifactType: Container

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

Copilot AI review requested due to automatic review settings April 24, 2026 15:23

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

Copilot reviewed 29 out of 29 changed files in this pull request and generated 3 comments.


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

@carldebilly
carldebilly enabled auto-merge April 24, 2026 20:16
@carldebilly
carldebilly merged commit 817a4fe into main Apr 27, 2026
17 of 18 checks passed
@carldebilly
carldebilly deleted the dev/cdb/repl branch April 27, 2026 12:22
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