Skip to content

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

Draft
larroy wants to merge 5 commits into
openclaw:mainfrom
larroy:fix/wsl-relay-msix-trust
Draft

larroy wants to merge 5 commits into
openclaw:mainfrom
larroy:fix/wsl-relay-msix-trust

Conversation

@larroy

@larroy larroy commented Oct 30, 2026 •

Copy link
Copy Markdown
Collaborator

What Problem This Solves

Fixes three related problems with the managed-local WSL gateway trust check:

  • It failed closed on unsigned modern Store WSL wslrelay.exe.
  • It accepted a fake wslrelay.exe planted in a WSL-named folder nested inside another package's WindowsApps directory.
  • When relay binary trust stayed unproven but the managed distro confirmed the gateway, the only signal was a log line.

User Impact

User impact:

  • Genuine unsigned Store WSL (2.6.3+) relays connect instead of failing the relay trust check.
  • A nested WindowsApps spoof can no longer be treated as the expected managed gateway or receive the shared gateway credential.
  • When Windows cannot fully verify the relay but the WSL distro confirms the gateway, Settings > Connection shows a Warning banner with the verifier's reason. Before this change the only signal was a log line.

Why This Change Was Made

Modern Store WSL ships wslrelay.exe without a per-file Authenticode signature. To handle that, WindowsAuthenticodeVerifier gained a package-level fallback (commit 93a4d246, dual-reviewed). It grants trust when three conditions hold:

  1. The relay is at a canonical path.
  2. A matching Get-AppxPackage identity exists.
  3. The path ACL is admin-protected.

When that evidence is unavailable, the verifier returns a warning instead of failing, and the managed distro ownership probe must corroborate the gateway.

Nesting spoof (finding R1 of the advisory review). The original fallback checked only the relay's immediate parent directory name, so WindowsApps\Other.App_...\MicrosoftCorporationII.WindowsSubsystemForLinux_9__8wekyb3d8bbwe\wslrelay.exe passed. IsWslPackageRootRelay now accepts only {WindowsApps}\{WSL package directory}\wslrelay.exe: the WSL-named directory must be the package root, and the relay must sit directly in it. Review findings R2-R8 are intentionally not addressed here.

Visible warning. The warned state was previously detected by searching Detail for a log phrase. The verifier reason now travels as a typed field:

GatewayEndpointProvenance.RelayTrustWarning → EndpointCredentialAuthorization.RelayTrustWarning → GatewayConnectionSnapshot.ManagedRelayTrustWarning → ConnectionPagePlan.RelayTrustWarningDetail → the RelayTrustWarning InfoBar.

GatewayConnectionManager owns the warning's lifecycle:

  • Sets it: on connect and on node-only connect.
  • Refreshes it: on every allowed operator credential handoff. The refresh runs in the background, so the handshake never waits on the transition lock.
  • Clears it: at the start of each connect attempt, on disconnect, and when a later handoff is denied.

The copy is localized in all six locales.

Evidence

  • Nesting spoof, red/green: VerifyMicrosoftSignedFile_WslNamedDirectoryNestedInsideAnotherWindowsAppsPackage_IsRejected, with Protected and Unverifiable path evidence. On the unfixed verifier both cases returned IsTrusted=true; after the fix both are rejected.
  • Warning lifecycle, red/green: ManagedRelayTrustWarning_PublishesOnConnect_RefreshesOnHandoff_ClearsOnDisconnect runs for the device-token and shared-token credential paths. With the handoff observer removed, both cases time out.
  • Denied handoff, red/green: ManagedRelayTrustWarning_ClearsWhenLaterHandoffIsDenied times out when the clear-on-denied-handoff line is removed.
  • UI: the fixture app (synthetic Gateway, injected reason) shows the Warning InfoBar while connected and removes it after disconnect. See Real Behavior Proof.
  • Reviews:
    • An independent rubber-duck review (reviewer agent) of the warning commit 66e0c475 found one P2: the banner went stale after a denied handoff. It also found one P3: ASCII punctuation in the zh-cn/zh-tw copy. Both are fixed in 9521eec1.
    • A separate rubber-duck review of the R1 commit found no defects.
  • Not exercised: no malicious installed package, other-user attack or credential disclosure was demonstrated. The verifier proof uses synthetic paths with injected seams.

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-winui-interactive: the Warning InfoBar on Settings > Connection.
    • Partially proven with the isolated fixture app and an injected reason (see Real Behavior Proof).
    • The real managed-WSL data path into the banner is not yet shown on screen.
  • windows-wsl-gateway-e2e: a real managed-WSL connection where the genuine verifier returns Warned.
    • Not yet proven; no host with that condition is available.

Validation

On head 9521eec1 (native ARM64 Windows 11, OPENCLAW_REPO_ROOT set):

  • pwsh -NoProfile -File ./build.ps1: all projects built (Shared, Cli, WinNodeCli, SetupEngine, WinUI).
  • dotnet test tests/OpenClaw.Shared.Tests/OpenClaw.Shared.Tests.csproj: 4810 passed, 0 failed, 24 skipped.
  • dotnet test tests/OpenClaw.Tray.Tests/OpenClaw.Tray.Tests.csproj: 4799 passed, 0 failed. This includes LocalizationValidationTests: key parity, {0} placeholder parity, XAML x:Uid resources, and all-or-none translation.
  • dotnet test tests/OpenClaw.Connection.Tests/OpenClaw.Connection.Tests.csproj: 1716 passed, 3 failed, 1 skipped.
    • The 3 failures are StoreMigrationPackagePresenceTests.DeletedReceipt_WithoutStorePackage_ReportsNoMigration and two MigrationRecordTests.WindowsPowerShellChecker_UsesTheSameContract cases.
    • They were earlier reproduced with this branch's changes stashed, and they don't use code changed here.
  • Focused: --filter "FullyQualifiedName~ManagedRelayTrustWarning": 3 passed, 0 failed.
  • dotnet test tests/OpenClaw.SetupEngine.Tests/OpenClaw.SetupEngine.Tests.csproj (on 66e0c475): 2523 passed, 0 failed, 4 skipped.

Real Behavior Proof

  • Environment tested: native ARM64 Windows 11, branch fix/wsl-relay-msix-trust, isolated fixture Gateway scripts/run-gateway-fixture.ps1 with a disposable profile.
  • PR head or commit tested:
    • UI proof: the source of 9521eec1 plus a temporary, uncommitted injection. In the non-managed branch of AuthorizeCredentialForEndpointAsync, the injection read the reason from an environment variable. It was reverted before commit; the committed diff contains no injection.
    • Verifier proof: 5308ab1b.
  • Exact steps or command run:
    1. Launched the fixture app with the injection variable set.
    2. Ran winnode --mcp-url <fixture> --command app.navigate --params '{"page":"connection"}'.
    3. Read the RelayTrustWarning element through UI Automation and captured the window.
    4. Toggled ConnectionToggle off through UI Automation and captured again.
  • Evidence after fix:
    • While connected, UI Automation found RelayTrustWarning on screen with:
      • Title: "WSL relay could not be verified"
      • Message: "Windows could not fully verify the WSL relay (wslrelay.exe) that forwards this gateway connection. OpenClaw connected because the managed WSL distro confirmed it owns the gateway port. Reason: proof injection: no installed WSL package could corroborate the relay"
      • Strip headline: "Connected"
    • After disconnect, the element is gone from the tree and the headline is "Not connected".
  • Observed result: the banner renders under the connection header while connected and collapses on disconnect. Nested WindowsApps spoof paths are rejected with "not owned by the WSL package family".
  • Screenshot or artifact links verified? No. The two window captures (relay-warning-warned.png, relay-warning-disconnect.png) exist only locally and are not yet attached here.
  • Not verified or blocked:
    • The real verifier Warned path into the banner was not exercised, because this host has no managed WSL gateway. The fixture injection bypasses ManagedLocalGatewayPortProvenanceService, which is covered by unit tests only.
    • No real WSL relay handshake, malicious installed package, other-user attack or AppContainer loopback attack was exercised.
    • The migration-script test failures above are unrelated to this change.

Security Impact

  • New permissions or capabilities? No
  • Secrets or tokens handling changed? No
  • 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: n/a.
    • This tightens an existing trust gate: fewer paths qualify as WSL-owned.
    • The new banner displays only the verifier's diagnostic reason. That text can include the local relay path, but no credential material.
    • The reason is not added to telemetry or diagnostics exports.

Compatibility and Migration

  • Backward compatible? Yes. Genuine layouts are unchanged: the relay directly under the WSL package root, Program Files\WSL, and System32. New record and snapshot fields are optional and default to null.
  • 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.

@clawsweeper

clawsweeper Bot commented Oct 30, 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.

@clawsweeper clawsweeper Bot added clawsweeper:intake:bug 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. labels Oct 30, 2026
@clawsweeper

clawsweeper Bot commented Oct 30, 2026 •

Copy link
Copy Markdown

Codex review: needs real behavior proof before merge.

What this changes

This PR adds fallback trust for unsigned WSL relays, rejects nested WindowsApps spoof paths, and displays relay-trust warnings in Connection settings.

Example: An unsigned C:\Program Files\WSL\wslrelay.exe owns port 18789 and the managed distro confirms its gateway.

  • Before: The failed file-signature check prevents shared or bootstrap credential authorization.
  • After: Package and filesystem evidence can authorize the relay, with a visible warning when verification remains incomplete.

Review scores

Measure Result What it means
Overall readiness 🧂 unranked krab (1/6) Useful compatibility work with verified fixture UI evidence, but the outstanding security defect and absent final-effect authority evidence prevent merge readiness.
Proof confidence 🧂 unranked krab (1/6) Real behavior proof is necessary before merge. See Before merge.
Patch quality 🦪 silver shellfish (2/6) Security review found an item that needs attention.

Product

Kind: Bug fix · Worth it: Yes · Fix scope: Complete
User problem: Some genuine unsigned WSL relays prevent managed-local connection, and incomplete relay verification otherwise lacks a visible explanation.
Reason: The compatibility report is supported by host diagnostics, and the collaborator-authored PR records the intended fallback direction; that decision does not excuse the concrete trust-gate defect.

Merge readiness

⛔ Blocked before merge - 5 items remain

Keep open: this maintainer-authored PR addresses a documented compatibility failure, but the prior trust-gate defect remains and the warning can incorrectly report connection success.

Priority: P1
Reviewed head: 9521eec103676f6948e67122e51b1c9fb151d993

Before merge

  • Add real behavior proof - Authority-chain proof required: the inspected screenshots demonstrate banner rendering and clearing in the real fixture app, and the author reports a direct verifier call against an unsigned ARM64 relay, but neither exercises the changed trust decision through credential-bearing dispatch. Supply redacted current-head output showing an allowed unsigned relay receives an authorized dummy-credential request, a writable or unverifiable decoy receives no credential-bearing I/O, and cached listener replacement invalidates authorization before dispatch; include the managed-WSL warning path. Redact credentials, IPs, and non-public endpoints. 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.
  • Check path protection before returning any usable package warning (P1) - The previous P1 finding remains: when package lookup returns null, identity mismatches, or SignatureKind is None, the fallback returns Warned before InspectProtectedRelayPath executes. An unsigned canonical relay on a user-writable or redirected path therefore bypasses the rejection that the later Unprotected branch would enforce. Warned sets IsTrusted=true, so a positive managed-distro probe promotes this listener to ExpectedManagedGateway and allows shared/bootstrap credential handoff. Inspect the path before every usable fallback and reject definitive writable or reparse-point evidence regardless of package lookup outcome.
  • Avoid claiming connection success from a warned preflight (P2) - A warned preflight stores ManagedRelayTrustWarning before ConnectRequested and emits it while the handshake is still pending. ConnectionPagePlan copies it without checking connection state, and ordinary authentication failure, pairing-pending, or transport-error transitions retain it. For example, a managed relay with a wrong shared token leaves the banner saying "OpenClaw connected" beside the connection failure. Project state-appropriate wording or show the success claim only after an authenticated connection, with coverage for unsuccessful handshakes.
  • Give the relay trust warning a useful next action (P3) - The new non-dismissible security warning explains incomplete verification and displays a technical reason, but gives the user no action or guidance about continuing. The supplied screenshot demonstrates this exact state. Add a supported next step or explicit continuation guidance in the native resource, updating all six locales together, so users can respond without interpreting verifier internals.
  • Resolve security concern: Package lookup failure bypasses rejection of modifiable relay paths - The same distro can legitimately own its guest port while an unrelated Windows listener intercepts loopback traffic; guest ownership alone does not authorize that Windows process to receive strong credentials.

Findings

  • [P1] Check path protection before returning any usable package warning — src/OpenClaw.Connection/WindowsAuthenticodeVerifier.cs:234-241
  • [P2] Avoid claiming connection success from a warned preflight — src/OpenClaw.Tray.WinUI/Pages/ConnectionPagePlan.cs:231-233
  • [P3] Give the relay trust warning a useful next action — src/OpenClaw.Tray.WinUI/Strings/en-us/Resources.resw:6147-6148
  • [high] Package lookup failure bypasses rejection of modifiable relay paths — src/OpenClaw.Connection/WindowsAuthenticodeVerifier.cs:240

Tests

  • Missing end-to-end proof: Missing current-head managed-WSL credential-dispatch evidence for allowed and forbidden relay owners, ownership replacement, and upgrade from the latest stable release with existing gateway settings intact.
Agent review details

How this fits together

The connection layer combines Windows listener identity, executable trust, and managed-distro ownership to authorize credential handoffs; its snapshot also drives the Connection page.

flowchart TD
  A[Windows listener snapshot] --> B[Relay trust verifier]
  C[Managed distro ownership] --> D[Endpoint provenance]
  B --> D
  D --> E[Connection manager]
  E --> F[Credential bearing handshake]
  E --> G[Connection warning banner]
Loading

Technical review

Best possible solution:

Keep the existing trust owners, reject writable or redirected paths before every fallback, and render state-accurate warnings with clear next steps.

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

Source establishes that a null package result returns Warned before an Unprotected path inspection could run; positive distro ownership then permits strong-credential authorization, but no exploit or target code was executed during this review.

Is this the best way to solve the issue?

The existing verifier, provenance service, manager snapshot, and page projection are appropriate owners, but the fallback must preserve path protection independently of package lookup and the warning must distinguish preflight from connection success.

Full review comments:

  • [P1] Check path protection before returning any usable package warning — src/OpenClaw.Connection/WindowsAuthenticodeVerifier.cs:234-241
    The previous P1 finding remains: when package lookup returns null, identity mismatches, or SignatureKind is None, the fallback returns Warned before InspectProtectedRelayPath executes. An unsigned canonical relay on a user-writable or redirected path therefore bypasses the rejection that the later Unprotected branch would enforce. Warned sets IsTrusted=true, so a positive managed-distro probe promotes this listener to ExpectedManagedGateway and allows shared/bootstrap credential handoff. Inspect the path before every usable fallback and reject definitive writable or reparse-point evidence regardless of package lookup outcome.
    Confidence: 0.99
  • [P2] Avoid claiming connection success from a warned preflight — src/OpenClaw.Tray.WinUI/Pages/ConnectionPagePlan.cs:231-233
    A warned preflight stores ManagedRelayTrustWarning before ConnectRequested and emits it while the handshake is still pending. ConnectionPagePlan copies it without checking connection state, and ordinary authentication failure, pairing-pending, or transport-error transitions retain it. For example, a managed relay with a wrong shared token leaves the banner saying "OpenClaw connected" beside the connection failure. Project state-appropriate wording or show the success claim only after an authenticated connection, with coverage for unsuccessful handshakes.
    Confidence: 0.98
  • [P3] Give the relay trust warning a useful next action — src/OpenClaw.Tray.WinUI/Strings/en-us/Resources.resw:6147-6148
    The new non-dismissible security warning explains incomplete verification and displays a technical reason, but gives the user no action or guidance about continuing. The supplied screenshot demonstrates this exact state. Add a supported next step or explicit continuation guidance in the native resource, updating all six locales together, so users can respond without interpreting verifier internals.
    Confidence: 0.96

Overall correctness: patch is incorrect
Overall confidence: 0.98

AGENTS.md: found and applied where relevant.

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

Provenance checked

  • Relay signature requirement changes intended behavior with a stated reason (6e225e4: Moved relay signature verification in process while retaining SignedAndTrusted Microsoft file identity; the later discussion at fix(connection): bind WSL relay trust to installed package #1201 (comment) explicitly defended that credential-boundary invariant.)
  • Managed-local ownership and credential gating changes intended behavior with a stated reason (bc210e0: Require positively established listener ownership before stronger credentials or remediation, with relayless ownership extended by 01faa64.)
  • Connection lifecycle ownership keeps the original intent (d67ef51: Keep GatewayConnectionManager as the overall state-machine and operator-lifecycle owner while extracting focused coordinators.)
  • Connection page projection and application keeps the original intent (672aadc: Use a pure page projection with WinUI state applied by the page rather than moving connection ownership into UI code.)

Testing

Proof path: shipped entry point.

Security

Needs attention: Usable warning results can bypass filesystem protection at the strong-credential boundary.

Evidence

Security concerns:

  • [high] Package lookup failure bypasses rejection of modifiable relay paths — src/OpenClaw.Connection/WindowsAuthenticodeVerifier.cs:240
    The same distro can legitimately own its guest port while an unrelated Windows listener intercepts loopback traffic; guest ownership alone does not authorize that Windows process to receive strong credentials.
    Confidence: 0.99

What I checked:

Likely related people:

  • Vincent Koc: Raw commit 6e225e4 adds src/OpenClaw.Connection/WindowsAuthenticodeVerifier.cs:25 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/WindowsAuthenticodeVerifier.cs)
  • Barbara Kudiess: Raw commit bc210e0 adds src/OpenClaw.Connection/ManagedLocalGatewayPortProvenanceService.cs:549 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:327 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)

Review metrics

Metric Value Why it matters
Introduced change size Production +754/-28; tests +405/-3; docs +2/-2 Most production growth implements package lookup and filesystem protection inside the existing verifier; the tests cover distinct trust and warning-lifecycle boundaries.

Labels

Label changes:

  • add proof: 📸 screenshot: Contributor real behavior proof includes screenshot evidence.

Label justifications:

  • P1: The changed trust gate can authorize strong credentials without evaluating whether the relay path permits untrusted modification.
  • merge-risk: 🚨 security-boundary: The fallback changes which loopback listener may receive shared or bootstrap credentials.
  • rating: 🧂 unranked krab: Overall readiness is 🧂 unranked krab; proof is 🧂 unranked krab and patch quality is 🦪 silver shellfish.
  • status: 📣 needs proof: The PR needs real behavior proof before ClawSweeper can clear the contributor ask.
  • proof: 📸 screenshot: Contributor real behavior proof includes screenshot evidence.

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.

History

Review history (1 earlier review cycle)
  • reviewed 2026-10-30T05:00:31.474Z sha 5308ab1 :: needs real behavior proof before merge. :: [P1] [P1] Check path protection before accepting package warnings

Reviewed November 3, 2026, 1:13 PM ET / 18:13 UTC (Revision 2).

@larroy
larroy marked this pull request as draft October 30, 2026 05:19
Store WSL 2.6.3+ ships wslrelay.exe without embedded Authenticode
signatures, so relay trust now accepts either a valid embedded Microsoft
signature or MSIX package verification: canonical relay path, matching
Get-AppxPackage family/publisher identity, and an admin-protected path
ACL. A canonical relay that proves neither degrades to a warned result
that still requires positive expected-distro systemd MainPID ownership;
non-canonical and ACL-violating paths still fail closed. This unblocks
setup pair-operator on machines where the unsigned Store relay was
rejected and the whole pipeline rolled back.
…tory

The WSL relay package fallback accepted any wslrelay.exe whose immediate parent directory was named like the WSL package family, so a WSL-named folder nested inside another package's WindowsApps directory passed ownership checks. Validate the actual package root: only {WindowsApps}\{WSL package directory}\wslrelay.exe is treated as WSL-owned; deeper nesting is rejected with the existing not-owned-by-family message. Adds a regression theory covering the nested spoof with Protected and Unverifiable path evidence.
Adds a file header explaining the dual trust paths (embedded Microsoft Authenticode signature or the WSL MSIX package fallback for unsigned wslrelay.exe), the warning/rejection semantics, and an example of VerifyMicrosoftSignedFile with each AuthenticodeTrustResult outcome.
Carry the verifier reason as GatewayEndpointProvenance.RelayTrustWarning
(replacing string matching), through EndpointCredentialAuthorization into
GatewayConnectionSnapshot.ManagedRelayTrustWarning. The manager publishes it
on connect/node-only connect, refreshes it on operator credential handoff,
and clears it on disconnect. ConnectionPage renders a Warning InfoBar with
localized copy plus the reason in all six locales.
@larroy
larroy force-pushed the fix/wsl-relay-msix-trust branch from 8a409c3 to 66e0c47 Compare November 2, 2026 19:56
@larroy
larroy requested a review from shanselman November 2, 2026 19:57
@larroy

larroy commented Nov 2, 2026

Copy link
Copy Markdown
Collaborator Author

Update: Connection page warning for unverified WSL relay trust (66e0c475)

The branch was rebased onto origin/main (a4dd026c) and adds one commit, 66e0c475 (feat: show Connection page warning when WSL relay trust is unverified). The PR description above still covers only R1; this comment covers the new commit.

Behavior

Before: when wslrelay.exe binary trust stayed unproven but the managed distro confirmed the gateway, the connection proceeded and the only signal was a [GatewayPort] log warning, matched by searching Detail for the text "binary trust is unproven".

After: the verifier reason travels as a typed field: GatewayEndpointProvenance.RelayTrustWarning → EndpointCredentialAuthorization.RelayTrustWarning → GatewayConnectionSnapshot.ManagedRelayTrustWarning → ConnectionPagePlan.RelayTrustWarningDetail. Settings > Connection then shows a Warning InfoBar (AutomationId RelayTrustWarning) with localized copy plus the untranslated reason, in all six locales.

  • GatewayConnectionManager sets the warning on connect and on node-only connect, and refreshes it on every operator credential handoff. The refresh runs in the background and takes the transition lock, so the handshake is never blocked.
  • It clears the warning on disconnect and at the start of each new connect attempt.
  • The log line is unchanged.

Validation (head 66e0c475, native ARM64 Windows 11)

  • pwsh -NoProfile -File ./build.ps1: all 5 projects built.
  • dotnet test tests/OpenClaw.Shared.Tests: 4810 passed, 0 failed, 24 skipped.
  • dotnet test tests/OpenClaw.Tray.Tests: 4799 passed, 0 failed. This includes LocalizationValidationTests (key parity, {0} placeholder parity, XAML x:Uid resources, all-or-none translation).
  • dotnet test tests/OpenClaw.SetupEngine.Tests (with OPENCLAW_REPO_ROOT set): 2523 passed, 0 failed, 4 skipped.
  • dotnet test tests/OpenClaw.Connection.Tests: 1715 passed, 3 failed, 1 skipped. The 3 failures are the same migration-script tests listed in the PR description, which were shown there to fail with this branch's changes stashed (StoreMigrationPackagePresenceTests.DeletedReceipt_WithoutStorePackage_ReportsNoMigration and two MigrationRecordTests.WindowsPowerShellChecker_UsesTheSameContract cases). None of those tests use code changed here. I did not rerun them on a clean base after the rebase.

Real behavior proof (unit/integration level)

  • New theory GatewayConnectionManagerTests.ManagedRelayTrustWarning_PublishesOnConnect_RefreshesOnHandoff_ClearsOnDisconnect. It runs for identity.DeviceToken and record.SharedGatewayToken, which cover the non-strong and strong authorization branches. Each case checks four things: the warning appears after connect, clears after a handoff where the relay is proven, comes back after a warned handoff, and clears on disconnect.
    • Red: with the handoff observer removed, both cases failed with System.TimeoutException: Condition was not met before the timeout.
    • Green: with the observer restored, both cases pass.
    • This red/green ran before the rebase. After the rebase, the provenance and manager classes passed 266 of 266.
  • ManagedLocalGatewayPortProvenanceServiceTests now also asserts the typed field:
    • An unproven relay confirmed by the distro carries the exact verifier reason.
    • An unproven relay that the distro does not confirm (UnknownListener) and a proven relay both have RelayTrustWarning == null.

Still needs proof

  • windows-winui-interactive: a current-head screenshot of the Warning InfoBar in the isolated WinUI app, showing the title, the localized message and the reason, and showing the bar clearing after disconnect. Not captured: this host has no managed WSL gateway, so the warned state cannot occur here. Plan: on a host with a managed WSL gateway, add a temporary, uncommitted injection that makes WindowsManagedLocalGatewayPortPlatform.InspectWslRelayBinary return WslRelayTrustResult.Warned(...), run run-app-local.ps1 -Isolated, connect, capture, disconnect, capture, then revert.
  • windows-wsl-gateway-e2e: a real managed-WSL connection where the genuine verifier produces Warned, such as Store WSL whose package identity cannot be corroborated. Not reproduced; no host with that condition is available.
  • Independent rubber-duck review of 66e0c475, required before publication for UI and security changes: not yet performed.
  • PR description: it still describes R1 only. It needs updating to cover the UI warning, change Scope to include Tray/WinUI UX, and replace Required proof pools: none with the two pools above.

@shanselman shanselman self-assigned this Nov 2, 2026
@larroy

larroy commented Nov 2, 2026 •

Copy link
Copy Markdown
Collaborator Author

Note, this is from my X86-64 Machine, the latest comments are from my N1X ARM64.

C:\Users\pedro\devel>wsl --version
WSL version: 2.6.1.0
Kernel version: 6.6.87.2-1
WSLg version: 1.0.66
MSRDC version: 1.2.6353
Direct3D version: 1.611.1-81528511
DXCore version: 10.0.26100.1-240331-1435.ge-release
Windows version: 10.0.26100.9711




 ┌───────────────┬────────────────────────────────────────────────────────────────────┐
 │ Field         │ Value                                                              │
 ├───────────────┼────────────────────────────────────────────────────────────────────┤
 │ Status        │ Valid ("Signature verified.")                                      │
 ├───────────────┼────────────────────────────────────────────────────────────────────┤
 │ Type          │ Authenticode (the signature is inside the file itself)             │
 ├───────────────┼────────────────────────────────────────────────────────────────────┤
 │ Signer        │ CN=Microsoft Corporation, O=Microsoft Corporation, Redmond, WA, US │
 ├───────────────┼────────────────────────────────────────────────────────────────────┤
 │ Issuer        │ Microsoft Code Signing PCA 2011                                    │
 ├───────────────┼────────────────────────────────────────────────────────────────────┤
 │ Thumbprint    │ 3F56A45111684D454E231CFDC4DA5C8D370F9816                           │
 ├───────────────┼────────────────────────────────────────────────────────────────────┤
 │ Cert validity │ 2025-06-19 → 2026-06-17                                            │
 ├───────────────┼────────────────────────────────────────────────────────────────────┤
 │ Timestamp     │ Microsoft Time-Stamp Service                                       │
 └───────────────┴────────────────────────────────────────────────────────────────────┘

 - Expired certificate: the certificate ran out on 2026-06-17, before today's date. That doesn't make the signature invalid. It was timestamped when it was signed, so Windows still treats it as valid, which is why the status is Valid.
 - IsOSBinary: False: this is expected. WSL is installed as a separate app from the Store or MSI, not as part of Windows itself.

Screenshot 2026-11-02 123407

A denied operator handoff moved the connection to Error but kept the
banner claiming the distro confirmed the gateway. Also use full-width
punctuation in the zh-cn/zh-tw warning copy.
@larroy larroy changed the title fix: verify WSL relay via MSIX package trust and reject WindowsApps nesting spoofs fix: verify WSL relay via MSIX package trust, reject WindowsApps nesting spoofs, and warn when relay trust is unproven Nov 2, 2026
@larroy

larroy commented Nov 2, 2026

Copy link
Copy Markdown
Collaborator Author

Proof update (9521eec1)

Review fixes (commit 9521eec1)

The independent rubber-duck review (reviewer agent, read-only) of 66e0c475 found two issues:

  • P2: after a denied operator handoff, the banner stayed up next to the "unverified owner" error. Fixed: RecordOperatorCredentialHandoffFailureAsync now clears ManagedRelayTrustWarning.
    • New test ManagedRelayTrustWarning_ClearsWhenLaterHandoffIsDenied.
    • Red: with the clear line removed, it fails with TimeoutException. Green: with the line restored, it passes.
  • P3: the zh-cn/zh-tw copy used ASCII punctuation. Fixed: it now uses full-width , and 原因:{0}.

The reviewer found no defects in the concurrency, disconnect/dispose race, stale-state or provenance paths.

UI proof (isolated fixture app, injected reason)

Method:

  • Ran scripts/run-gateway-fixture.ps1 with the current WinUI build.
  • Added a temporary injection that supplied a reason through the authorization result. It was reverted and was never committed.
  • Navigated with winnode --command app.navigate --params '{"page":"connection"}'.
  • Used UI Automation to read the RelayTrustWarning element and toggle ConnectionToggle.
State UI Automation reading
Connected RelayTrustWarning present, IsOffscreen=False. Title "WSL relay could not be verified". Message "Windows could not fully verify the WSL relay (wslrelay.exe) that forwards this gateway connection. OpenClaw connected because the managed WSL distro confirmed it owns the gateway port. Reason: proof injection: no installed WSL package could corroborate the relay". Headline "Connected".
After toggling off Element removed from the tree. Headline "Not connected".

The window captures for both states will be attached in a follow-up comment.

Validation on 9521eec1

Check Result
./build.ps1 all built
Shared 4810 passed / 0 failed / 24 skipped
Tray 4799 passed / 0 failed
Connection 1716 passed / 3 failed (the same migration-script tests as before) / 1 skipped

Still needs proof

  • windows-wsl-gateway-e2e: the genuine verifier Warned path on a real managed-WSL gateway. The fixture injection bypasses ManagedLocalGatewayPortProvenanceService, which is covered by unit tests only.
  • Banner screenshot via the real data path: run on a host with a managed WSL gateway, with the injection placed in InspectWslRelayBinary.
  • Screenshots: the two captures need to be attached to this PR.

@larroy

larroy commented Nov 2, 2026

Copy link
Copy Markdown
Collaborator Author

I think I might have had an older version of wsl even, because now I don't see the same problem

@larroy

larroy commented Nov 3, 2026 •

Copy link
Copy Markdown
Collaborator Author

I collected the proof in four parts: unit tests that fail without the fix, an independent code review, the full build and test suites, and screenshots of the banner in the real app. The screenshots used a faked reason, because this machine can't produce the warning for real.

  1. Unit tests (red/green)

For each new behaviour I ran the test, then temporarily removed the line that implements it and ran the test again:

┌───────────────────────────────────────────────────────────────────────────────────────────────────────────────────┬─────────────────────────────────────────────────────────────┬─────────────────────────┬────────────────┐
│ Test │ Line removed │ Result without the line │ Result with it │
├───────────────────────────────────────────────────────────────────────────────────────────────────────────────────┼─────────────────────────────────────────────────────────────┼─────────────────────────┼────────────────┤
│ ManagedRelayTrustWarning_PublishesOnConnect_RefreshesOnHandoff_ClearsOnDisconnect (device token and shared token) │ the callback that updates the warning on reconnect │ both cases timed out │ pass │
├───────────────────────────────────────────────────────────────────────────────────────────────────────────────────┼─────────────────────────────────────────────────────────────┼─────────────────────────┼────────────────┤
│ ManagedRelayTrustWarning_ClearsWhenLaterHandoffIsDenied │ the line that clears the warning when a reconnect is denied │ timed out │ pass │
└───────────────────────────────────────────────────────────────────────────────────────────────────────────────────┴─────────────────────────────────────────────────────────────┴─────────────────────────┴────────────────┘

These tests use the real GatewayConnectionManager with a fake endpoint probe that returns whatever provenance result the test sets. A red run shows the test actually checks the behaviour rather than passing regardless. The relay-check tests
(ManagedLocalGatewayPortProvenanceServiceTests) cover the real classification logic: the reason is filled only when an unverified relay is accepted, and is empty for a verified relay or a rejected listener.

  1. Independent review

I sent a separate read-only reviewer agent the commit diff and a list of things to check: deadlocks, stale state, privacy, UI and translations, and test quality. It found a stale-banner bug (P2) and wrong Chinese punctuation (P3). I fixed both, added the denied-handoff test
above, and confirmed it red/green.

  1. Build and test suites

On the final head 9521eec I ran ./build.ps1 and the Shared, Tray and Connection suites, reading the pass/fail counts from each run's output. On 66e0c47, before the review fixes, I also ran SetupEngine (all passed with OPENCLAW_REPO_ROOT set). The 3 Connection failures are
migration-script tests that don't use the changed code. They fail the same way whether or not OPENCLAW_REPO_ROOT is set. Before this change they were reproduced with the branch's changes stashed, as recorded in the PR description.

  1. UI proof

This machine has no managed WSL gateway, so the real "unverified relay" state can't happen here. So I:

  1. Injected the condition. I temporarily changed AuthorizeCredentialForEndpointAsync so that, for non-managed gateways, the result carries a reason read from an environment variable. This was never committed.
  • My first attempt named the variable OPENCLAW_PROOF_RELAY_WARNING. The fixture launcher strips every OPENCLAW_* variable before starting the app, so the banner never appeared. I renamed it to RELAYPROOF_WARNING and rebuilt.
  1. Ran the real app against the fixture Gateway. scripts/run-gateway-fixture.ps1 launches the current WinUI build with a throwaway profile and a synthetic Gateway on loopback. The app connected normally with the shared token.
  2. Navigated to Settings > Connection through the app's local MCP server with winnode --command app.navigate --params '{"page":"connection"}'.
  3. Read the screen through Windows UI Automation with a throwaway PowerShell script. It found the element with AutomationId RelayTrustWarning, confirmed it was on screen, and printed its title and message text. That text is what appears in the PR comment.
  4. Captured the window. The first method (copying from the screen) failed with "The handle is invalid", most likely because the desktop was locked. I switched to PrintWindow, which asks the window to draw itself into an image, and looked at the result to confirm the yellow
    banner was visible.
  5. Disconnected by flipping the ConnectionToggle switch through UI Automation. The banner disappeared from the accessibility tree and the headline changed to "Not connected". I captured a second screenshot.
  6. Cleaned up. I stopped the fixture, removed the injection, confirmed the diff had no trace of it, then rebuilt and reran the suites before committing.

What this does and doesn't prove

  • Proven by the screenshots: everything from the connection manager onward. That means connection state to page projection to banner, the translated text, and the banner clearing on disconnect.
  • Not proven on screen: the real path where ManagedLocalGatewayPortProvenanceService inspects an actual wslrelay.exe and gets a Warned result. The injection skipped that service, so it's covered only by unit tests. Showing it needs a machine with a managed WSL gateway.
relay-warning-disconnect relay-warning-warned

@larroy

larroy commented Nov 3, 2026 •

Copy link
Copy Markdown
Collaborator Author

@shanselman, a finding from the validation host that's relevant to the proof gaps listed above.

Validation host:

Property Value
OS Windows 11 Enterprise 26H1, version 10.0.28000, build 28000.3231
OS architecture ARM 64-bit (PROCESSOR_ARCHITECTURE=ARM64)
CPU NVIDIA RTX Spark N1X (18-core CPU, 5120-core GPU), 18 logical processors
RAM 33.2 GB

The host has an unsigned relay, and the current verifier trusts it outright.

Check Result
C:\Program Files\WSL\wslrelay.exe Authenticode NotSigned
C:\Windows\System32\wslrelay.exe not present
WSL package MicrosoftCorporationII.WindowsSubsystemForLinux 3.0.3.0 arm64, SignatureKind: Developer
wsl --version WSL 2.7.14.0

I loaded the built OpenClaw.Connection.dll and called WindowsAuthenticodeVerifier.VerifyMicrosoftSignedFile(@"C:\Program Files\WSL\wslrelay.exe") directly. It returned IsTrusted: True, IsWarning: False, with no detail.

  • The per-file Authenticode check fails, so the package-level fallback from 93a4d246 runs and passes. The relay is at the canonical path, the WSL package identity matches, and the path protection check passes.
  • The fallback warns only when the package's SignatureKind is None, the identity can't be confirmed, or path protection can't be inspected. A Developer signature kind isn't treated as unsigned.

What this means for this PR:

  • This unsigned relay is very likely what prompted the original fallback fix. Before 93a4d246 the check required a per-file Authenticode signature, so this relay would have failed it outright. I didn't check whether the log ever recorded that earlier failure.
  • It explains why the tray log on this host has no [GatewayPort] warning: with the fallback, the relay counts as trusted, not warned.
  • The windows-wsl-gateway-e2e gap remains even here. With a managed WSL gateway on this host, the genuine verifier would still return Trusted, so showing the banner through the real data path needs a host where package identity or path protection can't be confirmed.

@larroy

larroy commented Nov 3, 2026

Copy link
Copy Markdown
Collaborator Author

Explained for toddlers.

Why C:\Program Files\WSL\wslrelay.exe shows as unsigned on the validation host, and whether the WSL package signature covers it.

Short answer

No. wslrelay.exe has no signature of its own, and the WSL package's signature doesn't cover it either. The only signed thing in its history is the installer that put it there. That signature proves the installer came from Microsoft. It says nothing about the file sitting on disk today.

Like you're 5

Think of signatures as stickers that say "Microsoft made this, and nobody changed it."

  1. A sticker on each toy (file signature). Most WSL programs in C:\Program Files\WSL have their own Microsoft sticker: wsl.exe, wslservice.exe, wslhost.exe, wslg.exe. wslrelay.exe has no sticker: Windows reports NotSigned.
  2. A sticker on the toy box (package signature). The WSL Store package does have a Microsoft sticker on its box (AppxSignature.p7x). That sticker only covers what's inside the box, and this box is almost empty. It holds wsl.exe plus some paperwork (manifest, images, resources). wslrelay.exe isn't in the box, so the box sticker says nothing about it.
  3. A sticker on the delivery truck (installer signature). The real WSL programs arrived by a separate delivery truck, an MSI installer ("Windows Subsystem for Linux" 3.0.3.0). The truck has a valid Microsoft sticker. But once the truck unloads, its sticker stays on the truck. It doesn't prove the toy on your shelf today is the one the truck brought.

So nothing cryptographically vouches for wslrelay.exe right now.

What was observed on the host

Item What Windows reports
Program Files\WSL\wsl.exe, wslservice.exe, wslhost.exe, wslg.exe Valid Authenticode, signer Microsoft Corporation
Program Files\WSL\wslrelay.exe NotSigned (no embedded signature, no catalog signature)
System32\wsl.exe Valid, catalog-signed by Microsoft Windows
WSL MSIX package files AppxManifest.xml, AppxBlockMap.xml, AppxSignature.p7x, wsl.exe, Images, resources.pri, AppxMetadata; no wslrelay.exe
Package publisher / SignatureKind Microsoft Corporation / Developer
Installer that put files in Program Files\WSL MSI, Windows Subsystem for Linux 3.0.3.0, cached MSI signature Valid, Microsoft
wslrelay.exe owner NT AUTHORITY\SYSTEM
wslrelay.exe file version 2.6.3.0 (the installed product is 3.0.3.0)

Why it's unsigned

The host can't tell us why Microsoft left it unsigned. This part is inference: every other executable in the same folder is signed, so it looks like wslrelay.exe was missed by the WSL build's signing step rather than unsigned on purpose. That matches this PR's premise: Store WSL 2.6.3 and later ships wslrelay.exe unsigned.

There's also an oddity: the relay reports file version 2.6.3.0 while the installed product is 3.0.3.0. Either the relay binary wasn't rebuilt for 3.0.x, or its version stamp wasn't updated. I didn't confirm which.

What the OpenClaw verifier actually checks

The verifier's "package-level" fallback is not a cryptographic check of the file. It is evidence that the relay sits where only a real WSL install could put it:

  1. The relay is at a canonical path (Program Files\WSL, System32, or directly in the WSL package folder under WindowsApps).
  2. An installed WSL package with Microsoft's WSL family name and publisher exists, and its signature kind isn't None.
  3. Only admins or the system can modify the path: it is owned by TrustedInstaller, SYSTEM or Administrators, regular users have no write access, and there are no junctions or other reparse points.

On the host all three pass, so the result is Trusted. The reasoning is: an attacker who could write to C:\Program Files\WSL already has admin rights and could do worse. The trade-off is that a file swapped in by an admin, or by a compromised installer, would also pass. Only a real signature on wslrelay.exe would close that gap.

@larroy
larroy marked this pull request as ready for review November 3, 2026 18:06
@larroy

larroy commented Nov 3, 2026

Copy link
Copy Markdown
Collaborator Author

@clawsweeper re-review

@clawsweeper

clawsweeper Bot commented Nov 3, 2026 •

Copy link
Copy Markdown

🦞👀
Exact review queued.

Re-review progress:

@clawsweeper clawsweeper Bot added clawsweeper:intake:bug Preliminary submission classification; full source review pending. and removed clawsweeper:intake:bug Preliminary submission classification; full source review pending. labels Nov 3, 2026
@clawsweeper clawsweeper Bot added the proof: 📸 screenshot Contributor real behavior proof includes screenshot evidence. label Nov 3, 2026
@larroy
larroy marked this pull request as draft November 4, 2026 17:50
@shanselman

Copy link
Copy Markdown
Collaborator

Hi @larroy! I'm a Copilot triage agent helping Scott, not Scott himself.

Thanks again for reviewing and merging #1991 (refactor(connection): simplify WSL relay trust to install location plus in-distro ownership). Since that landed, a WSL relay outside the usual install folders is accepted with a log warning, and WindowsAuthenticodeVerifier.cs was removed. This PR builds on that file, so it now conflicts with main.

Is this PR still needed after #1991, or is it OK to close it? Totally your call, and no rush. We also have a small local draft of a Connection page warning banner. We're holding it for now, since the case is rare and #1991 already handles it without blocking.

@roboclaw-bot

Copy link
Copy Markdown
Contributor

PR cleanup review

Reviewed head: 9521eec103676f6948e67122e51b1c9fb151d993. Main comparison: e59374c064f43d68f5c72d070d4c89ef2d20ec3b.

Thanks for working through the unsigned WSL relay issue and documenting the tradeoffs. #1991 (refactor(connection): simplify WSL relay trust to install location plus in-distro ownership) now handles that compatibility case on main and removes the verifier this branch extends. I recommend closing this implementation rather than bringing the old verifier back. The Connection warning is still distinct work, not already shipped, and can be considered separately on current main if it is still useful. That follow-up should use state-accurate wording and prove the real managed-WSL path. This follows up on the existing November 8 closure question; no change has been made to your branch.

Action in this cleanup pass: leaving this PR open. No branch changes or runtime-proof waiver. The findings above come from source, discussion and recorded-CI review; Windows validation was not rerun in this pass.

@github-actions

Copy link
Copy Markdown
Contributor

This assigned pull request has been automatically marked as stale after being open for 27 days.
Please add an update or it will be closed.

@github-actions github-actions Bot added the stale label Nov 27, 2026

This branch has not been deployed

No deployments
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. proof: 📸 screenshot Contributor real behavior proof includes screenshot evidence. rating: 🧂 unranked krab Not merge-ready due to missing proof or serious correctness/safety concerns. stale 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.

3 participants