Repository navigation
improve(setup): keep WSL operations inside the app-owned directory - #1006
Conversation
Validate distro names and canonical install paths before setup cleanup, installation, and rollback filesystem operations. Reject reparse-point ancestors and revalidate ownership before each recursive-delete retry. Co-authored-by: Copilot App <[email protected]> Copilot-Session: f19f98b7-f377-4da5-a7ce-0f1ae34153cf
Preserve the finalized WSL quoting ownership rows from openclaw#1001 and append the WSL distro install-path policy row. Co-authored-by: Copilot App <[email protected]> Copilot-Session: f19f98b7-f377-4da5-a7ce-0f1ae34153cf
|
Codex review: found issues before merge. Reviewed July 17, 2026, 8:53 PM ET / July 18, 2026, 00:53 UTC. Summary Reproducibility: yes. for the reported unsafe-path behavior: the new tests and current-head Dev Box proof exercise traversal rejection before distro-targeting and recursive-delete operations. The compatibility regression is source-reproducible because the new policy rejects any configured name outside its ASCII allowlist before cleanup begins. Review metrics: 2 noteworthy metrics.
Merge readiness Overall follows the weaker of proof and patch quality, so missing proof can cap an otherwise strong patch. Rank-up moves:
Risk before merge
Maintainer options:
Copy recommended automerge instructionNext step before merge
Maintainer decision needed
Security Review findings
Review detailsBest possible solution: Preserve already-safe custom distro names through canonical immediate-child containment and reparse-point checks, rejecting only names or paths that resolve outside the app-owned root; adopt the narrower name grammar only if maintainers explicitly choose that compatibility break and document an upgrade path. Do we have a high-confidence way to reproduce the issue? Yes for the reported unsafe-path behavior: the new tests and current-head Dev Box proof exercise traversal rejection before distro-targeting and recursive-delete operations. The compatibility regression is source-reproducible because the new policy rejects any configured name outside its ASCII allowlist before cleanup begins. Is this the best way to solve the issue? No, not yet: centralized canonical containment and reparse validation are the right safety mechanism, but an unconditional broad name allowlist is not the narrowest solution until maintainers approve breaking existing safe custom-name workflows. Full review comments:
Overall correctness: patch is incorrect AGENTS.md: found and applied where relevant. Codex review notes: model internal, reasoning high; reviewed against 4518dd87ed2b. Label changesLabel changes:
Label justifications:
Evidence reviewedWhat I checked:
Likely related people:
What the crustacean ranks mean
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. How this review workflow works
Review history (4 earlier review cycles)
|
|
Marking as draft until I can further test this tomorrow |
|
@clawsweeper re-review |
|
🦞🧹 I asked ClawSweeper to review this item again. Re-review progress:
|
The containment policy is well designed: canonical immediate-child checks, tight distro-name allowlisting, reparse-point ancestor rejection, retry-time revalidation, and real junction-based TOCTOU tests are strong. There is no existing repository path-policy utility that should replace this owner. The remaining merge blocker is compatibility for existing custom distro names. Previously accepted names containing spaces or non-ASCII characters can now fail before replacement, cleanup, rollback, or uninstall filesystem work. That can strand an existing managed installation even though the new-install policy is safer. Please choose and prove a migration contract:
Add integration-style tests for replacement and uninstall/rollback of a legacy custom-name distro, proving nothing outside the app-owned root is touched. Also add boundary coverage for exactly 64 vs 65 characters and a rollback test asserting invalid/traversal names fail closed without deleting external paths. The first-use TOCTOU limitation is documented and acceptable for this PR, but the legacy-name upgrade/uninstall path needs a concrete supported behavior before merge. |
Separate strict new-install naming from safe legacy teardown so existing managed distros can be removed without weakening path containment. Co-authored-by: Copilot App <[email protected]> Copilot-Session: f19f98b7-f377-4da5-a7ce-0f1ae34153cf
|
Caleb Eden + GitHub Copilot pair-programming follow-up @shanselman Thanks for flagging the legacy-installation compatibility gap. We implemented a strict-creation, safe-teardown contract at New distro creation retains the 1–64 character ASCII grammar. Uninstall and rollback accept older names containing spaces or Unicode only when the name is one unambiguous Windows path segment whose canonical path is an immediate child of the app-owned Setup now validates the creation contract before stale cleanup, so it cannot delete a legacy installation and then discover that its name cannot be recreated. The actionable recovery path is to rerun SetupEngine with Added coverage for:
Validation is green: full build; Shared tests with 2,864 passed and 31 skipped; Tray tests with 1,717 passed; SetupEngine tests with 471 passed; and 42 focused contract tests. A final Claude Opus + GPT Codex review found no actionable issues. |
Resolve the combined SetupEngine preflight flow by retaining distro path validation ahead of cleanup and incorporating the new Tailscale setup steps. Co-authored-by: Copilot App <[email protected]> Copilot-Session: f19f98b7-f377-4da5-a7ce-0f1ae34153cf
Co-authored-by: Copilot App <[email protected]> Copilot-Session: 675e4cf9-9a9b-4a46-b00f-ba5a78916e0a
Co-authored-by: Copilot App <[email protected]> Copilot-Session: 675e4cf9-9a9b-4a46-b00f-ba5a78916e0a
Resolve the concurrent exec-approval integration-test repair in favor of main's concrete-executable plus wildcard-arguments contract. Co-authored-by: Copilot App <[email protected]> Copilot-Session: 675e4cf9-9a9b-4a46-b00f-ba5a78916e0a
Final reviewed head: The containment/setup proof originally stamped at |
Additional instructions
MUST: Keep Allow edits from maintainers enabled for this PR so maintainers can help update the branch when needed.
What problem this solves
Standalone SetupEngine accepted custom WSL distro names when deriving cleanup and install paths. A traversal value such as
..\..could resolve outside%LOCALAPPDATA%\OpenClawTray\wsl, where cleanup performs recursive deletion.No known user incident prompted this change. The packaged application supplies its fixed distro name, so the exposed path is primarily the repository/developer SetupEngine flow.
Contract
All WSL distro install paths now go through
DistroInstallPathPolicy.LocalDataDir\wslroot.Setup validates the creation grammar before stale cleanup, so it cannot delete a legacy install and then discover that the same name cannot be recreated. To replace a legacy install, run SetupEngine with
--uninstall --confirm-destructiveand the same legacy name, then install with a supported name.The remaining same-user filesystem check-to-use race is an explicit residual risk; the available WSL and directory APIs do not provide a handle-based atomic install/delete boundary.
Main merges and conflict decisions
Current main was merged normally throughout landing preparation:
b7231a3dce639b8b14e2021d486829fe8facbe62in57426b8fbc84124614468e605e7f3260ac546a2e93b645c93d880c16b4e91c9f255d472c98452468in0c8e9c7695bcf46e277cb20e515c4c06ae23b3611810e357aa0d0639099b347f31c746ba7d31512ain309cef0bbcc3755ea6404428e0f78823a765f6e3ddad64031116f62fa00fdd392d61717f23393ab0in final merge63d457f92b0fffc8e5e64e479c67f668dda7ce9cThe first three merges were clean. The final merge had one conflict in a current-main integration test that both sides repaired concurrently. Resolution took main's stronger contract: a concrete executable with wildcard arguments (
marker + " *"). The resolved test passed locally, and the file has no diff against current main. No setup, cancellation, or credential conflict occurred.Behavioral coverage
Tests use real Windows filesystem behavior, including junctions and a case-sensitive directory. They cover:
wsl\with a junction while an outside sentinel remains intact;A required independent Claude Opus rubber-duck review found no blocking correctness or security issue and independently ran 59 focused containment/rollback tests successfully.
Change type
Scope
Validation
Validated at PR head
63d457f92b0fffc8e5e64e479c67f668dda7ce9cwithOPENCLAW_REPO_ROOTset to this isolated worktree:.\build.ps1— passed; Shared, CLI, WinNode CLI, SetupEngine, and WinUI builtdotnet test .\tests\OpenClaw.Shared.Tests\OpenClaw.Shared.Tests.csproj --no-restore— 3,021 passed, 31 skipped, 0 faileddotnet test .\tests\OpenClaw.Tray.Tests\OpenClaw.Tray.Tests.csproj --no-restore— 1,834 passed, 0 skipped, 0 faileddotnet test .\tests\OpenClaw.SetupEngine.Tests\OpenClaw.SetupEngine.Tests.csproj --no-restore— 697 passed, 0 skipped, 0 failedSystemExecApprovals_GetThenSet_PersistsRuleintegration test after conflict resolution — 1 passed, 0 failed.\scripts\validate-wsl-gateway.ps1 -Scenario PreflightOnly -NoBuild— passedgit diff --check— passedOpenClaw.Connectiondiff against current main.Final-head CI run
29788066538passed:test— passed in 11m24se2etests (setup-connect)— passed in 9m36se2etests (revocation-recovery)— passed in 8m37se2etests (network-recovery)— passed in 8m27sbuild (win-x64)— passed in 6m34sbuild (win-arm64)— passed in 6m56sReal behavior proof
Proof head:
63d457f92b0fffc8e5e64e479c67f668dda7ce9c.The final-head GitHub setup E2E shard passed the real disposable WSL setup/connect path. Revocation-recovery and network-recovery also passed on the same head. Together they cover production SetupEngine provisioning, gateway startup, tray/node connection, recovery, and teardown on disposable WSL distros.
A separate local Windows x64 run also created three uniquely named disposable WSL2 distros under isolated app-owned local-data roots. Its logs showed successful path validation, direct WSL creation, WSL configuration, lockdown validation, CLI installation, gateway configuration, and service installation. That host then failed gateway health, so the local run was not counted as a pass. Setup rollback plus production CLI teardown nevertheless removed every disposable registration and isolated temp directory; post-run
wsl --list --quietcontained noOpenClawE2E-*distro.The local repeated-uninstall error was traced to
windows-node-contextinspecting a distro already removed by setup rollback; the containment/VHD rollback step safely treated the distro as absent and left no managed files behind.Supporting earlier Dev Box captures
These captures predate the compatibility follow-up and are retained only as supporting evidence. They are not presented as current-head proof. All four URLs were rechecked after this update and returned HTTP 200.
Not verified / blocked: the local host could not reach gateway-ready state, but the same final-head setup-connect path passed in GitHub CI. No merge-blocking proof gap remains.
Security impact
No permissions, secrets handling, network calls, or data-access scope are added. Existing
wsl --install --location, targeted WSL teardown, and recursive cleanup inputs are constrained to validated app-owned paths. Teardown accepts broader legacy names only after proving the same canonical immediate-child boundary, and destructive file cleanup is gated on WSL registration state.Compatibility and migration
Existing safe legacy names remain uninstallable; new/recreated names use the stricter grammar. No automatic migration is required. Replacement steps are
--uninstall --confirm-destructivewith the existing name, followed by setup with a supported name.Review conversations
review startedplaceholder for a prior head and is not treated as approval.