Skip to content

fix(setup): bind cleanup to live WSL registration - #1230

Merged
shanselman merged 1 commit into
mainfrom
shanselman-fix-wsl-registration-binding
Aug 26, 2026
Merged

shanselman merged 1 commit into
mainfrom
shanselman-fix-wsl-registration-binding

Conversation

@shanselman

Copy link
Copy Markdown
Collaborator

Follow-up safety fix for #1050 after #1229.

Summary

  • require durable OpenClaw evidence plus an exact, canonical live HKCU Lxss BasePath binding before automatic unregister
  • fail closed for missing, unreadable, duplicate, malformed, or mismatched registration metadata, while treating normal and \\?\ drive paths equivalently
  • require a path-bound marker for automatic orphan-directory deletion and guard marker deletion against mismatched evidence and IO/access races
  • preserve exact-name UI consent and --confirm-destructive as explicit overrides

Ownership remains in ManagedDistroOwnership; WindowsWslRegistrationInspector is the narrow Windows metadata seam. The preserved invariant is that automatic cleanup cannot terminate, unregister, or delete same-named foreign WSL data.

Diff: 10 files, +789/-44.

Validation

  • ./build.ps1 - passed; documentation validation checked 46 Markdown files and all 5 build targets succeeded
  • focused ownership/path tests - 68 passed, 0 failed, 0 skipped
  • dotnet test .\tests\OpenClaw.SetupEngine.Tests\OpenClaw.SetupEngine.Tests.csproj --no-restore - 978 passed, 0 failed, 0 skipped
  • dotnet test .\tests\OpenClaw.Shared.Tests\OpenClaw.Shared.Tests.csproj --no-restore - 3,813 passed, 0 failed, 32 skipped, 3,845 total
  • dotnet test .\tests\OpenClaw.Tray.Tests\OpenClaw.Tray.Tests.csproj --no-restore - 2,712 passed, 0 failed, 0 skipped
  • blocker-only rubber-duck review - clean, no blockers

Real behavior proof

Current-head synthetic proof ran 12 focused cases with fake WSL inventory and synthetic unowned directories:

  • stale marker, setup-state, and gateway-registry evidence each preserved a same-named replacement registered at a different BasePath
  • NotFound, Unavailable, Duplicate, and Malformed registration inspection each failed closed
  • setup-state and gateway-registry name-only evidence preserved orphan directories
  • mismatched and IO-locked markers were preserved
  • an equivalent \\?\ drive path was accepted

Each destructive-boundary test asserted the command runner received only wsl --list --quiet; no terminate, unregister, or directory-delete operation occurred. Real destructive proof was intentionally not performed to avoid touching any real WSL distro. No validation blockers.

@clawsweeper

clawsweeper Bot commented Aug 26, 2026

Copy link
Copy Markdown

🦞👀
ClawSweeper picked this up.

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

@shanselman shanselman added the status: 🚢 actively landing A maintainer or agent is actively driving this item through implementation, validation, or merge. label Aug 26, 2026
@clawsweeper clawsweeper Bot added merge-risk: 🚨 automation 🚨 Merging this PR could break CI, automerge, proof capture, label sync, or automation. merge-risk: 🚨 availability 🚨 Merging this PR could cause crashes, hangs, restart loops, stalls, or process outages. 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: 🦪 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 Aug 26, 2026
@clawsweeper

clawsweeper Bot commented Aug 26, 2026

Copy link
Copy Markdown

Codex review: needs real behavior proof before merge. Reviewed August 25, 2026, 8:12 PM ET / August 26, 2026, 00:12 UTC.

ClawSweeper review

What this changes

The branch binds automatic WSL cleanup to a live registry base path, while also replacing the gateway control stdin script with a Bash argv command and changing a Copilot setup action pin.

Regression provenance

Possible regression — probable (reviewed change; known regression link). No predecessor PR is attributed.

Merge readiness

⛔ Blocked until real behavior proof from a real setup is added - 12 items remain

Keep open. The live-registration cleanup hardening is not on main, but this branch regresses the current main WSL gateway-control fix and needs a security-boundary decision before merge.

Priority: P1
Reviewed head: 70670093c0db3b7a006db8c4af911e5a38d69da8
Owner decision: Required. See Decision needed.

Review scores

Measure Result What it means
Overall readiness 🦪 silver shellfish (2/6) The safety coverage is substantial, but a known mainline WSL regression and missing final-effect authority proof block merge readiness.
Proof confidence 🦪 silver shellfish (2/6) Needs real behavior proof before merge: Authority-chain proof required: the supplied proof uses fake WSL inventory and command-runner cases, so it does not show an allowed registration and a reassigned same-name registration reaching or being rejected before real WSL final effects. After adding proof, update the PR body; ClawSweeper should re-review automatically. If it does not, the PR author or someone with repository write access can comment @clawsweeper re-review.
Patch quality 🦪 silver shellfish (2/6) Security review found an item that needs attention.

Verification

Check Result Evidence
Real behavior Needs proof Needs real behavior proof before merge: Authority-chain proof required: the supplied proof uses fake WSL inventory and command-runner cases, so it does not show an allowed registration and a reassigned same-name registration reaching or being rejected before real WSL final effects. After adding proof, update the PR body; ClawSweeper should re-review automatically. If it does not, the PR author or someone with repository write access can comment @clawsweeper re-review.
Evidence reviewed 6 items Introduced WSL control regression: The branch passes a command containing $PATH through wsl.exe argv via bash -lc, replacing the stdin-backed command path used on main.
Documented WSL argv behavior: The repository documents that wsl.exe -- bash -c <script> expands $PATH from the Windows environment before Bash receives it, and identifies stdin as the safe path.
Mainline provenance: Commit 6ae9c6a introduced the stdin-backed bash -s gateway control path specifically to preserve Linux PATH; this branch removes that behavior.
Findings 1 actionable finding [P1] Keep the gateway command on stdin
Security Needs attention Registration binding can become stale before destructive I/O: The registration is checked before name-based terminate and unregister calls, with no identity carried to the final effect; a concurrent same-name replacement can change which WSL data is affected.
Unrelated action revision is downgraded: The workflow changes a pinned external action from its annotated v0.87.2 revision to v0.86.1 without an explanation or evidence that the older revision is required.

How this fits together

Windows setup creates and replaces an app-owned WSL gateway. Cleanup combines durable OpenClaw metadata with the current-user WSL registration before it can terminate, unregister, or delete WSL data; the tray also uses WSL commands to start and restart that gateway.

flowchart LR
  A[Setup request] --> B[Cleanup stage]
  B --> C[Durable OpenClaw evidence]
  B --> D[Live WSL registration]
  C --> E[Ownership decision]
  D --> E
  E -->|Exact path match| F[Scoped WSL cleanup]
  E -->|Missing or mismatched| G[Preserve data]
  H[Explicit user confirmation] --> F
Loading

Decision needed

Question Recommendation
Should automatic WSL cleanup fail closed unless its final terminate and unregister effects can be bound to an unchanged live registration identity? Require final identity-bound cleanup: Keep automatic cleanup disabled whenever an unchanged registration identity cannot be proven at the final destructive operation, falling back to explicit consent.

Why: The current check observes a mutable name-to-path mapping before later destructive commands that act only by name, so maintainer policy is needed for the residual reassignment window.

Before merge

  • Add real behavior proof - Needs real behavior proof before merge: Authority-chain proof required: the supplied proof uses fake WSL inventory and command-runner cases, so it does not show an allowed registration and a reassigned same-name registration reaching or being rejected before real WSL final effects. After adding proof, update the PR body; ClawSweeper should re-review automatically. If it does not, the PR author or someone with repository write access can comment @clawsweeper re-review.
  • Keep the gateway command on stdin (P1) - Do not move this script into argv. wsl.exe expands $PATH before Bash receives an argv script, so this loses the native Linux PATH and can leave openclaw or its env node launcher unresolved. Commit 6ae9c6a5ea0f6017d1a9a2d073bf44fcaedc2dcc added the stdin-backed bash -s path for this controller; retain that path and its regression coverage.
  • Resolve security concern: Registration binding can become stale before destructive I/O - The registration is checked before name-based terminate and unregister calls, with no identity carried to the final effect; a concurrent same-name replacement can change which WSL data is affected.
  • Resolve security concern: Unrelated action revision is downgraded - The workflow changes a pinned external action from its annotated v0.87.2 revision to v0.86.1 without an explanation or evidence that the older revision is required.
  • Resolve merge risk (P1) - Gateway start, stop, and restart can run with a Windows-rewritten PATH after merge.
  • Resolve merge risk (P1) - A same-name WSL registration can change after the one-time binding check and before the later name-based destructive command.
  • Resolve merge risk (P1) - The unrelated GitHub Action revision downgrade needs security and intent review.
  • Complete next step (P2) - A narrow repair can restore the current-main stdin behavior and remove the unrelated workflow downgrade, but the final cleanup-authority policy still needs maintainer direction.
  • Improve patch quality - Restore the stdin-backed WSL gateway command path from current main.
  • Improve patch quality - Capture redacted terminal proof with a disposable WSL distro showing a valid binding proceeds and a reassigned same-name binding is rejected before destructive I/O.
  • Improve patch quality - Remove or explain the unrelated gh-aw action downgrade.

Findings

  • [P1] Keep the gateway command on stdin — src/OpenClaw.Connection/WslGatewayController.cs:36-42
  • [high] Registration binding can become stale before destructive I/O — src/OpenClaw.SetupEngine/CleanupStaleDistroStep.cs:70
  • [low] Unrelated action revision is downgraded — .github/workflows/copilot-setup-steps.yml:21
Agent review details

Security

Needs attention: The diff changes a destructive local-data authorization boundary and includes an unexplained third-party workflow-action downgrade.

Review metrics

Metric Value Why it matters
Actual branch scope 20 files changed, +826/-138 The checked-out diff is twice the 10-file scope stated in the PR body, including gateway-control and workflow changes.
Implementation and tests implementation +430/-78, tests +392/-55 The safety work has substantial regression coverage, but the changed WSL control tests now assert the unsafe argv form.

Merge-risk options

Maintainer options:

  1. Restore the proven WSL execution path (recommended)
    Reinstate the stdin-backed gateway command, remove or separately justify the unrelated action downgrade, and prove the command against a disposable WSL distro before merge.
  2. Strengthen the destructive binding
    Implement and prove a final-effect identity check, or pause automatic cleanup and preserve explicit confirmation until that guarantee is available.

Technical review

Best possible solution:

Restore the stdin-backed WSL control path, then permit automatic cleanup only when the registration binding remains valid through the final destructive effect; otherwise require explicit destructive consent.

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

Yes for the WSL control regression: the repository documents a concrete Windows WSL reproduction for argv expansion, and this branch places $PATH in that exact argv position. A live confirmation requires a Windows WSL host.

Is this the best way to solve the issue?

No. The cleanup binding is a reasonable direction, but the branch undoes the current stdin safeguard and does not prove that a reassigned registration is rejected before the final destructive effect.

Full review comments:

  • [P1] Keep the gateway command on stdin — src/OpenClaw.Connection/WslGatewayController.cs:36-42
    Do not move this script into argv. wsl.exe expands $PATH before Bash receives an argv script, so this loses the native Linux PATH and can leave openclaw or its env node launcher unresolved. Commit 6ae9c6a5ea0f6017d1a9a2d073bf44fcaedc2dcc added the stdin-backed bash -s path for this controller; retain that path and its regression coverage.
    Confidence: 0.99

Overall correctness: patch is incorrect
Overall confidence: 0.98

AGENTS.md: found and applied where relevant.

Codex review notes: model internal, reasoning high; reviewed against 3365e6e1b8b8.

Labels

Label changes:

  • add P1: The branch can break an existing app-managed gateway's start, stop, or restart recovery path.
  • add merge-risk: 🚨 security-boundary: It changes automatic authorization to terminate, unregister, and delete locally registered WSL data.
  • add merge-risk: 🚨 availability: The changed WSL command can lose the native Linux PATH needed to run gateway controls.
  • add merge-risk: 🚨 automation: It changes the pinned third-party action executed by the Copilot setup workflow.
  • add rating: 🦪 silver shellfish: Overall readiness is 🦪 silver shellfish; proof is 🦪 silver shellfish and patch quality is 🦪 silver shellfish.
  • add status: 📣 needs proof: The PR needs real behavior proof before ClawSweeper can clear the contributor ask. Needs real behavior proof before merge: Authority-chain proof required: the supplied proof uses fake WSL inventory and command-runner cases, so it does not show an allowed registration and a reassigned same-name registration reaching or being rejected before real WSL final effects. After adding proof, update the PR body; ClawSweeper should re-review automatically. If it does not, the PR author or someone with repository write access can comment @clawsweeper re-review.

Label justifications:

  • P1: The branch can break an existing app-managed gateway's start, stop, or restart recovery path.
  • merge-risk: 🚨 security-boundary: It changes automatic authorization to terminate, unregister, and delete locally registered WSL data.
  • merge-risk: 🚨 availability: The changed WSL command can lose the native Linux PATH needed to run gateway controls.
  • merge-risk: 🚨 automation: It changes the pinned third-party action executed by the Copilot setup workflow.
  • rating: 🦪 silver shellfish: Overall readiness is 🦪 silver shellfish; proof is 🦪 silver shellfish and patch quality is 🦪 silver shellfish.
  • status: 📣 needs proof: The PR needs real behavior proof before ClawSweeper can clear the contributor ask. Needs real behavior proof before merge: Authority-chain proof required: the supplied proof uses fake WSL inventory and command-runner cases, so it does not show an allowed registration and a reassigned same-name registration reaching or being rejected before real WSL final effects. After adding proof, update the PR body; ClawSweeper should re-review automatically. If it does not, the PR author or someone with repository write access can comment @clawsweeper re-review.

Evidence

Security concerns:

  • [high] Registration binding can become stale before destructive I/O — src/OpenClaw.SetupEngine/CleanupStaleDistroStep.cs:70
    The registration is checked before name-based terminate and unregister calls, with no identity carried to the final effect; a concurrent same-name replacement can change which WSL data is affected.
    Confidence: 0.9
  • [low] Unrelated action revision is downgraded — .github/workflows/copilot-setup-steps.yml:21
    The workflow changes a pinned external action from its annotated v0.87.2 revision to v0.86.1 without an explanation or evidence that the older revision is required.
    Confidence: 0.93

Acceptance criteria:

  • [P1] ./build.ps1.
  • [P1] dotnet test ./tests/OpenClaw.Shared.Tests/OpenClaw.Shared.Tests.csproj --no-restore.
  • [P1] dotnet test ./tests/OpenClaw.Tray.Tests/OpenClaw.Tray.Tests.csproj --no-restore.
  • [P1] dotnet test ./tests/OpenClaw.SetupEngine.Tests/OpenClaw.SetupEngine.Tests.csproj --no-restore.
  • [P1] Run the documented WSL argv reproduction against a disposable distro and retain redacted terminal output.

What I checked:

Likely related people:

  • shanselman: Introduced the current-main WSL PATH-preservation fix and the preceding WSL cleanup ownership work. (role: recent area contributor; confidence: high; commits: 6ae9c6a5ea0f, 787db18f3874; files: src/OpenClaw.Connection/WslGatewayController.cs, src/OpenClaw.Connection/WslCommandRunner.cs, src/OpenClaw.SetupEngine/ManagedDistroOwnership.cs)
  • Barbara Kudiess: Feature history records the setup-step ownership refactor that established the surrounding SetupEngine seam. (role: earlier setup refactor contributor; confidence: medium; commits: b37307cbd51f; files: src/OpenClaw.SetupEngine/CleanupStaleDistroStep.cs)

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

merge-risk: 🚨 automation 🚨 Merging this PR could break CI, automerge, proof capture, label sync, or automation. merge-risk: 🚨 availability 🚨 Merging this PR could cause crashes, hangs, restart loops, stalls, or process outages. 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: 🦪 silver shellfish Thin PR readiness signal; proof, validation, or implementation needs work. status: 🚢 actively landing A maintainer or agent is actively driving this item through implementation, validation, or merge. 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.

1 participant