Skip to content

refactor(connection): simplify WSL relay trust to install location plus in-distro ownership - #1991

Merged
larroy merged 3 commits into
openclaw:mainfrom
shanselman:shanselman/simplify-wsl-relay-trust
Nov 4, 2026
Merged

larroy merged 3 commits into
openclaw:mainfrom
shanselman:shanselman/simplify-wsl-relay-trust

Conversation

@shanselman

@shanselman shanselman commented Nov 3, 2026 •

Copy link
Copy Markdown
Collaborator

Related: #1934 (fix: verify WSL relay via MSIX package trust, reject WindowsApps nesting spoofs, and warn when relay trust is unproven).

What Problem This Solves

Managed WSL Gateway connections can be rejected when a genuine relay is unsigned or installed outside the usual locations.

User Impact

User impact: an unsigned or nonstandard relay can be used when the expected distro's Gateway owns the guest port. A nonstandard path produces a logged warning and provenance detail, not a blocking error or a new visible banner.

Security tradeoff: this no longer authenticates the Windows relay. A local program named wslrelay.exe at a nonstandard path could be accepted while the expected WSL Gateway is listening and could receive a shared or bootstrap token. The maintainer explicitly accepted warning-only behavior with this risk documented.

Why This Change Was Made

This removes Authenticode verification, its package dependency, and the cached provenance handoff. Each handoff rechecks the Windows listener snapshot and expected guest-port owner. Interactive HTTP and dashboard handoffs require complete, consistent relay PID, start time, and path; relayless mirrored networking retains its empty-snapshot check. The guest check does not prove that the Windows listener forwards to that guest, and the earlier listener identity is no longer retained between checks.

Evidence

  • Connection tests cover warning-only acceptance, incomplete or inconsistent relay identities, listener changes during a check, and the relayless path.
  • An independent rubber-duck reviewed the final candidate and the proof plan; its identity checks must not be interpreted as relay authentication.
  • A full-branch P0-P3 shared source review was attempted but did not complete because the Codex review engine was unavailable. This is a review blocker, not a clean verdict.
  • An isolated real-WSL Gateway proof passed connection, dashboard credential handoff, and safe Gateway-to-node invocation. The fixture removed its own distro; default-profile Gateway registry and device identity fingerprints were unchanged.
  • The formal proof pool and nonstandard-path runtime proof remain unverified.

Change Type

  • Bug fix
  • Feature
  • Refactor
  • Docs or instructions
  • Tests or validation
  • Security hardening
  • Chore or infrastructure

Scope

  • Tray or WinUI UX
  • Windows node capability
  • Local MCP or winnode
  • Gateway, connection, or pairing
  • Setup or onboarding
  • Permissions, privacy, or security
  • Tests, CI, or docs

Required proof pools

  • windows-wsl-gateway-e2e: the changed gate applies to managed WSL connection and credential handoff.

Validation

  • .\build.ps1: all 5 builds passed.
  • dotnet test .\tests\OpenClaw.Shared.Tests\OpenClaw.Shared.Tests.csproj --no-restore --verbosity quiet: 4,810 passed, 24 skipped.
  • dotnet test .\tests\OpenClaw.Tray.Tests\OpenClaw.Tray.Tests.csproj --no-restore --verbosity quiet: 4,788 passed.
  • dotnet test .\tests\OpenClaw.Connection.Tests\OpenClaw.Connection.Tests.csproj --no-restore --verbosity quiet: 1,710 passed, 1 skipped.
  • With OPENCLAW_RUN_E2E=1, dotnet test .\tests\OpenClaw.E2ETests\OpenClaw.E2ETests.csproj --no-restore -r win-x64 --filter 'FullyQualifiedName~FullSetup_TrayConnects_OperatorAndNode|FullyQualifiedName~FullSetup_DashboardLink_UsesSharedGatewayTokenFragmentAfterPairing|FullyQualifiedName~FullSetup_SafeNodeInvocation_RoutesThroughRealGateway' --logger 'trx;LogFileName=relay-wsl-proof.trx' --results-directory <private-session-directory>: 3 passed, 0 skipped. The private output path is redacted here.
  • git diff --check: passed.

The test run used the final source before commit; its association with commit 3bba2ef9a60f1661070588e086f83658ca728632 was recorded manually. Inherited OPENCLAW_* overrides were cleared and tray data was isolated.

Real Behavior Proof

  • Environment tested: Windows x64, an isolated WSL Gateway distro, and an isolated Companion profile.
  • PR head or commit tested: 3bba2ef9a60f1661070588e086f83658ca728632.
  • Exact steps or command run: the isolated filtered E2E command in Validation.
  • Evidence after fix: operator and node connected; the dashboard shared-credential URL succeeded; a safe system.which command was invoked through the real Gateway.
  • Observed result: all 3 selected E2E tests passed. Separately, owner tests verified nonstandard-path acceptance and one deduplicated warning.
  • Screenshot or artifact links verified? N/A.
  • Not verified or blocked: the full windows-wsl-gateway-e2e pool on a clean-restorable host, a real nonstandard relay path, ARM64 unsigned-relay behavior, and the independent P0-P3 source review. The previous hosted UI job aborted after a testhost crash; its cause has not been established.

Security Impact

  • New permissions or capabilities? No.
  • Secrets or tokens handling changed? Yes.
  • New or changed network calls? No.
  • Command or tool execution surface changed? No.
  • Data access scope changed? No.
  • If any answer is Yes, explain the risk and mitigation: a spoofed nonstandard relay can receive shared or bootstrap credentials as described in User Impact. Guest ownership, complete listener capture, and handoff-time identity consistency reduce other failure modes but do not authenticate the relay.

Compatibility and Migration

  • Backward compatible? Yes, with the explicitly relaxed trust behavior above.
  • Config or environment changes? No.
  • Migration needed? No.
  • If yes, list the exact upgrade steps: N/A.

Review Conversations

  • I replied to or resolved every bot review conversation addressed by this PR.
  • I left unresolved only conversations that still need maintainer judgment.

…ownership proof

Drop the Authenticode check on wslrelay.exe (genuine WSL builds ship it unsigned)
and the cached strong-credential re-proof; handoff now reruns the full proof.
Pin the WindowsApps relay to Microsoft's WSL package root.

Co-authored-by: Copilot App <[email protected]>
@clawsweeper

clawsweeper Bot commented Nov 3, 2026 •

Copy link
Copy Markdown

🦞👀
ClawSweeper picked this up.

Pull request received. I will update this pull request when review starts.

ClawSweeper review complete

ClawSweeper finished reviewing this revision. The review result is being finalized.

View the workflow run.

@shanselman
shanselman requested a review from larroy November 3, 2026 19:57
@shanselman

Copy link
Copy Markdown
Collaborator Author

Hi @larroy! I'm a Copilot agent helping Scott with maintenance, not Scott himself. This PR goes the opposite way from #1934 (fix: verify WSL relay via MSIX package trust, reject WindowsApps nesting spoofs, and warn when relay trust is unproven): instead of adding package-trust verification, it drops the relay signature check entirely and relies on install location plus the expected distro's systemd MainPID owning the port. It also pins WindowsApps relays to the root of Microsoft's WSL package. Since you hit the unsigned WSL 2.6.3 ARM64 relay, would you be up for a review, and maybe a quick check on that machine? No pressure, and thank you.

@clawsweeper clawsweeper Bot added clawsweeper:intake:bug Preliminary submission classification; full source review pending. clawsweeper:intake:needs-repro Preliminary submission classification; full source review pending. P1 Urgent regression or broken agent/channel workflow affecting real users now. merge-risk: 🚨 security-boundary 🚨 Merging this PR could weaken sandboxing, authorization, credentials, or sensitive data. rating: 🧂 unranked krab Not merge-ready due to missing proof or serious correctness/safety concerns. status: 📣 needs proof The PR needs real behavior proof before ClawSweeper can clear the contributor ask. and removed clawsweeper:intake:bug Preliminary submission classification; full source review pending. clawsweeper:intake:needs-repro Preliminary submission classification; full source review pending. labels Nov 3, 2026
@clawsweeper

clawsweeper Bot commented Nov 3, 2026

Copy link
Copy Markdown

Codex review: needs real behavior proof before merge.

What this changes

This PR replaces WSL relay signature verification with install-location checks and replaces cached credential authorization with a fresh ownership proof.

Example: A managed Gateway uses an unsigned C:\Program Files\WSL\wslrelay.exe forwarding localhost:18789 to OpenClawGateway.

  • Before: The signature check rejects the relay even when the expected distro owns the Gateway port.
  • After: The install location and fresh distro ownership proof allow the connection.

Review scores

Measure Result What it means
Overall readiness 🧂 unranked krab (1/6) Useful and substantially simpler, but the identity regression blocks correctness and unit results do not establish the changed authority boundary.
Proof confidence 🧂 unranked krab (1/6) Real behavior proof is necessary before merge. See Before merge.
Patch quality 🦐 gold shrimp (3/6) Security review found an item that needs attention.

Product

Kind: Bug fix · Worth it: Yes · Fix scope: Complete
User problem: A genuine unsigned WSL relay prevents a managed local Gateway from being trusted during connection.
Reason: The compatibility failure has concrete supporting observations, and the collaborator-authored PR records the chosen simpler trust policy.

Merge readiness

⛔ Blocked before merge - 3 items remain

Keep open: this maintainer-authored PR addresses a supported unsigned-relay compatibility problem, but introduces a fail-closed identity regression.

Priority: P1
Reviewed head: 60c866d20962e7a2453f145f9d0e4fdd0fedeaf5

Before merge

  • Add real behavior proof - Authority-chain proof required: the body supplies unit/contract results for head 60c866d and explicitly records no live WSL Gateway or unsigned ARM64 run. Show the changed provenance service through the production credential resolver and request path: a genuine unsigned relay must receive an authenticated request, while an unrelated listener or listener replaced after successful guest proof receives no connection or token. Include partial-identity rejection and redact credentials, IPs and non-public endpoints. Related-PR screenshots and historical handoff traces do not exercise this changed head. After adding proof, update the PR body, then request a new review with @clawsweeper re-review. The PR author or someone with repository write access can request it.
  • Reject relay proofs with missing process start times (P2) - Replacing the old handoff gate with InspectCore drops its explicit ProcessStartTimeUtc requirement. WindowsTcpListenerSnapshot.ResolveProcess can populate name/path while independently catching a failed StartTime read. For localhost:18789, a canonical wslrelay with a null start time and successful guest ownership proof is classified ExpectedManagedGateway; two such snapshots compare equal because null equals null. The new gate therefore releases the shared/bootstrap credential for partially captured relay identity, whereas the base returns false. Preserve the non-null start-time requirement for relay-backed authorization and add a regression case without restricting the separate complete-empty relayless path.
  • Resolve security concern: Partial relay identity passes strong-credential authorization - Start-time identity distinguishes process generations during listener revalidation; accepting null on both sides removes that protection at the interactive credential boundary.

Findings

  • [P2] Reject relay proofs with missing process start times — src/OpenClaw.Connection/ManagedLocalGatewayPortProvenanceService.cs:300-302
  • [medium] Partial relay identity passes strong-credential authorization — src/OpenClaw.Connection/ManagedLocalGatewayPortProvenanceService.cs:302

Tests

  • Missing end-to-end proof: No current-head final-effect evidence shows unsigned-relay credential handoff succeeding while an unrelated or replaced listener receives no credentials, and no base-fail/head-pass run is supplied for the added path cases.
Agent review details

How this fits together

The connection provenance service combines Windows listener snapshots with expected-distro port ownership to authorize shared/bootstrap credentials and restrict local repair.

flowchart TD
  A[Gateway record and credential] --> B[Managed local provenance service]
  B --> C[Windows listener snapshots]
  B --> D[Relay install location]
  B --> E[Expected distro MainPID ownership]
  B --> F[Interactive credential authorizer]
  F --> G[Chat and Dashboard credential handoff]
Loading

Technical review

Best possible solution:

Keep the fresh proof in the existing provenance owner while preserving complete relay process identity and the distinct relayless exception.

Do we have a high-confidence way to reproduce the issue?

Current main rejects unsigned relay files through WindowsAuthenticodeVerifier, and the related ARM64 report establishes a genuine NotSigned relay; no runtime reproduction was performed during this read-only review.

Is this the best way to solve the issue?

Location-based trust is an explicitly chosen compatibility repair, and reusing InspectCore removes duplicate authorization machinery, provided its stronger handoff invariants are preserved.

Full review comments:

  • [P2] Reject relay proofs with missing process start times — src/OpenClaw.Connection/ManagedLocalGatewayPortProvenanceService.cs:300-302
    Replacing the old handoff gate with InspectCore drops its explicit ProcessStartTimeUtc requirement. WindowsTcpListenerSnapshot.ResolveProcess can populate name/path while independently catching a failed StartTime read. For localhost:18789, a canonical wslrelay with a null start time and successful guest ownership proof is classified ExpectedManagedGateway; two such snapshots compare equal because null equals null. The new gate therefore releases the shared/bootstrap credential for partially captured relay identity, whereas the base returns false. Preserve the non-null start-time requirement for relay-backed authorization and add a regression case without restricting the separate complete-empty relayless path.
    Confidence: 0.97

Overall correctness: patch is incorrect
Overall confidence: 0.95

AGENTS.md: found and applied where relevant.

Codex review notes: model internal, reasoning medium; reviewed against 598918ff8d7f.

Provenance checked

  • Relay signature verification and dependency changes intended behavior with a stated reason (6e225e4: Move existing Microsoft-signature verification from PowerShell into the process while retaining canonical-path checks.)
  • Cached interactive credential authorization changes intended behavior with a stated reason (bc210e0: Require proven managed-local listener ownership before releasing stronger credentials; later relayless support preserved the complete-identity requirement for relay-backed proofs.)
  • Post-probe listener recapture keeps the original intent (b65006a: Reject listener replacement during the expected-distro probe before returning a strong credential.)
  • Relayless ownership exception keeps the original intent (01faa64: Support mirrored WSL networking through complete empty Windows snapshots surrounding positive guest ownership proof.)

Testing

Proof path: unit tests only.

Security

Needs attention: The credential gate loses a process-identity safeguard, although no actual credential disclosure was demonstrated.

Evidence

Security concerns:

  • [medium] Partial relay identity passes strong-credential authorization — src/OpenClaw.Connection/ManagedLocalGatewayPortProvenanceService.cs:302
    Start-time identity distinguishes process generations during listener revalidation; accepting null on both sides removes that protection at the interactive credential boundary.
    Confidence: 0.97

What I checked:

Likely related people:

  • Barbara Kudiess: Raw commit bc210e0 adds src/OpenClaw.Connection/ManagedLocalGatewayPortProvenanceService.cs:307 relative to its recorded parents. This identifies author metadata, not feature responsibility or a PR merger. (role: source-line author; confidence: high; commits: bc210e048aa9; files: src/OpenClaw.Connection/ManagedLocalGatewayPortProvenanceService.cs)
  • Scott Hanselman: Raw commit 01faa64 adds src/OpenClaw.Connection/ManagedLocalGatewayPortProvenanceService.cs:382 relative to its recorded parents. This identifies author metadata, not feature responsibility or a PR merger. (role: source-line author; confidence: high; commits: 01faa6419b42; files: src/OpenClaw.Connection/ManagedLocalGatewayPortProvenanceService.cs)
  • Sebastien Tardif: Raw commit b65006a adds tests/OpenClaw.Connection.Tests/ManagedLocalGatewayPortProvenanceServiceTests.cs:385 relative to its recorded parents. This identifies author metadata, not feature responsibility or a PR merger. (role: source-line author; confidence: high; commits: b65006a6984a; files: tests/OpenClaw.Connection.Tests/ManagedLocalGatewayPortProvenanceServiceTests.cs)
  • Vincent Koc: Raw commit 6e225e4 adds src/OpenClaw.Connection/ManagedLocalGatewayPortProvenanceService.cs:43 relative to its recorded parents. This identifies author metadata, not feature responsibility or a PR merger. (role: source-line author; confidence: high; commits: 6e225e4758e1; files: src/OpenClaw.Connection/ManagedLocalGatewayPortProvenanceService.cs)

Labels

Label changes:

  • add P1: The change addresses blocked managed WSL connections and modifies the gate protecting shared/bootstrap credentials.
  • add merge-risk: 🚨 security-boundary: The replacement authorization admits a partially captured relay identity that the base explicitly rejected; the author's accepted signature-removal tradeoff does not cover this regression.
  • add rating: 🧂 unranked krab: Overall readiness is 🧂 unranked krab; proof is 🧂 unranked krab and patch quality is 🦐 gold shrimp.
  • add status: 📣 needs proof: The PR needs real behavior proof before ClawSweeper can clear the contributor ask.

Label justifications:

  • P1: The change addresses blocked managed WSL connections and modifies the gate protecting shared/bootstrap credentials.
  • merge-risk: 🚨 security-boundary: The replacement authorization admits a partially captured relay identity that the base explicitly rejected; the author's accepted signature-removal tradeoff does not cover this regression.
  • rating: 🧂 unranked krab: Overall readiness is 🧂 unranked krab; proof is 🧂 unranked krab and patch quality is 🦐 gold shrimp.
  • status: 📣 needs proof: The PR needs real behavior proof before ClawSweeper can clear the contributor ask.

Rating scale

6/6 🦀 challenger crab · 5/6 🦞 diamond lobster · 4/6 🐚 platinum hermit · 3/6 🦐 gold shrimp · 2/6 🦪 silver shellfish · 1/6 🧂 unranked krab. Overall follows the weaker of proof and patch quality; ✨ marks media proof (a screenshot, video, or linked artifact) that directly shows the changed behavior.

Workflow

ClawSweeper edits this one comment on every review. Comment @clawsweeper re-review for a fresh review only. Repair and merge execution lanes are retired.

Reviewed November 3, 2026, 3:11 PM ET / 20:11 UTC.

@larroy larroy left a comment •

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

LGTM, but that means it won't accept WSL from random places, or not installed from store, no warning.

Suggestions:

  • Change the rejection to include the path and the allowed roots, e.g. WSL relay at '' is outside the trusted WSL install locations (Program Files\WSL, System32, or the Microsoft WSL package).
  • Add a test that the detail contains the path.
  • Leave the proper warning UX to #1934.

…tall locations

A wslrelay at a non-standard path is accepted when the expected distro
proves it owns the gateway port; the path and expected locations are
logged once and returned in provenance detail.

Co-authored-by: Copilot App <[email protected]>
@shanselman

Copy link
Copy Markdown
Collaborator Author

Hi @larroy, this is a Copilot agent helping with triage (not Scott). Thanks for the review. Following your suggestion, a84d573 relaxes the location check:

  • A wslrelay outside the standard WSL install locations is now accepted with a warning when the expected distro proves it owns the gateway port. The warning (logged once per path) and the provenance detail include the relay path and the expected locations.
  • With no distro proof, it is still rejected, and the detail still names the path.
  • Tests: added a warn-and-accept case and a no-proof reject case, and the location theory now asserts the path appears in the rejection detail. Docs are updated. The UI warning is left to fix: verify WSL relay via MSIX package trust, reject WindowsApps nesting spoofs, and warn when relay trust is unproven #1934 as you suggested.

Validation: build.ps1 passed. Tests: Connection 1702 passed (1 skipped), Shared 4810 passed (24 skipped), Tray 4788 passed.

Require a complete, consistent relay identity for interactive credential handoffs and document the warning-only trust tradeoff.

Co-authored-by: Copilot App <[email protected]>
@larroy

larroy commented Nov 4, 2026

Copy link
Copy Markdown
Collaborator

Agent is working on requested verification in N1X and will post results here in ETA 60 min

@larroy

larroy commented Nov 4, 2026

Copy link
Copy Markdown
Collaborator

Machine test of 3bba2ef9a60f1661070588e086f83658ca728632 (current PR head) on Windows ARM64 (build 28000, 26H1), WSL 3.0.3.0 arm64. Machine name, user name and profile paths are redacted.

Pool windows-wsl-gateway-e2e, command run-gateway-product-path (verbatim from the inventory): passed.

  • SetupAndConnectTests: 26 discovered, 26 executed, 26 passed, 0 failed, 0 skipped.
  • The run created a fresh OpenClawE2E-* distro, installed the Gateway CLI, paired operator and node through the tray, and routed system.which through the real Gateway. The tray connected over the leased wslrelay loopback port. The fixture distro was unregistered at teardown. The default Ubuntu distro is still present and stopped.
  • The evidence-summary.json run reported {"discovered":26,"executed":26,"passed":26,"failed":0,"skipped":0} with the two required env gates.
  • Host setup, since the testhost is win-x64 and this machine is ARM64:
    • A task-local x64 .NET 10 runtime in a temp dir via DOTNET_ROOT_X64.
    • OPENCLAW_E2E_TRAY_EXE pointing at the ARM64 tray.
    • An extra -r win-x64 tray build, because two ExternalLike_* tests resolve the tray through a different locator (IsolatedTrayInstance) that ignores the override.
  • A first run of this same command had 24 of 26 passing. The 2 failures were those ExternalLike_* tests ("Tray exe not found"). They passed after the x64 tray build.

Local validation:

  • validate-proof-pools.ps1 passed. git diff --check was clean.
  • build.ps1 passed (5 projects) once local untracked scratch .md files were moved aside. They made the docs link validator fail, which is unrelated to the PR.
  • OpenClaw.Shared.Tests: 4810 passed, 24 skipped, 0 failed.
  • OpenClaw.Connection.Tests: 1707 passed, 1 skipped, 3 failed:
    • StoreMigrationPackagePresenceTests.DeletedReceipt_WithoutStorePackage_ReportsNoMigration
    • 2x MigrationRecordTests.WindowsPowerShellChecker_UsesTheSameContract
  • OpenClaw.Tray.Tests: 4787 passed, 1 failed on rerun, BuildPrerequisiteTests.CheckOnly_UsesTheAppLocalRuntimeResolver. The first run had 2 failures, including OpenClawChatDataProviderTests.QueuedSend_InFlightAckWithoutLifecycle_RequeuesAndRetriesSameIdempotencyKey, which passed on rerun.
  • These failures are in migration, PowerShell, build-prerequisite and chat-queue areas. I did not compare them against origin/main, so I can't say whether they predate the PR. The PR's ManagedLocalGatewayPortProvenanceServiceTests were part of the Connection run and are not among the failures.

Relay on this machine: C:\Program Files\WSL\wslrelay.exe is 3.0.3.0 with a Valid Authenticode signature. The original unsigned 2.6.3 ARM64 relay does not reproduce here, and I did not downgrade WSL. The E2E run shows the tray accepting the real relay listener at the canonical location. A live unsigned or nonstandard-relay runtime check remains unverified. That path is covered only by the Connection unit tests.

Limits:

  • Pool clean-restorable-state is only approximated. There is no VM. The fixture isolates tray data in %TEMP% and removes its own distro.
  • Another process (a node gateway) was already listening on 18789. It was untouched and the E2E used its own leased port.
  • The independent P0-P3 source review was not part of this run.

@clawsweeper re-review

@larroy
larroy merged commit 6493970 into openclaw:main Nov 4, 2026
27 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

merge-risk: 🚨 security-boundary 🚨 Merging this PR could weaken sandboxing, authorization, credentials, or sensitive data. P1 Urgent regression or broken agent/channel workflow affecting real users now. rating: 🧂 unranked krab Not merge-ready due to missing proof or serious correctness/safety concerns. status: 📣 needs proof The PR needs real behavior proof before ClawSweeper can clear the contributor ask.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants