Skip to content

fix: reject shell interpreters as approved exec targets - #1039

Merged
shanselman merged 3 commits into
openclaw:mainfrom
AlexAlves87:fix/exec-approvals-reject-shell-interpreters
Jul 21, 2026
Merged

shanselman merged 3 commits into
openclaw:mainfrom
AlexAlves87:fix/exec-approvals-reject-shell-interpreters

Conversation

@AlexAlves87

@AlexAlves87 AlexAlves87 commented Jul 21, 2026 •

Copy link
Copy Markdown
Contributor

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:

  • Windows: cmd, powershell, pwsh, wsl, cscript, wscript
  • POSIX and WSL: sh, bash, zsh, dash, ash, ksh, fish

Matching 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 as mycmd.exe, bashful.exe, pwsh-helper.exe, and cscript-runner.exe remain valid.

Semantics

  • Remote system.execApprovals.set cannot create an allow rule whose executable token is an indirect command host.
  • V2 AllowAlways cannot persist an indirect command host.
  • Existing stored host rules are preserved byte-for-byte but are not consumed for pre-approval or match-dependent headless fallback.
  • Explicit interactive AllowOnce remains allowed and never persists.
  • Explicit security=full behavior remains unchanged, including a pure Full headless fallback.
  • Batch-script and modified env wrapper fail-closed behavior is unchanged.
  • V2 remains opt-in and off by default.

ClawSweeper review incorporation

ClawSweeper reviewed exact head 539d33c84cb6ef81173ff4a058cb9bd461e72efd and identified wsl.exe bash -c ... as an indirect-shell bypass. Current head 553372908f45d9e0dfb45aa17e61d265c171f430 incorporates that finding by classifying wsl as an indirect command host and testing stored-rule, AllowAlways, and match-dependent fallback paths.

ClawSweeper then reviewed exact current head 553372908f45d9e0dfb45aa17e61d265c171f430 and reported:

  • overall correctness: patch is correct;
  • security review: cleared;
  • code findings: none;
  • confidence: 0.72;
  • keep open solely for missing current-head gateway/MXC runtime proof.

Independent security and rubber-duck reviews also identified and verified both headless fallback quadrants:

  • security=allowlist with an allowlist-backed fallback;
  • security=full with askFallback=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

Command Result
.\build.ps1 All 5 projects built successfully
Focused ExecApprovalsCoordinatorTests and CapabilityTests 401 passed, 0 failed
dotnet test .\tests\OpenClaw.Shared.Tests\OpenClaw.Shared.Tests.csproj --no-restore 3,161 passed, 31 skipped, 0 failed
dotnet test .\tests\OpenClaw.Tray.Tests\OpenClaw.Tray.Tests.csproj --no-restore with xUnit collections serialized 1,862 passed, 0 failed
Hosted Build and Test run 29809912275 All required jobs passed on current head
Independent security review Clean after two verified fallback findings were fixed
Independent rubber-duck review Clean after one verified fallback quadrant was fixed
ClawSweeper exact-head review Patch correct, security cleared, no code findings

The normal parallel local Tray run exposed an unrelated DeviceIdentity atomic-file race in GatewayConnectionManagerConnectTests; 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:

  • interactive AllowOnce for wsl.exe returns an execution payload and does not modify the store;
  • AllowAlways for wsl.exe is denied and leaves the store unchanged;
  • a stored **/wsl.exe rule is denied and remains byte-for-byte unchanged;
  • headless Allowlist fallback and Full plus askFallback=allowlist cannot consume a stored host rule;
  • pure Full fallback remains allowed;
  • remote rule variants across quoting, paths, aliases, casing, and extensions are rejected;
  • non-host substring names remain accepted.

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.

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]>
@shanselman

Copy link
Copy Markdown
Collaborator

@clawsweeper re-review

@clawsweeper

clawsweeper Bot commented Jul 21, 2026 •

Copy link
Copy Markdown

🦞🧹
ClawSweeper re-review requested.

I asked ClawSweeper to review this item again.
Action: item re-review queued (workflow sweep.yml, event repository_dispatch).
Result: the existing ClawSweeper review comment will be edited in place when the review finishes.

Re-review progress:

Co-authored-by: Copilot App <[email protected]>

Copilot-Session: e455f682-94ad-48d0-a829-c1ddded32fc0
@shanselman

Copy link
Copy Markdown
Collaborator

@clawsweeper re-review

@clawsweeper

clawsweeper Bot commented Jul 21, 2026 •

Copy link
Copy Markdown

🦞🧹
ClawSweeper re-review requested.

I asked ClawSweeper to review this item again.
Action: item re-review queued (workflow sweep.yml, event repository_dispatch).
Result: the existing ClawSweeper review comment will be edited in place when the review finishes.

Re-review progress:

@clawsweeper

clawsweeper Bot commented Jul 21, 2026

Copy link
Copy Markdown

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.

@shanselman

Copy link
Copy Markdown
Collaborator

GitHub Copilot maintainer-assistant closeout — automated, not written personally by Scott.

Final reviewed head: 553372908f45d9e0dfb45aa17e61d265c171f430.

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 security=full behavior remain unchanged; stored rules remain byte-preserved but cannot authorize blocked interpreters. Validation passed: 401 focused approval tests, all five project builds, 3,161 Shared tests plus 31 skipped, 1,862 Tray tests, and hosted Build/Test plus setup-connect, revocation-recovery, and network-recovery E2Es. Local MXC remains documented as blocked by the unrelated upstream 2026.6.11 fresh-WSL gateway self-race.

Independent confidence: 94%. Any later ClawSweeper finding will be evaluated as follow-up evidence.

@shanselman
shanselman merged commit 54927b4 into openclaw:main Jul 21, 2026
19 of 20 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants