Skip to content

fix(setup): keep WSL PATH scripts off the wsl.exe argv path - #1476

Merged
shanselman merged 3 commits into
openclaw:mainfrom
SebTardif:fix/f006-wsl-path-stdin
Sep 28, 2026
Merged

shanselman merged 3 commits into
openclaw:mainfrom
SebTardif:fix/f006-wsl-path-stdin

Conversation

@SebTardif

@SebTardif SebTardif commented Sep 23, 2026 •

Copy link
Copy Markdown
Contributor

What problem

Gateway install, uninstall, configuration, token minting, pairing approval, restart, and verification prepend the Linux OpenClaw paths with a script containing $PATH. When that script is passed through wsl.exe -- bash -c <script>, wsl.exe can expand shell variables before Bash starts and replace the Linux PATH.

Fix

All affected SetupEngine calls now pass PATH-bearing scripts through standard input with RunInWslAsync(..., inputViaStdin: true), which selects wsl.exe -- bash -s. The contributor regression test covers install, uninstall, configure, mint, operator and node approval, restart, approval drain, and wizard reload restoration. A source-shape closure test prevents new PATH-bearing RunInWslAsync calls from returning to argv transport.

Current head 72d0cbfdcf4979deca0368258aabc896b0c25854 preserves SebTardif's two contributor commits and adds a normal merge of current main. No force-push or replacement PR was used.

Required proof pools

  • windows-wsl-gateway-e2e: setup transport, bootstrap, pairing, restart, existing-service behavior, and verification changed.
  • windows-wsl-mxc: repository-required real Gateway to Windows node system.run closeout for gateway setup/connect changes.

Validation

Maintainer validation on 2026-09-28, exact head 72d0cbfdcf4979deca0368258aabc896b0c25854:

Command Result
.\build.ps1 Passed. All five projects and documentation validation, Debug win-x64.
dotnet test .\tests\OpenClaw.Shared.Tests\OpenClaw.Shared.Tests.csproj --no-restore 4,116 passed, 32 skipped, 0 failed; 4,148 total.
dotnet test .\tests\OpenClaw.Tray.Tests\OpenClaw.Tray.Tests.csproj --no-restore 3,154 passed, 0 skipped, 0 failed.
dotnet test .\tests\OpenClaw.SetupEngine.Tests\OpenClaw.SetupEngine.Tests.csproj --no-restore 1,201 passed, 1 skipped, 0 failed; 1,202 total. Includes WslPathPrefixScripts_UseStdinSoWslExeDoesNotExpandPath.
dotnet test .\tests\OpenClaw.Connection.Tests\OpenClaw.Connection.Tests.csproj --no-restore 1,120 passed, 1 skipped, 0 failed; 1,121 total.
$env:TEMP=$env:TMP='<task-owned D:\ path>'; $env:OPENCLAW_RUN_E2E='1'; .\scripts\Invoke-CiE2e.ps1 -Name setup-connect -Filter '<CI setup-connect filter>' 45 passed, 1 expected Ollama opt-in skip, 0 failed; 46 total. Both required MXC proofs and all three SSH ownership proofs passed.
$env:TEMP=$env:TMP='<task-owned D:\ path>'; .\scripts\validate-mxc-e2e.ps1 -NoBuild 17 passed, 0 skipped, 0 failed. MirroredWslSafeGatewayPort_IsListeningAndRecorded, real Gateway MXC execution, and protected tray-data write denial all passed.

The first fresh-worktree --no-restore attempts correctly failed because test assets were absent. Each test project was then explicitly built, and the counted --no-restore runs above were rerun sequentially. Two timeout-sensitive tests that failed only under four-suite parallel contention passed alone and in the final sequential full suites.

Environment: Windows x64, .NET SDK 10.0.401, WSL 2.9.13. Process-only TEMP and TMP pointed to a task-owned D:\OpenClawProof\... directory for WSL VHD creation. No global ACL or system setting changed. All task-owned E2E distros, temp state, and the auxiliary Azure Crabbox lease were removed after proof.

Real behavior proof

A disposable harness invoked the production OpenClaw.SetupEngine.CommandRunner against the local Ubuntu WSL distro with a PATH-bearing multi-line script and a unique marker. While the command was running, Windows process inspection observed only:

WSL_ARGV="wsl.exe" -d Ubuntu -- bash -s

The unique script marker was absent from wsl.exe argv. Product output was:

EXIT=0
PATH_HEAD=/tmp/openclaw-stdin-proof
SCRIPT_MARKER=OPENCLAW_STDIN_PROOF_5571738D
BASH_CMDLINE=bash -s

This directly proves that the production runner kept the script off the wsl.exe argv path, preserved the Linux PATH, preserved Bash variable expansion, and delivered the script to bash -s over stdin.

The current-head setup-connect shard then provisioned fresh isolated gateways through the real SetupEngine and validated install, configure, service start, bootstrap, operator and node pairing, existing-running-service recognition, gateway connection, Windows node capability propagation, and teardown. The changed environment-backed approval path succeeded through real setup, closing the concern that request IDs might be lost when expansion moved from Windows argv processing to Bash.

The strict MXC script selected real BaseContainer containment and completed all 17 tests without skips. Both required real Gateway to Windows node system.run proofs passed, including denial of a write to the isolated tray data directory.

Rubber-duck review found no blocking implementation issue after the live changed-path proof. It identified only non-blocking follow-ups outside this bounded fix: richer stdin command diagnostics, an architecture-ledger entry for the closure guard, and broader documentation cross-links.

No gateway credentials, setup codes, device identities, private settings, or secret-bearing artifacts are included in this proof.

Signed-off-by: Sebastien Tardif <SebTardif@ncf.ca>
@clawsweeper clawsweeper Bot added P2 Normal priority bug or improvement with limited blast radius. rating: 🦪 silver shellfish Thin PR readiness signal; proof, validation, or implementation needs work. status: 📣 needs proof The PR needs real behavior proof before ClawSweeper can clear the contributor ask. labels Sep 23, 2026
@clawsweeper

clawsweeper Bot commented Sep 23, 2026 •

Copy link
Copy Markdown

Codex review: needs maintainer review before merge. Reviewed September 28, 2026, 2:49 PM ET / 18:49 UTC (Revision 6).

ClawSweeper review

What this changes

The setup engine sends PATH-bearing Gateway install, configuration, pairing, restart, and verification scripts through WSL standard input and adds regression coverage.

Merge readiness

✅ Ready for maintainer review

This PR remains necessary: current main still sends PATH-bearing Gateway setup scripts through the WSL argv path. The earlier review gaps are addressed by the current patch and its current-head native proof, with no blocking defect identified.

Priority: P2
Reviewed head: 72d0cbfdcf4979deca0368258aabc896b0c25854

Review scores

Measure Result What it means
Overall readiness 🐚 platinum hermit (4/6) The focused transport patch has strong current-head native proof and regression coverage; the large source guard keeps overall patch quality at the normal good tier.
Proof confidence 🦞 diamond lobster (5/6) Sufficient (terminal): On the exact head, a native production CommandRunner invocation showed bash -s in wsl.exe argv with the script marker absent, while Ubuntu output showed the expected Linux PATH and marker. The PR body also records fresh setup, existing-service recognition, pairing, and a non-skipping MXC result; no stored-data contract changes are introduced.
Patch quality 🐚 platinum hermit (4/6) No actionable review findings were identified.

Verification

Check Result Evidence
Real behavior Verified Sufficient (terminal): On the exact head, a native production CommandRunner invocation showed bash -s in wsl.exe argv with the script marker absent, while Ubuntu output showed the expected Linux PATH and marker. The PR body also records fresh setup, existing-service recognition, pairing, and a non-skipping MXC result; no stored-data contract changes are introduced.
Evidence reviewed 8 items Current-main gap: Current main still invokes the Gateway configuration script without inputViaStdin, leaving the central PATH expansion problem unresolved.
Introduced repair: The pinned introduced diff converts the remaining configuration and wizard calls and other PATH-bearing setup calls to inputViaStdin.
Production transport: The existing runner selects bash -s and writes the script to standard input when inputViaStdin is true.
Findings None None.
Security None None.

How this fits together

The setup engine turns onboarding choices into commands for a Gateway running inside WSL. Those commands configure and start the Gateway, then support pairing and connection verification.

flowchart LR
  A[Onboarding choices] --> B[Setup engine]
  B --> C[Gateway scripts]
  C --> D[WSL standard input]
  D --> E[Linux Bash]
  E --> F[Gateway setup and pairing]
Loading

Before merge

None.

Agent review details

Security

None.

Review metrics

Metric Value Why it matters
Production and test delta production +23/-17 lines; tests +539 lines The production transport edit is small; most added code covers the regression and its source guard.

Root-cause cluster

Relationship: canonical
Canonical: #1476
Summary: The merged reload-mode repair covers one PATH-bearing setup command; this PR covers the remaining setup transport calls. The pairing-approval PR addresses a distinct authority problem.

Members:

Proposal only: this assessment does not dispatch repair, suppress jobs, mutate sibling items, close, or merge anything.

Technical review

Best possible solution:

Land the bounded stdin transport repair and retain the regression guard for future PATH-bearing setup calls.

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

Yes. Current-main source uses the unsafe argv path, and the repository documents a concrete WSL variable-expansion reproduction; this read-only review did not execute it.

Is this the best way to solve the issue?

Yes. The patch uses the runner’s existing stdin transport and covers the setup calls identified by maintainer review.

AGENTS.md: found and applied where relevant.

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

Labels

Label changes:

  • add proof: sufficient: Contributor real behavior proof is sufficient. On the exact head, a native production CommandRunner invocation showed bash -s in wsl.exe argv with the script marker absent, while Ubuntu output showed the expected Linux PATH and marker. The PR body also records fresh setup, existing-service recognition, pairing, and a non-skipping MXC result; no stored-data contract changes are introduced.
  • add rating: 🐚 platinum hermit: Overall readiness is 🐚 platinum hermit; proof is 🦞 diamond lobster and patch quality is 🐚 platinum hermit.
  • add status: 👀 ready for maintainer look: ClawSweeper has no concrete contributor-facing blocker left for this PR. Sufficient (terminal): On the exact head, a native production CommandRunner invocation showed bash -s in wsl.exe argv with the script marker absent, while Ubuntu output showed the expected Linux PATH and marker. The PR body also records fresh setup, existing-service recognition, pairing, and a non-skipping MXC result; no stored-data contract changes are introduced.
  • remove status: 📣 needs proof: Current PR status label is status: 👀 ready for maintainer look.
  • remove merge-risk: 🚨 compatibility: Current PR review selected no merge-risk labels.
  • remove rating: 🦐 gold shrimp: Current PR rating is rating: 🐚 platinum hermit, so this older rating label is no longer current.

Label justifications:

  • P2: This is a bounded setup reliability repair with no demonstrated emergency or broad current-user outage.
  • rating: 🐚 platinum hermit: Overall readiness is 🐚 platinum hermit; proof is 🦞 diamond lobster and patch quality is 🐚 platinum hermit.
  • status: 👀 ready for maintainer look: ClawSweeper has no concrete contributor-facing blocker left for this PR. Sufficient (terminal): On the exact head, a native production CommandRunner invocation showed bash -s in wsl.exe argv with the script marker absent, while Ubuntu output showed the expected Linux PATH and marker. The PR body also records fresh setup, existing-service recognition, pairing, and a non-skipping MXC result; no stored-data contract changes are introduced.
  • proof: sufficient: Contributor real behavior proof is sufficient. On the exact head, a native production CommandRunner invocation showed bash -s in wsl.exe argv with the script marker absent, while Ubuntu output showed the expected Linux PATH and marker. The PR body also records fresh setup, existing-service recognition, pairing, and a non-skipping MXC result; no stored-data contract changes are introduced.

Evidence

What I checked:

Likely related people:

  • Scott Hanselman: Suggested for follow-up; no historical authorship or introduction is verified. (role: unverified routing candidate; confidence: low)
  • karkarl: Suggested for follow-up; no historical authorship or introduction is verified. (role: unverified routing candidate; confidence: low)
  • Barbara Kudiess: Suggested for follow-up; no historical authorship or introduction is verified. (role: unverified routing candidate; confidence: low)
  • SebTardif: Suggested for follow-up; no historical authorship or introduction is verified. (role: unverified routing candidate; confidence: low)

Rating scale

Score Internal tier Crab rank Meaning
6/6 S 🦀 challenger crab Exceptional readiness
5/6 A 🦞 diamond lobster Very strong readiness
4/6 B 🐚 platinum hermit Good normal PR; ordinary maintainer review
3/6 C 🦐 gold shrimp Useful, but confidence is limited
2/6 D 🦪 silver shellfish Proof or implementation needs work
1/6 F 🧂 unranked krab Not merge-ready
N/A NA 🌊 off-meta tidepool Rating does not apply

Overall follows the weaker of proof and patch quality.
Shiny media proof means a screenshot, video, or linked artifact directly shows the changed behavior. Runtime, network, CSP, and security claims still need visible diagnostics.

Workflow

  • ClawSweeper keeps one durable marker-backed review comment per issue or PR.
  • Re-runs edit this comment so the latest verdict, findings, and automation markers stay together instead of adding duplicate bot comments.
  • A fresh review can be triggered by eligible @clawsweeper re-review comments, exact-item GitHub events, scheduled/background review runs, or manual workflow dispatch.
  • PR/issue authors and users with repository write access can comment @clawsweeper re-review or @clawsweeper re-run on an open PR or issue to request a fresh review only.
  • Maintainers can also comment @clawsweeper review to request a fresh review only.
  • Fresh-review commands do not start repair, autofix, rebase, CI repair, or automerge.
  • Maintainer-only repair and merge flows require explicit commands such as @clawsweeper autofix, @clawsweeper automerge, @clawsweeper fix ci, or @clawsweeper address review.
  • Maintainers can comment @clawsweeper explain to ask for more context, or @clawsweeper stop to stop active automation.

History

Review history (5 earlier review cycles)
  • reviewed 2026-09-23T02:24:08.010Z sha c5139ae :: needs real behavior proof before merge. :: none
  • reviewed 2026-09-23T16:40:52.329Z sha c5139ae :: needs real behavior proof before merge. :: none
  • reviewed 2026-09-23T17:08:03.034Z sha c5139ae :: needs real behavior proof before merge. :: none
  • reviewed 2026-09-23T20:19:23.203Z sha 7fa601b :: needs real behavior proof before merge. :: none
  • reviewed 2026-09-28T17:56:16.122Z sha 7fa601b :: needs real behavior proof before merge. :: none

@shanselman shanselman added the status: 🚢 actively landing A maintainer or agent is actively driving this item through implementation, validation, or merge. label Sep 23, 2026
@shanselman shanselman removed the status: 🚢 actively landing A maintainer or agent is actively driving this item through implementation, validation, or merge. label Sep 23, 2026
@clawsweeper clawsweeper Bot added rating: 🦐 gold shrimp Decent PR readiness signal, but merge confidence is limited. and removed rating: 🦪 silver shellfish Thin PR readiness signal; proof, validation, or implementation needs work. labels Sep 23, 2026
@karkarl

karkarl commented Sep 23, 2026

Copy link
Copy Markdown
Collaborator

Global triage: HOLD_FOR_AUTHOR. Take confidence 40%; recommendation confidence 90%; effort small; risk medium.

Reviewed exact head c5139ae42d27. The stdin approach matches docs/WSL_EXE_ARGV_PITFALL.md, but three PATH-bearing calls remain on the unsafe argv path: ConfigureGatewayStep.cs:82-92 and SetupWizardRunner.cs:109-114,640-660. The test covers only calls it exercises, so add a durable repo-wide guard. After completing the conversion, run windows-wsl-gateway-e2e and non-skipping validate-mxc-e2e.ps1. Current setup E2E passed with all six MXC tests skipped, so it does not satisfy that gate.

ConfigureGateway and the setup wizard still passed PATH scripts on the wsl.exe argv path. Those calls now use bash -s stdin, with a guard so a new argv PATH script fails the test.

Signed-off-by: Sebastien Tardif <SebTardif@ncf.ca>
@clawsweeper clawsweeper Bot added the merge-risk: 🚨 compatibility 🚨 Merging this PR could break existing users, config, migrations, defaults, or upgrades. label Sep 23, 2026
@shanselman shanselman added the status: 🚢 actively landing A maintainer or agent is actively driving this item through implementation, validation, or merge. label Sep 28, 2026
Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
Copilot-Session: 5571738d-2ca1-457c-8a27-6895b3a9e455
@shanselman

Copy link
Copy Markdown
Collaborator

@clawsweeper re-review

@clawsweeper

clawsweeper Bot commented Sep 28, 2026 •

Copy link
Copy Markdown

🦞👀
Exact review queued.

Re-review progress:

@clawsweeper clawsweeper Bot added proof: sufficient Contributor real behavior proof is sufficient. rating: 🐚 platinum hermit Good normal PR readiness with ordinary maintainer review expected. status: 👀 ready for maintainer look ClawSweeper has no concrete contributor-facing blocker left for this PR. and removed status: 📣 needs proof The PR needs real behavior proof before ClawSweeper can clear the contributor ask. merge-risk: 🚨 compatibility 🚨 Merging this PR could break existing users, config, migrations, defaults, or upgrades. rating: 🦐 gold shrimp Decent PR readiness signal, but merge confidence is limited. labels Sep 28, 2026
@shanselman
shanselman merged commit 373887b into openclaw:main Sep 28, 2026
57 of 62 checks passed
@shanselman shanselman removed the status: 🚢 actively landing A maintainer or agent is actively driving this item through implementation, validation, or merge. label Sep 28, 2026
@SebTardif
SebTardif deleted the fix/f006-wsl-path-stdin branch September 29, 2026 17:39
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

P2 Normal priority bug or improvement with limited blast radius. proof: sufficient Contributor real behavior proof is sufficient. rating: 🐚 platinum hermit Good normal PR readiness with ordinary maintainer review expected. status: 👀 ready for maintainer look ClawSweeper has no concrete contributor-facing blocker left for this PR.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants