Repository navigation
fix: reject shell interpreters as approved exec targets - #1039
shanselman merged 3 commits into
Conversation
An approved command is executed as a direct argument vector, on the promise that it reaches a single process verbatim. That promise does not hold when the resolved executable is itself a shell (cmd, powershell, pwsh, bash, sh, zsh, dash, ash, ksh, fish): the shell re-parses its own argument tail, so metacharacters such as & or | can spawn commands the user never saw or approved. Argument quoting cannot be trusted to neutralize this because cmd.exe has its own splitting rules. Generalize the existing .bat/.cmd rejection in BuildApprovedExecution to fail closed on any shell interpreter, with a single source of truth in ExecCommandToken.IsShellInterpreter. Coordinator tests that used cmd /c as a generic allowable command are migrated to a non-shell executable, since shell wrappers are no longer approvable. Co-Authored-By: Claude Sonnet 4.6 <[email protected]>
|
@clawsweeper re-review |
|
🦞🧹 I asked ClawSweeper to review this item again. Re-review progress:
|
…ject-shell-interpreters
Co-authored-by: Copilot App <[email protected]> Copilot-Session: e455f682-94ad-48d0-a829-c1ddded32fc0
|
@clawsweeper re-review |
|
🦞🧹 I asked ClawSweeper to review this item again. Re-review progress:
|
|
ClawSweeper status: review started. I am starting a fresh review of this pull request: fix: reject shell interpreters as approved exec targets This is item 1/1 in the current shard. Shard 0/1. This placeholder means the worker is alive and reading the current context. I will edit this same comment with the actual review when the claws are done clicking. Crustacean status: shell secured, claws on keyboard, evidence pebbles being sorted. |
Final reviewed head: ClawSweeper was requested twice on the exact head and leased both runs, but did not publish a durable review after more than six hours. The merge decision therefore uses the completed maintainer evidence rather than waiting indefinitely on stalled automation. The branch is current-main integrated and cleanly mergeable. Independent security review found no bypass or false-positive blocker: shell identity is checked at the sole approved-payload factory using resolved executable identity, including full-path/case/extension/env-wrapper variants; both Allow paths fail closed; explicit AllowOnce and pure Independent confidence: 94%. Any later ClawSweeper finding will be evaluated as follow-up evidence. |
What
Durable exec approval rules can safely name only executables whose argument vector retains its meaning. Shells and command hosts reinterpret arguments as another command language, so persisting the host executable would authorize different future commands.
This PR rejects durable authorization for exact indirect command hosts:
cmd,powershell,pwsh,wsl,cscript,wscriptsh,bash,zsh,dash,ash,ksh,fishMatching is by normalized executable basename, not string fragments. Aliases, casing,
.exe, quoted tokens, full paths, relative paths, and resolved executable paths are covered. Names such asmycmd.exe,bashful.exe,pwsh-helper.exe, andcscript-runner.exeremain valid.Semantics
system.execApprovals.setcannot create an allow rule whose executable token is an indirect command host.AllowAlwayscannot persist an indirect command host.AllowOnceremains allowed and never persists.security=fullbehavior remains unchanged, including a pure Full headless fallback.envwrapper fail-closed behavior is unchanged.ClawSweeper review incorporation
ClawSweeper reviewed exact head
539d33c84cb6ef81173ff4a058cb9bd461e72efdand identifiedwsl.exe bash -c ...as an indirect-shell bypass. Current head553372908f45d9e0dfb45aa17e61d265c171f430incorporates that finding by classifyingwslas an indirect command host and testing stored-rule, AllowAlways, and match-dependent fallback paths.ClawSweeper then reviewed exact current head
553372908f45d9e0dfb45aa17e61d265c171f430and reported:Independent security and rubber-duck reviews also identified and verified both headless fallback quadrants:
security=allowlistwith an allowlist-backed fallback;security=fullwithaskFallback=allowlist.The coordinator records whether a fallback allow actually depended on a stored match and rejects durable host authorization on that basis. Final security and rubber-duck re-reviews reported no remaining findings.
Validation
Current head:
553372908f45d9e0dfb45aa17e61d265c171f430.\build.ps1ExecApprovalsCoordinatorTestsandCapabilityTestsdotnet test .\tests\OpenClaw.Shared.Tests\OpenClaw.Shared.Tests.csproj --no-restoredotnet test .\tests\OpenClaw.Tray.Tests\OpenClaw.Tray.Tests.csproj --no-restorewith xUnit collections serialized29809912275The normal parallel local Tray run exposed an unrelated
DeviceIdentityatomic-file race inGatewayConnectionManagerConnectTests; the exact failing test passed alone, and the complete serialized suite passed.Hosted setup-connect E2E initially hit a transient WSL failure: the fresh distro did not register. The failed job was rerun once and passed; all build, test, setup-connect, network-recovery, and revocation-recovery jobs are green on the current head.
Structured autoreview is blocked by local Codex 0.137 refusing to create its isolated helper binaries. Three unchanged Sol review attempts produced no model result or code finding.
Real behavior proof
Current-head focused tests execute the real coordinator, evaluator, resolver, matcher, and filesystem-backed approvals store. They prove:
AllowOnceforwsl.exereturns an execution payload and does not modify the store;AllowAlwaysforwsl.exeis denied and leaves the store unchanged;**/wsl.exerule is denied and remains byte-for-byte unchanged;askFallback=allowlistcannot consume a stored host rule;Live gateway/MXC proof was not rerun. It is blocked on this host by the known upstream 2026.6.11 WSL gateway self-race, and the maintainer explicitly requested that this review not consume the WSL slot or retry MXC. ClawSweeper therefore keeps the PR open for proof sufficiency. The earlier PR-body MXC success claim has been removed from current-head proof.
Security impact
This narrows durable command authorization without changing default-off V2 routing or explicit one-time approval. Stored policy files are not migrated, rewritten, or silently corrupted. Rejected requests return
persistent-approval-not-permitted-for-command-host.