Skip to content

fix: honor exec allowlists for Windows node commands - #1109

Merged
shanselman merged 30 commits into
openclaw:mainfrom
calebeden:calebeden-fix-exec-approval-bindings
Aug 7, 2026
Merged

shanselman merged 30 commits into
openclaw:mainfrom
calebeden:calebeden-fix-exec-approval-bindings

Conversation

@calebeden

@calebeden calebeden commented Aug 6, 2026 •

Copy link
Copy Markdown
Contributor
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

Fixes an issue where users who added a Windows executable such as hostname.exe to Exec Approvals would stop seeing prompts but still have Windows node commands requested through the gateway fail with persistent-approval-not-permitted-for-command-host. It also fixes reading the Windows node policy through the gateway failing because the Windows node returned an incompatible file-backed approval snapshot shape.

Along the way this closes a real over-authorization bug. Durable approvals were keyed by executable path only, so approving whoami.exe once silently authorized whoami.exe /priv and every other argument combination for that executable, forever. Durable rules are now bound to the executable plus an argPattern, matching the macOS node and the upstream gateway protocol.

Why This Change Was Made

For Mac parity, simple static commands inside the gateway's canonical cmd.exe /d /s /c carrier are conservatively bound to one resolved executable identity, while interpreters and argument-selected code hosts remain one-time approvals. The same identity controls allowlist matching, persistence metadata, and direct execution. Durable binding looks through only the resolved Windows system cmd.exe, permits native .exe targets, and rejects script extensions, shell syntax, ambiguous forms, and legacy indirect code hosts. File-backed approval snapshots now match the gateway schema while retaining hash-based compare-and-swap updates.

Approval identity and execution transport are deliberately separate. For a strictly recognized trusted canonical carrier the node binds, shows, and persists the inner executable, but still executes the validated carrier so its in-band PATH/TEMP bootstrap under MXC stays intact. The executed carrier is reconstructed and checked to match the approved payload exactly, including interior spacing, so no metacharacter drift can be introduced between what was approved and what runs.

User Impact

Users can allowlist simple Windows executables and have matching agent-requested Windows node commands run without repeated prompts or contradictory policy failures. Pipelines and other shell-dependent commands continue to require attended one-time approval unless local policy allows them. Approving one command no longer grants that executable unlimited arguments.

Evidence

  • Real unchanged-gateway invocation of hostname.exe returned exitCode: 0 and the Windows hostname.
  • Tray approval diagnostics recorded decision=allow, fallbackUsed=false, and promptAttempted=false.
  • MXC diagnostics recorded executor=mxc-direct-appc, contained=True, and shell=<direct-argv>.
  • Live approval prompt shows the resolved inner executable, and a previously approved executable with a different argument re-prompts instead of being silently allowed. See Real Behavior Proof.
  • Dual-model adversarial review completed. It found three real issues, all now fixed and covered by regression tests that fail without the fix: the carrier's two launch-time pins were skipped for a one-time Allow Once, skipped again for a pre-approved security=full run, and a direct command executed the normalizer's resolution rather than the binder's resolution that the prompt displayed. No other actionable correctness or security findings remain at the current head.

Change Type

  • Bug fix
  • Feature
  • Refactor
  • Docs or instructions
  • Tests or validation
  • Security hardening
  • Chore or infrastructure

Scope

  • Tray or WinUI UX
  • Windows node capability
  • Local MCP or winnode
  • Gateway, connection, or pairing
  • Setup or onboarding
  • Permissions, privacy, or security
  • Tests, CI, or docs

Validation

All counts below are from the exact current head 866bab33, run with OPENCLAW_REPO_ROOT set to the worktree.

  • ./build.ps1 — exit 0, all 5 projects, documentation validation passed on 45 Markdown files
  • dotnet test ./tests/OpenClaw.Shared.Tests/OpenClaw.Shared.Tests.csproj --no-restore — 3,608 passed, 0 failed, 32 environment-gated skips, 3,640 total
  • dotnet test ./tests/OpenClaw.Tray.Tests/OpenClaw.Tray.Tests.csproj --no-restore — 2,165 passed, 0 failed
  • dotnet test ./tests/OpenClaw.WinNode.Cli.Tests/OpenClaw.WinNode.Cli.Tests.csproj --no-restore — 126 passed, 0 failed
  • dotnet test ./tests/OpenClaw.Tray.IntegrationTests/OpenClaw.Tray.IntegrationTests.csproj --no-restore with OPENCLAW_RUN_INTEGRATION=1 — 22 passed, 0 failed
  • ./scripts/validate-mxc-e2e.ps1 — 5 of 5 real gateway/MXC proofs passed, run strictly without -AllowSkip

Real Behavior Proof

  • Environment tested: Windows 11 with local WSL gateway and MXC/AppContainer available
  • PR head or commit tested: 866bab33, except the attended UI capture noted below
  • Screenshot or artifact links verified? (Yes/No/N/A): Yes, captured and hash-verified locally

Gateway path. ./scripts/validate-mxc-e2e.ps1 drove a real WSL gateway through node.invoke. Canonical cmd.exe /d /s /c hostname.exe returned stdout: "LAPTOP-GA3HSH96", exitCode: 0; the tray logged promptAttempted=false; MXC logged contained=True and shell=<direct-argv>. The local **/hostname.exe rule authorized the gateway request without a prompt and the bound executable ran inside MXC containment. The multi-element carrier tail proof and the bound-allowlist-rule proof both passed in the same run.

Attended UI proof, isolated tray, no real user settings touched. Captured at 3db79d18, an ancestor of the current head whose prompt and durable-write behavior is unchanged by the two commits since. Launched ./run-app-local.ps1 -Isolated -AllowNonMain with EnableMcpServer=true, then invoked:

winnode --command system.run --params '{"command":["cmd.exe","/d","/s","/c","whoami.exe"],"rawCommand":"whoami.exe"}'

The approval prompt rendered the command card cmd.exe /d /s /c whoami.exe, Agent: main, and Executable: C:\WINDOWS\system32\whoami.exe. That Executable row is the resolved inner payload executable, not the cmd.exe carrier, so the operator approves the identity that durable policy will actually store.

Choosing Allow Always wrote an argument-bound rule rather than a path-only one:

{
  "pattern": "C:\\WINDOWS\\system32\\whoami.exe",
  "argPattern": "^\u0000\u0000$",
  "source": "allow-always",
  "commandText": "cmd.exe /d /s /c whoami.exe"
}

Re-running the identical command was then silently allowed, logging decision=allow reason=approved promptAttempted=false grant=arg-bound.

Running the same already-approved executable with a different argument, cmd.exe /d /s /c "whoami.exe /priv", re-prompted instead of running, because /priv does not match the stored argPattern. This is the decisive proof: before this change a path-only rule would have silently allowed it.

  • Not verified or blocked: this host cannot spawn grandchild processes inside the MXC AppContainer (0xC0000142 / Access is denied.), which is a documented host limitation rather than a defect in this change. The E2E recognizes those signatures explicitly and still proves the containment and approval behavior. Also note the WSL gateway proof requires networkingMode=NAT; under networkingMode=Mirrored the in-distro gateway never accepts loopback connections and setup fails before any node behavior is exercised.

Security Impact

  • New permissions or capabilities? (Yes/No): No
  • Secrets or tokens handling changed? (Yes/No): No
  • New or changed network calls? (Yes/No): No
  • Command or tool execution surface changed? (Yes/No): Yes
  • Data access scope changed? (Yes/No): No
  • If any answer is Yes, explain the risk and mitigation: Durable authorization applies only when the canonical carrier resolves to a real Windows system cmd.exe and contains one safely bindable static native executable. The resolved absolute system image is pinned into the executed argv, so a rogue cmd.exe earlier on PATH is never what runs, and the payload's executable token is pinned too so cmd cannot re-resolve it against the working directory after approval. Both pins now apply to one-time Allow Once as well, not only to durable approvals, so the image the operator was shown is always the image that runs. The binder rejects quotes, shell operators, expansion, noncanonical switches, script extensions, missing targets, network/UNC executables, arguments containing NUL, interpreters, and legacy argument-selected code hosts. Durable bindability is deliberately .exe only; a .com target remains runnable but prompt-only, which is the fail-closed side. Allow Once and full local policy retain the original wrapper, and MXC containment remains enforced.

Compatibility and Migration

  • Backward compatible? (Yes/No): No. This intentionally removes the redundant baseHash field from local MCP and winnode exec-approval snapshot responses so the node uses the gateway-compatible file-backed shape. The upstream schema was confirmed directly at db90dff1396fecbf7029e9e9ea19d6c6ca3e644e in packages/gateway-protocol/src/schema/exec-approvals.ts, where the snapshot object sets additionalProperties: false and requires exactly ["path","exists","hash","file"], so emitting baseHash is schema-invalid and had to be removed.
  • Config or environment changes? (Yes/No): No
  • Migration needed? (Yes/No): Yes, only for local MCP or winnode consumers that read snapshot.baseHash.
  • If yes, list the exact upgrade steps: Read snapshot.hash from system.execApprovals.get and pass that value as the baseHash argument to system.execApprovals.set. Preserving the old response alias is intentionally out of scope.

Review Conversations

  • I replied to or resolved every bot review conversation addressed by this PR.
  • I left unresolved only conversations that still need maintainer judgment.

calebeden and others added 3 commits August 5, 2026 20:43
Omit the redundant baseHash response field so file-backed V2 snapshots match the gateway protocol. Keep hash as the compare-and-swap value supplied to system.execApprovals.set.

Co-authored-by: Copilot App <[email protected]>
Bind simple canonical CMD carriers to one resolved executable identity for allowlist matching, persistence, metadata, and direct execution. Keep shell syntax and ambiguous command forms on the one-time approval path.

Co-authored-by: Copilot App <[email protected]>
Keep argument-selected Windows code hosts on the one-time approval path, document the maintained host catalog, and enforce the reusable-command prerequisite for durable fallback execution.

Co-authored-by: Copilot App <[email protected]>
@calebeden calebeden changed the title fix: allow Windows exec rules to authorize simple gateway commands fix: honor exec allowlists for Windows node commands Aug 6, 2026
@clawsweeper clawsweeper Bot added proof: sufficient Contributor real behavior proof is sufficient. rating: 🦐 gold shrimp Decent PR readiness signal, but merge confidence is limited. status: ⏳ waiting on author ClawSweeper has contributor-facing work open and is waiting for author action. P1 Urgent regression or broken agent/channel workflow affecting real users now. merge-risk: 🚨 compatibility 🚨 Merging this PR could break existing users, config, migrations, defaults, or upgrades. merge-risk: 🚨 security-boundary 🚨 Merging this PR could weaken sandboxing, authorization, credentials, or sensitive data. labels Aug 6, 2026
@clawsweeper

clawsweeper Bot commented Aug 6, 2026 •

Copy link
Copy Markdown

Codex review: needs real behavior proof before merge. Reviewed August 7, 2026, 4:03 PM ET / 20:03 UTC.

ClawSweeper review

What this changes

This PR binds reusable Windows command approvals to resolved executables and exact arguments, pins trusted cmd.exe carrier execution, and updates approval snapshot protocol fields.

Merge readiness

⛔ Blocked until stronger real behavior proof is added - 9 items remain

Keep open and block merge: historical Allow Always entries have the same source-less, argument-less shape that this patch treats as deliberate broad rules, so existing approvals can still authorize new arguments and defeat the stated security guarantee.

Priority: P1
Reviewed head: 866bab33564a9de6646e4e45eed5e9fd238717e0
Owner decision: Required. See Decision needed.

Review scores

Measure Result What it means
Overall readiness 🧂 unranked krab (1/6) The branch has substantial focused coverage, but an unresolved P1 authorization-migration gap and mismatched real-behavior media prevent merge readiness.
Proof confidence 🦪 silver shellfish (2/6) Needs stronger real behavior proof before merge: The prepared screenshots are from the separate Permissions UI work and do not show this head's gateway allowlist execution, changed-argument re-prompt, or MXC result; add redacted current-head terminal or runtime-log evidence. 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 stronger real behavior proof before merge: The prepared screenshots are from the separate Permissions UI work and do not show this head's gateway allowlist execution, changed-argument re-prompt, or MXC result; add redacted current-head terminal or runtime-log evidence. 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 5 items Ambiguous legacy rule remains broad: The new matcher treats every source-less rule without argPattern as a path-only match for ordinary executables. Current pre-PR Allow Always persistence wrote exactly that shape, so old automatic approvals cannot be distinguished from a hand-authored broad rule.
Current persistence shape: Before this PR, AddAllowlistEntryAsync, called by the Allow Always path, persisted only id and pattern. It stored neither source nor argPattern.
Branch regression test confirms the unsafe upgrade behavior: The proposed test explicitly accepts a legacy source-less hostname.exe rule for hostname.exe --fqdn, despite that being indistinguishable from an old automatically generated approval.
Findings 1 actionable finding [P1] Fail closed on ambiguous legacy approval rules
Security Needs attention Legacy Allow Always rules retain broad authority: Current V2 persistence wrote source-less, argument-less rules for Allow Always, but this patch accepts that shape for ordinary executables without an argument check.

How this fits together

Gateway and local MCP system.run requests enter the Windows node approval pipeline before MXC executes them. The pipeline matches persisted allowlist policy, may prompt an operator, and returns the argv that the node runner executes.

flowchart LR
  A[Gateway or local MCP request] --> B[Request validation]
  B --> C[Reusable command binding]
  C --> D[Allowlist and prompt decision]
  D --> E[Pinned MXC execution]
  E --> F[Node response and diagnostics]
Loading

Decision needed

Question Recommendation
Should ambiguous source-less V2 allowlist entries be disabled pending fresh argument-bound approval, or should the product intentionally retain their path-only authorization after upgrade? Fail closed and require reapproval: Treat ambiguous pre-binding entries as non-reusable, preserve them for audit, and let operators explicitly create fresh argument-bound approvals.

Why: Prior Allow Always persistence and a hand-authored rule share an identical on-disk representation, so source inspection cannot safely infer the operator's intended authority boundary.

Before merge

  • Add real behavior proof - Needs stronger real behavior proof before merge: The prepared screenshots are from the separate Permissions UI work and do not show this head's gateway allowlist execution, changed-argument re-prompt, or MXC result; add redacted current-head terminal or runtime-log evidence. 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.
  • Fail closed on ambiguous legacy approval rules (P1) - Pre-PR Allow Always calls wrote entries with only id and pattern, the same shape this branch calls a hand-written broad rule. As a result, an existing hostname.exe approval still matches hostname.exe --fqdn or any other arguments after upgrade, retaining the over-authorization this PR claims to remove. Preserve these records, but require a fresh bound approval or add a migration that can reliably distinguish manual broad rules.
  • Resolve security concern: Legacy Allow Always rules retain broad authority - Current V2 persistence wrote source-less, argument-less rules for Allow Always, but this patch accepts that shape for ordinary executables without an argument check.
  • Resolve merge risk (P1) - Existing users with source-less V2 rules written by prior Allow Always actions will retain path-only authorization for ordinary executables, so approving one command can still permit arbitrary later arguments after upgrade.
  • Resolve merge risk (P1) - Removing baseHash from the local MCP and winnode snapshot response is an intentional public-contract break that requires consumers to switch to hash as the set request token.
  • Complete next step (P2) - A maintainer must choose the security-versus-legacy-compatibility policy because existing on-disk entries do not record whether they were automatic or manually broad.
  • Improve patch quality - Resolve the legacy-rule security policy and add upgrade regression coverage proving the selected behavior.
  • Improve patch quality - Attach redacted current-head gateway/MXC output showing a bound allowlist hit and a changed-argument re-prompt.

Findings

  • [P1] Fail closed on ambiguous legacy approval rules — src/OpenClaw.Shared/ExecApprovals/ExecAllowlistMatcher.cs:87-96
  • [high] Legacy Allow Always rules retain broad authority — src/OpenClaw.Shared/ExecApprovals/ExecAllowlistMatcher.cs:87
Agent review details

Security

Needs attention: The command-execution hardening leaves ambiguous legacy grants authorized broadly, creating an upgrade-time authorization-boundary gap.

Review metrics

Metric Value Why it matters
Patch size 40 files, +5,359/-205 lines A security-sensitive runtime fix spans approval storage, execution, MCP contract, MXC proof, and documentation.
Production versus tests production +1,932/-116, tests +3,105/-77 The broad test investment is useful, but it currently codifies the ambiguous legacy-rule behavior that needs a policy decision.

Root-cause cluster

Relationship: canonical
Canonical: #1109
Summary: This PR is the canonical runtime approval-binding work; the related UI submissions do not replace its unresolved migration boundary.

Members:

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

Merge-risk options

Maintainer options:

  1. Fail closed for ambiguous legacy entries (recommended)
    Preserve ambiguous records but require a new explicit, argument-bound approval before they can authorize execution after upgrade.
  2. Accept retained path-only authority
    Keep legacy source-less rules broad only with explicit maintainer acceptance and revised security and upgrade documentation.

Technical review

Best possible solution:

Choose and implement an explicit legacy-rule policy: fail closed and require reapproval for ambiguous entries, or introduce a reliable migration marker that preserves only demonstrably hand-authored broad rules, with upgrade coverage for both paths.

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

Yes, from source: create a pre-PR source-less hostname.exe allowlist entry, upgrade, then request hostname.exe with different arguments. The matcher accepts it as a broad rule, although current persistence used that same shape for Allow Always.

Is this the best way to solve the issue?

No. Argument binding is the right destination, but the proposed source-based distinction cannot identify historical generated entries, so it needs an explicit upgrade policy before it is safe.

Full review comments:

  • [P1] Fail closed on ambiguous legacy approval rules — src/OpenClaw.Shared/ExecApprovals/ExecAllowlistMatcher.cs:87-96
    Pre-PR Allow Always calls wrote entries with only id and pattern, the same shape this branch calls a hand-written broad rule. As a result, an existing hostname.exe approval still matches hostname.exe --fqdn or any other arguments after upgrade, retaining the over-authorization this PR claims to remove. Preserve these records, but require a fresh bound approval or add a migration that can reliably distinguish manual broad rules.
    Confidence: 0.99

Overall correctness: patch is incorrect
Overall confidence: 0.97

AGENTS.md: found and applied where relevant.

Codex review notes: model internal, reasoning high; reviewed against 01faa6419b42.

Labels

Label changes:

  • add proof: 📸 screenshot: Contributor real behavior proof includes screenshot evidence. The prepared screenshots are from the separate Permissions UI work and do not show this head's gateway allowlist execution, changed-argument re-prompt, or MXC result; add redacted current-head terminal or runtime-log evidence.
  • add rating: 🧂 unranked krab: Overall readiness is 🧂 unranked krab; proof is 🦪 silver shellfish and patch quality is 🦪 silver shellfish.
  • remove rating: 🦪 silver shellfish: Current PR rating is rating: 🧂 unranked krab, so this older rating label is no longer current.

Label justifications:

  • P1: The upgrade can preserve broad command authority for existing operators despite the PR's stated argument-binding guarantee.
  • merge-risk: 🚨 compatibility: Existing source-less approvals and consumers of snapshot.baseHash have behavior or contract changes on upgrade.
  • merge-risk: 🚨 security-boundary: An old automatically generated approval remains indistinguishable from a deliberate broad rule and can authorize new arguments.
  • rating: 🧂 unranked krab: Overall readiness is 🧂 unranked krab; 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 stronger real behavior proof before merge: The prepared screenshots are from the separate Permissions UI work and do not show this head's gateway allowlist execution, changed-argument re-prompt, or MXC result; add redacted current-head terminal or runtime-log evidence. 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.
  • proof: 📸 screenshot: Contributor real behavior proof includes screenshot evidence. The prepared screenshots are from the separate Permissions UI work and do not show this head's gateway allowlist execution, changed-argument re-prompt, or MXC result; add redacted current-head terminal or runtime-log evidence.

Evidence

Security concerns:

  • [high] Legacy Allow Always rules retain broad authority — src/OpenClaw.Shared/ExecApprovals/ExecAllowlistMatcher.cs:87
    Current V2 persistence wrote source-less, argument-less rules for Allow Always, but this patch accepts that shape for ordinary executables without an argument check.
    Confidence: 0.99

What I checked:

Likely related people:

  • shanselman: Authored the PR head and several carrier-pinning and approval-hardening commits in this area. (role: recent exec-approval and execution-path contributor; confidence: high; commits: 866bab33564a, ce0a3cba2d4c; files: src/OpenClaw.Shared/ExecApprovals/ExecApprovalsCoordinator.cs, src/OpenClaw.Shared/ExecApprovals/ExecReusableCommandBinder.cs)
  • bkudiess: Introduced the V2 approval-store path whose persisted entries lack provenance and argument bindings. (role: file-backed approval-store introducer; confidence: high; commits: 4806eaac7c24; files: src/OpenClaw.Shared/ExecApprovals/ExecApprovalsStore.cs)
  • AlexAlves87: History shows repeated work on the coordinator and allowlist matcher, including command-host restrictions. (role: historical approval-policy contributor; confidence: medium; commits: 54927b462839; files: src/OpenClaw.Shared/ExecApprovals/ExecAllowlistMatcher.cs, src/OpenClaw.Shared/ExecApprovals/ExecApprovalsCoordinator.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.

History

Review history (7 earlier review cycles)
  • reviewed 2026-08-06T06:35:11.304Z sha 6be4957 :: found issues before merge. :: [P1] Preserve the documented local snapshot field
  • reviewed 2026-08-06T06:53:47.488Z sha 6be4957 :: found issues before merge. :: [P1] Preserve the documented local snapshot field | [P2] Run the required WinNode CLI validation
  • reviewed 2026-08-06T23:34:37.621Z sha b9be5f4 :: needs real behavior proof before merge. :: [P1] Preserve the documented local snapshot field | [P2] Run the required WinNode CLI validation
  • reviewed 2026-08-07T00:18:13.381Z sha b9be5f4 :: needs real behavior proof before merge. :: [P1] Preserve the local snapshot response field
  • reviewed 2026-08-07T03:03:25.907Z sha d192ed1 :: needs real behavior proof before merge. :: [P1] Preserve the local snapshot response field
  • reviewed 2026-08-07T19:10:08.312Z sha c574616 :: needs real behavior proof before merge. :: [P1] Protect existing durable approvals during migration
  • reviewed 2026-08-07T19:38:16.505Z sha ce0a3cb :: needs real behavior proof before merge. :: [P1] Migrate ambiguous pre-binding approvals before accepting them

shanselman and others added 2 commits August 6, 2026 14:03
Review follow-ups for the reusable exec command binder.

Carrier shape (blocker): the binder only accepted a cmd carrier with
exactly 5 argv elements, but the gateway sends the command tail already
tokenized (upstream fixture: cmd.exe /d /s /c echo "SAFE&&whoami"), so
real invocations never bound and allowlists stayed broken. Carrier
recognition now lives in a single owner, CanonicalCmdCarrier, which
accepts multi-element tails and identifies cmd by basename so the
absolute-path form works. MxcConfigBuilder now shares that owner instead
of keeping its own divergent copy, which also removes a latent
NotSupportedException on carriers with more than 5 elements.

Bindable executables (high): PATHEXT resolution can return .vbs, .js,
.msc, .com and similar, so a denylist of .bat/.cmd was insufficient for
durable rules. Replaced with an .exe-only allowlist, applied in both the
binder and the coordinator.

Prompt resolved path (high): ExecApprovalEvaluation.Resolution is derived
from the allowlist resolutions, which are now empty for unbindable
commands, so the approval dialog lost the resolved path on exactly the
riskiest path. Restored a fallback to the carrier resolution.

Indirect command hosts: corrected the inaccurate claim that this catalog
matches the macOS binding model (macOS binds an argPattern instead) and
expanded it with 20 argument-selected code hosts.

Also documents why baseHash must not be reintroduced into the exec
approvals snapshot, records the new ownership in the architecture ledger
with guard tests, and documents the interpreter-rule behavior change.

Co-authored-by: Copilot App <[email protected]>
Copilot-Session: 1223ff2c-11b6-48d9-937b-a56408e99b93
Rubber-duck review caught an approval/execution identity mismatch that the
previous commit introduced.

Unifying carrier recognition on a basename match let any image named
cmd.exe be looked through, including a copy in a writable directory. For
"C:\Writable\cmd.exe /d /s /c hostname.exe" the binder would bind against
the inner hostname.exe, so the approval dialog showed that trusted path,
but an allow-once still launches the outer image, which is free to ignore
its arguments and run something else entirely.

The two owners need different predicates. Serialization must stay
permissive: cmd parses its own raw command line rather than going through
CommandLineToArgvW, so anything cmd receives has to use the cmd-aware
serializer regardless of where the image lives, and being permissive there
only ever yields correct quoting. Trust must be strict, because looking
through a carrier is what makes the shown identity differ from the
executed image.

IsCmdExecutable stays as the serialization predicate and keeps its
MxcConfigBuilder caller. IsTrustedCarrierExecutable is new and accepts
only the bare gateway name or a fully-qualified path in the Windows system
directories; the binder now uses TryGetTrustedCanonicalPayload. An
unrecognized carrier falls through to the existing indirect-host
rejection, so it stays unbindable instead of binding to the wrong
identity.

Co-authored-by: Copilot App <[email protected]>
Copilot-Session: 1223ff2c-11b6-48d9-937b-a56408e99b93
@calebeden
calebeden marked this pull request as draft August 6, 2026 21:39
Require durable binding to resolve the outer carrier to system cmd.exe, restore native .com executables, preserve .com command-host classification, and clarify the live gateway carrier shape.

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

Copy link
Copy Markdown
Contributor Author

Caleb Eden + GitHub Copilot pair-programming follow-up

@shanselman Thanks for the carrier-recognition and binding hardening patches. The shared CanonicalCmdCarrier, prompt-path restoration, and expanded regression coverage address several real gaps.

I reviewed both follow-ups and prepared a local patch for two remaining edge cases:

  • Bare cmd.exe was trusted before PATH resolution, so PATH shadowing could still make an untrusted outer image appear transparent. Durable binding now requires the resolved carrier to be the system cmd.exe.
  • The .exe-only gate excluded native Windows .com binaries such as chcp.com. Durable binding now permits native .exe and .com targets while preserving indirect-host classification for both suffixes.

I also clarified that the live gateway currently sends one pre-joined command element; reconstructible multi-element tails are supported for low-level callers and fixtures. Build, Shared, Tray, and real gateway/MXC validation are green, and the follow-up received a clean dual-model review.

@calebeden
calebeden marked this pull request as ready for review August 6, 2026 21:54
shanselman and others added 4 commits August 6, 2026 15:04
…ble names

Durable approval identity is now executable path plus an argument pattern,
matching the gateway protocol and the macOS node. Approving one invocation of a
program no longer authorizes every other invocation of it.

Upstream ground truth is openclaw/openclaw at db90dff1396fecbf7029e9e9ea19d6c6ca3e644e:
packages/gateway-protocol/src/schema/exec-approvals.ts, src/infra/exec-approvals-allowlist.ts,
src/infra/exec-command-resolution.ts, src/infra/system-run-command.ts.

Argument binding (D1)

ExecArgPattern owns the wire format. A generated pattern is an anchored regex
over the NUL-separated argument subject, matching buildArgPatternFromArgv on
Windows. The macOS hashed "sha256:argv:" form is recognized so an entry created
there matches here. Patterns are remote-influenced input, so matching is time
bounded and a malformed pattern fails closed.

ExecAllowlistMatcher now mirrors matchAllowlist: an entry with an argument
pattern must match the arguments and wins over a path-only match; a generated
entry with no argument pattern never matches, because such an entry predates
argument binding and would authorize argv the operator never saw.

The name-keyed interpreter catalog in ExecCommandToken is deleted. A name list
is not a boundary: renaming an image defeats it and the list can never be
complete. Argument binding constrains a renamed interpreter exactly as tightly.

rawCommand consistency (D2)

ValidatedRunRequest carries rawCommand and the validator rejects a mismatch
against command, mirroring the gateway's RAW_COMMAND_MISMATCH. Both accepted
forms are honored: the formatted argv and the inline cmd payload. rawCommand is
never promoted to executable input.

Network executables (D3)

A durable rule names a path, not the bytes at that path. UNC and mapped network
paths are refused for durable binding because whoever controls the share
controls what a past approval authorizes later.

Carrier diagnostics (D4)

An unbindable carrier now reports why (non-canonical-cmd-carrier,
carrier-payload-not-static, untrusted-cmd-carrier-image, and so on) instead of
silently producing an allowlist that appears to be ignored.

Identity separated from transport (D5)

A strictly recognized canonical cmd carrier is authorized by the executable it
actually runs, but is executed exactly as received. Substituting the bound
direct argv would drop the carrier's in-band PATH and TEMP setup, which is the
only environment contract the sandbox currently accepts. An invariant asserts
the executed transport still reconstructs the approved request. Images merely
named cmd.exe are refused: looking through one would describe the trusted inner
program while running the untrusted outer image.

Also fixes a real widening bug: rewriting the approvals file dropped source and
argPattern, silently converting a narrow generated rule into a path-only one.

Behavior change worth calling out: a hand-written path-only rule such as
**/wsl.exe now authorizes that executable instead of hard-failing with
persistent-approval-not-permitted-for-command-host. That matches upstream and is
the operator's explicit choice. Generated rules still pin their arguments.

Validation: build.ps1, Shared 3502, Tray 2116, WinNode.Cli 126.

Co-authored-by: Copilot App <[email protected]>
Copilot-Session: 1223ff2c-11b6-48d9-937b-a56408e99b93
The D5 carrier-preservation path kept the request's original argv[0], which is
typically a bare `cmd.exe`. LocalCommandRunner.ValidateDirectExecutable requires a
fully-qualified executable, so every preserved carrier failed at launch, and a
relative argv[0] would also let Windows re-resolve the image against PATH/cwd at
spawn time - the exact hijack the resolved-path rule exists to prevent.

CanonicalCmdCarrier.ResolveTrustedCarrierPath now resolves a trusted carrier token
to the absolute System32/SysWOW64 cmd.exe, and the binder pins executionArgv[0] to
it. The anti-drift invariant in CarrierTransportMatchesRequest permits exactly that
one substitution (argv[0], compared OrdinalIgnoreCase); argv[1..] must still be
Ordinal-identical, so no metacharacter drift can be introduced. A carrier that
cannot be resolved to a trusted image is rejected with UntrustedCarrierImage.

E2E: adds a multi-element-tail allowlist proof matching the gateway's real wire
shape, plus a child-spawn diagnostic. Both approval proofs now assert the approval
decision unconditionally and tolerate only STATUS_DLL_INIT_FAILED for the exit
code, since some hosts cannot spawn any child executable under MXC. Any other
nonzero exit still fails.

Co-authored-by: Copilot App <[email protected]>
Copilot-Session: 1223ff2c-11b6-48d9-937b-a56408e99b93
…h rejection

WINDOWS_NODE_ARCHITECTURE still described the removed indirect-command-host
catalog as the durable security boundary. Replaced with the implemented model:
durable identity is executable + argPattern, the platform-specific argPattern wire
form, upstream matchAllowlist authorization consequences, the trusted-carrier
identity/transport split and its two anti-drift invariants, and the deliberate
path-only policy loosening.

Adds an architecture ledger row for exec-carrier-transport-identity so a future
change cannot quietly substitute the bound direct argv for the carrier while MXC
still needs the in-band PATH/TEMP bootstrap.

Adds SystemExecApprovals_SetRejectsStaleBaseHash over the real MCP HTTP server:
the GET snapshot carries no baseHash, a stale baseHash on .set is rejected, and
the rejected write does not mutate the file.

Co-authored-by: Copilot App <[email protected]>
Copilot-Session: 1223ff2c-11b6-48d9-937b-a56408e99b93
Three ways a durable approval could authorize one thing and permit another.

Current-directory hijack. The trusted cmd carrier is executed verbatim, so
cmd.exe re-resolves the payload executable at launch and it searches the
current directory before PATH. Our resolver searches PATH only. A file named
like the payload sitting in the working directory therefore meant the binder
authorized the PATH copy while cmd.exe launched the local one, and a replay
re-resolved to the same PATH copy so no prompt appeared. The binder now
refuses to bind when the current directory shadows a bare payload name, so
the two resolvers can never disagree. Explicitly relative payloads are
unaffected: both resolve them the same way.

Remote binding strip. A remote .set was allowed to retain any entry whose
pattern matched an existing one. Keeping the path while dropping argPattern
and source converted a narrow generated rule into a path-only grant for that
executable, which is privilege escalation without adding an entry. Retention
now compares the whole authorization identity.

NUL in arguments. NUL separates arguments inside a persisted argPattern, so
"a\0b" rendered identically to the two arguments "a","b" and a stored rule
could match a differently segmented argv. NUL is not representable in a
Windows command line anyway, so arguments containing one are rejected before
anything is bound or written.

Also stamps allowlist usage against the matched entry id and argument binding
rather than the pattern alone, so a path-only rule no longer absorbs the
usage metadata of a bound sibling, and logs the breadth of each grant.

Validation: build.ps1; Shared 3508 passed; Tray 2116 passed;
WinNode.Cli 126 passed; MCP exec-approvals integration 4 passed against a
live tray subprocess.

Co-authored-by: Copilot App <[email protected]>
Copilot-Session: 1223ff2c-11b6-48d9-937b-a56408e99b93
@clawsweeper clawsweeper Bot added 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. and removed proof: sufficient Contributor real behavior proof is sufficient. rating: 🦐 gold shrimp Decent PR readiness signal, but merge confidence is limited. status: ⏳ waiting on author ClawSweeper has contributor-facing work open and is waiting for author action. labels Aug 6, 2026
shanselman and others added 2 commits August 6, 2026 17:10
Follow-up review found three ways around the checks added in the previous
commit.

Identity forgery. The retained-entry identity joined pattern, argPattern and
source with NUL, but argPattern legitimately contains NUL. A caller could
shift the delimiter between fields to forge a match while leaving a broader,
unanchored regex behind: (argPattern "^--version\0$", source "allow-always")
had the same joined form as (argPattern "^--version", source "$\0allow-always").
The fields are now compared structurally, so no redistribution can collide.

Omitted working directory. The current-directory shadow check treated a null
cwd as "no current directory", but a child process inherits this one's and
cmd.exe searches it before PATH just the same. It now falls back to the
inherited directory instead of skipping the check.

Carrier payload NUL. The NUL rejection sat in the direct-binding path only.
The carrier tokenizes a payload string into a fresh argv, so a NUL carried
inside the payload was checked but the outer command was not. The check now
runs at entry, before any carrier parsing, and again after tokenization.

Validation: build.ps1 (WinNodeCli hit the known transient GitVersion mutex
error; rebuilt clean on retry); Shared 3510 passed; Tray 2116 passed;
WinNode.Cli 126 passed; MCP exec-approvals integration 5 passed against a
live tray subprocess rebuilt from this head.

Co-authored-by: Copilot App <[email protected]>
Copilot-Session: 1223ff2c-11b6-48d9-937b-a56408e99b93
Documents the working-directory ambiguity refusal, the NUL argument rule, and
the structural retained-entry identity comparison. Also states plainly that the
ambiguity check is an approval-time snapshot, so a writable working directory
remains in scope for payload substitution until the transport question is
settled.

Co-authored-by: Copilot App <[email protected]>
Copilot-Session: 1223ff2c-11b6-48d9-937b-a56408e99b93
shanselman and others added 18 commits August 6, 2026 17:37
The structural comparison introduced in the previous commit replaced a hash set
with a linear scan. The submitted allowlist is remote-controlled, so a caller
could pass the retention constraint with many duplicate entries and force a full
scan of the local allowlist for each one. Restores hashed lookup with a
structural tuple comparer, so collision safety does not cost bounded lookup.

Source-only commit. Not validated locally: coordinator holds the host.

Co-authored-by: Copilot App <[email protected]>
Copilot-Session: 1223ff2c-11b6-48d9-937b-a56408e99b93
…rier

D6, targeted quarantine. An allowlist entry with neither `source` nor
`argPattern` stays a valid path-only rule for an ordinary executable, but goes
inert when its resolved target is a wrapper, interpreter, or code host the
previous model refused to approve durably (python, cmd, powershell, pwsh, wsl
and the rest of the pre-existing catalog, including versioned interpreters).
Those commands prompt instead of matching. The entry is not deleted and is not
auto-migrated on first observation. Only an explicit Allow always writes a
source-marked, argument-bound sibling, which then matches normally. This keeps
the move from a name catalog to argument binding from silently loosening a case
that used to be denied outright. The catalog is a legacy-compatibility
predicate, not the security boundary; structural wrapper classification plus
argument binding remains the model.

D7, constrained Option A. The recognized canonical trusted cmd carrier is still
executed (its in-band PATH and TEMP bootstrap is required under MXC 0.7, which
rejects a non-empty process.env), but it is reconstructed with the payload's
executable token pinned to the binder-resolved absolute path, in addition to the
already-pinned argv[0]. This closes the working-directory substitution race:
without the pin, the binder authorizes using a PATH-only resolver while cmd
resolves the same token at launch searching the working directory first, so
anything able to write there between approval and launch picked the winner.

New `CmdPayloadTokenizer` is the single owner of payload parsing and exposes
token spans, so the rewrite is built from the parsed structure and never from a
string replacement. An argument that repeats the executable's text survives
untouched. Pinning is refused rather than approximated: the pinned path must be
readable back by cmd byte for byte, so whitespace, quotes, control characters,
`% ! ^ & | < > ( )`, the command-name delimiters `, ; =`, and a trailing
backslash all fail closed to prompt-only. Whitespace is refused rather than
quoted because under `/s` cmd strips the payload's first and last quote and uses
the remainder verbatim, which would reintroduce the ambiguity the pin exists to
remove. Reconstruction is validated by round trip: same argument count, the
executable equal to the pinned path, every other argument ordinal-identical,
tail arity preserved, and the whole carrier still recognized as canonical. The
same equivalence is re-checked at execution time. The approval-time
working-directory ambiguity check is demoted to a diagnostic and the residual
race is removed from the docs.

Reconciles remote contributor head b9be5f4:
- Adopted: `.com` is a directly-executable image, so it is bindable and is
  stripped by NormalizedBasename (so powershell.com classifies like
  powershell.exe).
- Adopted: the doc clarification that the live gateway sends one pre-joined tail
  element and a tokenized tail is a low-level/fixture shape.
- Superseded: `IsTrustedSystemCmdPath` detected a bare cmd.exe resolving outside
  System32 and refused to bind. Pinning is strictly stronger: argv[0] is set to
  the system image, so a rogue cmd.exe first on PATH is not merely detected, it
  is never what runs. The weaker predicate must not be resurrected. The test
  that protected the invariant is preserved in strengthened form.

NOT VALIDATED. No build, test, or tool run was performed for this commit: the
coordinator holds an exclusive local host lock. Source only, pending the
`1109 LOCAL WINDOW START` window.

Co-authored-by: Copilot App <[email protected]>
Copilot-Session: 1223ff2c-11b6-48d9-937b-a56408e99b93
Adds focused CanonicalCmdCarrier coverage for the D7 reconstruction: the
request's own switch spelling is preserved, a relative carrier or payload is
refused, the pinned carrier matches the request it was built from, any other
difference (different program, different argument, injected metacharacter,
unqualified payload, changed switch) is refused at execution time, and the
PATHEXT extension a bare name gains when resolved is accepted.

Refuses pinning a path containing cmd's command-name delimiters , ; = which our
tokenizer deliberately does not model, so such a path cannot be split by cmd
into a different program plus an argument. Adds the three cases to the
representation-safety theory.

Avoids nullable/variance-sensitive assertion overloads and collection
expressions in generic Assert.Equal calls, since tests build with
TreatWarningsAsErrors.

NOT VALIDATED. Source only, local host hold still in force.

Co-authored-by: Copilot App <[email protected]>
Copilot-Session: 1223ff2c-11b6-48d9-937b-a56408e99b93
…onstruction

Two coordinator-required corrections to the D6/D7 work. All other D6/D7
behavior is unchanged.

1. Revert the .com durable bindability expansion.

   b9be5f4 proposed treating .com as bindable alongside .exe, and that was
   adopted in 4f8252c. It is reverted here. Widening the durable authorization
   allowlist to another executable format is a separate decision with its own
   review, and it is out of scope for a change about carrier binding.
   IsBindableExecutable is .exe only again, and .com rejoins the
   non-bindable PATHEXT set.

   NormalizedBasename still strips .com, for one narrow reason that is now
   documented at the call site: IsLegacyQuarantinedHost has to recognize a
   provenance-less legacy entry naming powershell.com exactly as it recognizes
   powershell.exe, otherwise the D6 change in model would silently upgrade a
   case the old catalog refused outright. That is quarantine classification, not
   bindability. Both halves now have focused tests
   (NativeComExtensionTarget_DoesNotBind for the contract,
   ComExtension_QuarantinesAsTheSameCommandHostAsExe and
   LegacyPathOnlyEntryForACommandHostWithComExtension_IsInert for the
   transitional behavior).

2. Verify the pinned payload by reconstruction, not token comparison.

   PinnedCarrierMatchesRequest documented that all interior spacing must be
   byte-identical, but it only compared token values. A payload whose tokens
   matched while its spacing was rewritten passed. It now reconstructs the one
   payload the request is permitted to have become, by applying the executable
   token span edit to the request's own payload, and requires ordinal equality
   with the payload actually being executed. That single check subsumes argument
   values, argument count, and every byte of interior spacing.

   PinnedCarrier_RejectsInteriorSpacingChangesThatPreserveTokens covers a
   doubled space, a tab, a leading space, and a trailing space. Each asserts the
   tokens are still identical before asserting the match fails, so the rejection
   is attributable to spacing alone.

Docs and the architecture ledger are updated to say .exe only.

No local validation, rebase, push, or PR mutation was performed.

Co-authored-by: Copilot App <[email protected]>
Copilot-Session: 1223ff2c-11b6-48d9-937b-a56408e99b93
…antine

D6 asks a purely historical question about an allowlist entry that is already
on disk and carries neither provenance nor an argument binding: would this
exact entry have been refused durable approval when it was written? The answer
has to come from the catalog as it actually stood immediately before argument
binding replaced it, not from a fresh judgement about which programs look
dangerous today.

The previous revision restored that catalog from cdcb74f, which predates the
indirect-host expansion, so it silently dropped 28 names: mshta, regsvr32,
rundll32, msbuild, csc, vbc, dnx, rcsi, installutil, regasm, regsvcs,
mavinject, msiexec, certutil, bitsadmin, wmic, forfiles, scriptrunner, pcalua,
cmstp, odbcconf, msdt, ieexec, presentationhost, winrs, hh, msxsl and xwizard.
Every one of those was refused durable approval in the shipped release, so a
provenance-less entry naming one could only have been written under a model
that denied it. Leaving them out would have converted a denial into an
unconditional allow on upgrade, which is exactly the regression D6 exists to
prevent.

The catalog and IsVersionedInterpreter are now a verbatim copy of e4ff61e,
the last revision before binding replaced them (69 names, byte-identical and
in the same order). The accompanying comment states that this list must not be
curated, pruned or extended, because anything added would claim to have been
denied in a past release when it was not.

This does not reopen D4. The catalog is not the security boundary and cannot
become one: IsLegacyQuarantinedHost has exactly one call site
(ExecAllowlistMatcher.MatchInternal), reached only when an entry has no
ArgPattern and no Source. Every rule this node generates carries an argument
binding, so new rules never take that path. WindowsCodeHost_BindsOnlyToThe
ApprovedPayload still binds mshta, regsvr32 and rundll32 durably through
argument binding, unchanged.

Tests:
- LegacyPathOnlyEntryForACommandHost_IsInert gains mshta, rundll32, regsvr32,
  msbuild, certutil and wmic.
- LegacyQuarantineCoversTheFullPreBindingCatalog enumerates all 69 names and
  reports any that were dropped by name, so this class of truncation fails
  loudly rather than silently widening an allow.
- LegacyQuarantineCoversVersionedInterpreters covers python3, python3.12,
  pythonw3.11 and pypy3.10.
- LegacyQuarantineDoesNotCoverLookalikeNames pins that pythonish,
  python-wrapper and pypycache stay ordinary executables.
- LegacyPathOnlyEntryForAnOrdinaryExecutable_StillMatches is the unchanged
  control for hostname.exe, git.exe and rg.exe.

Co-authored-by: Copilot App <[email protected]>
Copilot-Session: 1223ff2c-11b6-48d9-937b-a56408e99b93
…com quarantine claim

Exact archaeology: e4ff61e's NormalizedBasename stripped `.exe` and nothing
else. A `.com` spelling therefore never normalized to a catalog name, was never
classified as a command host, and was never refused durable approval. The
previous revision of this branch taught NormalizedBasename to strip `.com` as
well so that a provenance-less entry naming `powershell.com` would go inert.
That inverted the very rule D6 exists to enforce: it invents a denial that
never happened, which is the same class of error as dropping one that did.

It was also far wider than intended. NormalizedBasename is shared by IsEnv, the
shell-wrapper normalizer, and the PowerShell and builtin classifiers, so the
extra strip silently changed what all of them recognize, well outside the
transitional quarantine it was meant to serve. A separate `.com` stripper for
the quarantine alone would have been no better, because the historical
behavior it must reproduce had no such concept at all.

NormalizedBasename is now byte-identical to e4ff61e (verified mechanically),
and a legacy entry naming `python.com` keeps working exactly as it did before.

Unchanged and re-verified:
- IsBindableExecutable is still `.exe` only, so a real Windows `.com` image is
  still refused durable binding. Bindability and legacy classification are
  independent questions and stay that way.
- The pre-binding catalog is still the complete verbatim 69-name copy from
  e4ff61e, with the exact versioned-interpreter logic.
- PinnedCarrierMatchesRequest still verifies by reconstruction, so interior
  spacing drift is still rejected.

Tests:
- ComExtension_QuarantinesAsTheSameCommandHostAsExe becomes
  ComExtension_IsNotLegacyQuarantined, asserting the opposite for the same
  three tokens.
- LegacyPathOnlyEntryForACommandHostWithComExtension_IsInert becomes
  ..._StillMatches.
- NativeComExtensionTarget_DoesNotBind is untouched: it is the bindability
  contract and is unaffected by classification.

Docs: the WINDOWS_NODE_ARCHITECTURE quarantine section drops the `.com`
spelling claim, names the indirect execution hosts now in the catalog, and
states the `.exe`-only matching rule with its rationale.

Co-authored-by: Copilot App <[email protected]>
Copilot-Session: 1223ff2c-11b6-48d9-937b-a56408e99b93
The quarantine section explained at length why a `.com` spelling is not
quarantined. The explanation was correct but it kept `.com` in front of the
reader in a section about which names were historically refused, which is
exactly the confusion to avoid. The rule is stated positively instead: the
quarantine compares a basename with only a `.exe` suffix stripped, exactly as
the original catalog did.

Versioned interpreters (`python3.12`) and the indirect execution hosts are
retained in the refused-outright list, since those were genuinely in the
historical catalog.

No behavior change. The `.com` reference remaining in this document is the
pre-existing non-executable extension list, which is about resolution rather
than quarantine.

Co-authored-by: Copilot App <[email protected]>
Copilot-Session: 1223ff2c-11b6-48d9-937b-a56408e99b93
ExecCommandResolver.HasCurrentDirectoryCandidate had zero callers once a trusted
carrier's payload executable token became pinned to its resolved absolute path.
Keeping it compiled "as a diagnostic" was the wrong disposition for a routine
that used to be an authorization boundary: a dead security check is an
invitation to wire it back up, and its own doc comment had to argue against
that. Deleting it removes the invitation.

The check was never sound as a boundary. It could only observe the working
directory as it stood when approval was granted, and anything able to write
there before launch simply wins after the check has passed. Pinning closes the
window properly: cmd performs no second resolution, so there is nothing left to
shadow.

TryGetProcessCurrentDirectory went with it; it had no other caller.

A comment in its place records what was removed and why, so the next reader
does not rediscover the idea and reintroduce it.

Docs:
- ARCHITECTURE ledger row `exec-carrier-cwd-ambiguity-check` no longer carries
  the helper as still-allowed, and its closure note is discharged. The invariant
  now states that ExecCommandResolver exposes no such method, so the ledger
  asserts the absence rather than tolerating the presence.
- WINDOWS_NODE_ARCHITECTURE no longer says the check is retained as a
  diagnostic.

No new test: no existing test referenced the helper, so there is no contract to
preserve or update.

Co-authored-by: Copilot App <[email protected]>
Copilot-Session: 1223ff2c-11b6-48d9-937b-a56408e99b93
Resolve the Windows node architecture documentation conflict while preserving main's schema clarification and the branch's reusable command binding design.

Co-authored-by: Copilot App <[email protected]>
Reconciles the exec-approval binding work with main's documentation
standardization pass (2439d43).

Conflict: docs/WINDOWS_NODE_ARCHITECTURE.md, one add/add at the exec-approvals
anchor. Both sides insert at the same point after the V2 migration example.
Resolved by union, main's text first: main's clarification that
`"version": 1` is the persisted file schema version and not the retired V1
evaluator, then this branch's D5/D6/D7 decision block. The two say different
things about different subjects and both are needed.

docs/ARCHITECTURE.md auto-merged. Verified afterwards that the ledger carries
all ten new rows: main's chat-tool-activity-renderer,
chat-history-replay-projection, reactor-tool-rendering-closed, and this
branch's exec-reusable-binding, exec-multi-segment-allowlist-closed,
canonical-cmd-carrier, exec-carrier-transport-identity,
cmd-payload-tokenization, exec-carrier-cwd-ambiguity-check,
exec-legacy-host-quarantine. No id collisions.

docs/OPENCLAW_GATEWAY_NODE_EXEC_FAQ.md is new on main and documented
pre-openclaw#1109 behavior as current, so merging without amending it would have left
main's own FAQ contradicting merged code. Three amendments:

- The approved identity for a strict canonical cmd carrier is the payload's
  resolved executable plus an exact argument pattern, not the command host.
  The existing `del` example is correct as written and kept, because a cmd
  built-in has no standalone executable to bind, so it stays prompt-only. Added
  a contrasting `hostname.exe` example where Allow Always is now permitted, and
  listed the cases that refuse binding and fall back to prompt-only.
- The "shell ambiguity" row now describes the actual mechanism: structural
  classification plus an exact argument pattern on every durable entry. Added
  the D6 legacy case, where a provenance-less entry stays valid for an ordinary
  executable but is inert for an interpreter or indirect host that was already
  refused durable approval when the entry could have been written.
- Source map row for Windows local approval now lists
  ExecReusableCommandBinder, CanonicalCmdCarrier, and CmdPayloadTokenizer,
  where durable identity derivation actually lives.

Also documented why the node must omit baseHash from the execApprovals.get
snapshot, quoting the upstream schema at
db90dff1396fecbf7029e9e9ea19d6c6ca3e644e: ExecApprovalsNodeSnapshotSchema sets
additionalProperties false at line 119 and guards `required: ["baseHash"]` at
line 126 inside the file branch's not.anyOf. A response carrying baseHash
alongside path/exists/hash/file matches no branch of the oneOf, so omitting it
is required for conformance rather than a tidiness choice. Recording the
citation here means the next reader does not have to re-derive it.

scripts/validate-docs.ps1 passes: 47 files checked.

Co-authored-by: Copilot App <[email protected]>
Copilot-Session: 1223ff2c-11b6-48d9-937b-a56408e99b93
Fourteen carrier tests failed on a machine with coreutils installed, and the
binder was right every time.

These tests bind a bare `hostname.exe` payload, which resolves through PATH.
The assumption was that PATH yields `C:\Windows\System32\hostname.exe`. With
coreutils installed it yields `C:\Program Files\coreutils\bin\hostname.exe`
instead, and that path contains a space. Under `cmd /s` the first and last quote
of the payload are stripped and the rest is used verbatim, so a spaced path
cannot be pinned without changing what cmd executes. The binder refuses and
returns CarrierPayloadNotPinnable, which is the accepted D7 fail-closed
behavior. The tests were asserting on ambient machine state, not on the code.

Confirmed by probe against the real binder:

    Resolve(hostname.exe).ResolvedPath: [C:\Program Files\coreutils\bin\hostname.exe]
    TryBuildPinnedCarrier: False
    TryBind -> bound=<null> failure=CarrierPayloadNotPinnable

Two fixes, chosen by what each layer can express:

Binder-level tests pin PATH to the system directory through the existing `env`
argument, so a bare name still has to be resolved through PATH and the behavior
under test is unchanged. New ExecTestPath helper holds that, with the reasoning,
so the next person does not reintroduce a process-PATH dependency.
BareCmdResolvingOutsideSystemDirectory_ExecutesTheSystemImage keeps its rogue
directory first but now also has the system directory on PATH, since otherwise
the payload cannot resolve at all and the test fails before reaching its claim.

Coordinator-level tests cannot do that. ExecApprovalV2InputValidator denies a
non-empty env with custom-env-not-supported, so a request cannot carry a PATH
and resolution always uses the process PATH. Those three tests name the payload
absolutely instead. They are about the coordinator's authorize-and-execute
wiring, which an absolute payload exercises identically, and bare-name
resolution stays covered at the binder level where env can be injected.

This also means the spaced-path refusal now has real-world evidence rather than
only a synthetic test: an ordinary developer machine produced exactly the case
D7 fails closed on.

Validation on this commit:
  Shared    3618 total, 3586 passed, 0 failed, 32 skipped
  Tray      2165 total, 2165 passed, 0 failed
  WinNode   126 total, 126 passed, 0 failed

Co-authored-by: Copilot App <[email protected]>
Copilot-Session: 1223ff2c-11b6-48d9-937b-a56408e99b93
…ning and currency

Adversarial review of the exec-approval binding work surfaced two real
defects that focused tests now cover.

1. Versioned executables could bind and then hard-fail at execution.
   PinnedCarrierMatchesRequest required the request name to have no
   extension before allowing the pinned name to carry one. But
   Path.HasExtension("python3.11") is true (it sees ".11"), so a
   versioned tool bound successfully at authorization time and then
   failed at execution time with InternalError(unresolved-executable-on-allow).
   The rule is now simply: the pinned name equals the request name, or
   the request name plus exactly one appended extension. Stem identity is
   still required, so a pinned name with a different stem is rejected.

2. The mid-approval policy guard could miss a tightened grant.
   ExecApprovalsCurrency fingerprinted allowlist entries by Pattern only,
   so adding an argPattern, narrowing an existing argPattern, or marking a
   path-only entry as generated was invisible to IsStillCurrent. The
   fingerprint is now the (Pattern, ArgPattern, Source) triple. Pattern
   keeps case-insensitive comparison for Windows paths while ArgPattern
   and Source compare ordinally, using a comparer rather than case folding
   so the ToUpperInvariant/ToLowerInvariant round-trip pitfall cannot
   collapse distinct identities.

Neither change relaxes an authorization decision: both make a previously
silent acceptance fail closed or bind correctly.

Co-authored-by: Copilot App <[email protected]>
Copilot-Session: 1223ff2c-11b6-48d9-937b-a56408e99b93
…roof hermetic

Second adversarial reviewer findings.

Accepted: source gating in ExecAllowlistMatcher was fail-open.
A path-only entry was treated as generated (and therefore inert) only when
its source was exactly "allow-always" under an ordinal comparison. Any other
non-empty value - a different case, a padded string, a marker written by
another producer, or a corrupted one - fell through to the path-only branch.
That was fail-open twice over: the entry gained path-only reach, and because
its source was non-empty it also skipped the legacy quarantine check. The
rule is now simply that any non-empty source means a generator produced the
entry, so a generated entry that lost its argPattern is inert regardless of
spelling. Provenance is absent only when source is empty or whitespace, and
those entries keep hand-written path-only semantics behind the quarantine
check exactly as before. No entry that used to be denied becomes allowed.

Rejected: persisted command text as a secret-disclosure regression.
The reviewer proposed redacting CommandText/LastUsedCommand and filtering
them out of system.execApprovals.get. That does not mitigate the stated risk
and would break two contracts. ArgPattern already encodes the exact argv and
is load-bearing for authorization, so arguments are on disk either way;
redaction would only stop an operator from auditing what they approved. The
get payload is returned verbatim and its hash is the concurrency token for a
matching set, so filtering the bytes would break read-modify-write. Returning
the file from execApprovals.get also predates this branch. The invariant is
recorded on the contract instead.

Also makes the MXC exec-approval proof hermetic. It used hostname.exe, which
is commonly shadowed on a developer PATH by a copy in a directory the sandbox
does not grant, so the proof could fail for reasons that have nothing to do
with approvals. It now uses whoami.exe, which has no common shadow.

Co-authored-by: Copilot App <[email protected]>
Copilot-Session: 1223ff2c-11b6-48d9-937b-a56408e99b93
…ture

The MXC exec-approval proofs already tolerated one shape of "this host cannot
spawn a child executable inside the AppContainer": exit code 0xC0000142,
STATUS_DLL_INIT_FAILED. The same incapacity also appears as CreateProcess being
refused outright, which cmd reports as exit code 1 with "Access is denied." on
stderr. On a host expressing the second shape the proofs failed as if approvals
were broken, which is the wrong report.

The evidence that this is a host property and not an approvals or binding
problem is the child-spawn diagnostic, which runs with grant=none. No allowlist
entry participates, nothing is bound, and the carrier executes exactly as the
gateway sent it, with a bare executable name and no pinned path. It still
fails, while the echo builtin in the same payload and the same container
succeeds. It also reproduces under security=full. So it is not caused by
argument binding, by pinning a payload to a resolved absolute path, or by any
V2 decision.

The tolerance is deliberately narrow: exit code 1 together with exactly that
stderr message. It does not weaken what these tests prove. Each caller
separately asserts the approval decision and the MXC request shape from the
tray log, and a real approvals regression surfaces as decision=deny or a node
error rather than this signature. Any other nonzero exit code still fails.

Documents the limitation and its validation consequences in the gateway node
exec FAQ.

Co-authored-by: Copilot App <[email protected]>
Copilot-Session: 1223ff2c-11b6-48d9-937b-a56408e99b93
…ity, not failure

On a host that cannot spawn a child executable inside the MXC AppContainer, the
sandbox run does not always come back with a clean nonzero exit. Observed here:
wxc-exec starts the container, the node logs decision=allow, and the run then
never returns a result at all, so the gateway CLI call gives up and the probe
fails before it can read any payload. That surfaced as an approvals proof
failing at AssertCommandSucceeded, which blames exec approvals for a
sandbox-runtime limitation of the host.

The child-spawn diagnostic now reports an incomplete probe as what it is: host
capability could not be established. This test asserts no approvals behavior,
so nothing is being swallowed. The approval decision and the MXC request shape
are asserted by the two bound-rule proofs, which still fail normally, and every
other nonzero exit code is still a failure everywhere else.

Co-authored-by: Copilot App <[email protected]>
Copilot-Session: 1223ff2c-11b6-48d9-937b-a56408e99b93
…ding

Merges the live PR head (d192ed1), which carried the contributor's
b9be5f4 "verify resolved cmd carrier identity" plus a second merge of
origin/main that this branch already contained.

Kept from b9be5f4:

- Its security intent. b9be5f4 added IsTrustedSystemCmdPath and called it
  from the binder so a bare "cmd.exe" resolving outside a Windows system
  directory could not be looked through. This branch already enforces that
  invariant more strongly: ResolveTrustedCarrierPath rejects the same case
  and additionally yields the absolute system image, which
  TryBuildPinnedCarrier pins into argv[0]. The rogue image is therefore not
  merely detected at approval time, it is never what runs. The predicate is
  dropped as a zero-caller duplicate and its assertion is folded into
  SystemDirectoryCmd_IsTrustedCarrier against the surviving owner.
- Its documentation corrections about the live gateway carrier shape: the
  gateway sends one pre-joined command element, and reconstructible
  multi-element tails exist for low-level callers and upstream fixtures
  rather than being the gateway's own shape.

Not taken from b9be5f4:

- Widening durable bindability from .exe to .exe/.com in
  IsBindableExecutable. Adding an image format to the durable authorization
  allowlist is a separate decision with its own review, not a detail of
  carrier binding. A .com target remains runnable and prompt-only, which is
  the fail-closed side.
- Widening ExecCommandToken.NormalizedBasename to strip .com. That helper is
  shared by IsEnv, the shell-wrapper normalizer, the PowerShell and builtin
  classifiers, and IsLegacyQuarantinedHost, so widening it silently changes
  what all of them recognize. The legacy quarantine reproduces the catalog as
  it actually was at e4ff61e, where only .exe was stripped and a .com
  spelling was never classified or refused; quarantining one now would invent
  a denial that never happened.

These two are coherent only as a pair. Binding .com without also classifying
it would let powershell.com bind unquarantined, so both are declined together
and the existing guard tests (NativeComExtensionTarget_DoesNotBind,
NonExecutableExtensionTarget_DoesNotBind, ComExtension_IsNotLegacyQuarantined)
continue to pin that.

Also dropped b9be5f4's re-added IsIndirectCommandHost theories, which name a
symbol this branch replaced with IsLegacyQuarantinedHost, and its
NativeComExtensionTarget_Binds test, which asserts the declined behavior.

Validation: build.ps1 exit 0 (47 docs), Shared 3606 passed / 0 failed / 32
skipped of 3638, Tray 2165 passed / 0 failed, WinNode.Cli 126 passed / 0
failed.

Co-authored-by: Copilot App <[email protected]>
Copilot-Session: 1223ff2c-11b6-48d9-937b-a56408e99b93
Adversarial review found that the two launch-time pins were applied only when
execution went through the reusable transport, which was selected for durable
allows and match-dependent fallback allows but not for a one-time Allow Once.

An Allow Once therefore executed the request's own argv: argv[0] was the
request's PATH-resolved cmd.exe, and a bare payload name stayed bare for cmd to
resolve again at launch, searching the working directory before PATH. The prompt
meanwhile names the inner executable the binder resolved through a trusted
system cmd.exe, so the operator approved one image while a different one could
run. With a writable directory ahead of the system directory on the node's PATH,
approving a command once could execute attacker-controlled code.

Approval identity, durability, and execution transport are three separate
things. Route a recognized canonical carrier through its pinned transport
whenever one exists, independent of durability. Durability is still gated on
requiresReusableExecution, so a one-time allow persists nothing.

Regression test asserts the pinned payload token; it fails without this change
with the token still bare. The test discovers a bindable payload from a
candidate list because a coordinator request cannot carry a custom env and a
shadowed system name can resolve under a spaced path.

Co-authored-by: Copilot App <[email protected]>
Copilot-Session: 1223ff2c-11b6-48d9-937b-a56408e99b93
Follow-up to ce0a3cb from the same adversarial review, which found two more
paths that still executed an image other than the one the operator approved.

1. The pre-approved branch chose the reusable transport only for an allowlist
   hit, so a security=full/ask=off run reached process launch with the carrier
   unpinned: argv[0] resolved through PATH and a bare payload token stayed bare
   for cmd to resolve again at launch. Full policy already permits arbitrary
   execution, so this is not an authorization escalation, but it left the
   "every approved run is pinned" invariant untrue and the two allow branches
   inconsistent.

2. A direct command is resolved twice, once by the normalizer for the execution
   identity and once by the binder for the identity that is displayed and
   stored. Execution used the normalizer's, so the prompt could name one image
   while a separate lookup of the same name selected another.

Both collapse into one rule, so transport selection now lives in a single
helper used by both decision points: whenever the binder produced a reusable
command, that command's argv is what runs. This is safe for direct commands
because BindDirect already applies the same env-wrapper unwrapping and modifier
rejection as BuildApprovedExecution and adds strictly more gates, so only the
source of the resolved executable changes.

Durability is unchanged and still gated separately, so no allow persists
anything it did not persist before.

PreApprovedFullPolicy_CanonicalCarrier_ExecutesThePinnedCarrier fails without
this change with the payload token still bare.

Co-authored-by: Copilot App <[email protected]>
Copilot-Session: 1223ff2c-11b6-48d9-937b-a56408e99b93
@clawsweeper clawsweeper Bot added proof: 📸 screenshot Contributor real behavior proof includes screenshot evidence. rating: 🧂 unranked krab Not merge-ready due to missing proof or serious correctness/safety concerns. and removed rating: 🦪 silver shellfish Thin PR readiness signal; proof, validation, or implementation needs work. labels Aug 7, 2026
@calebeden

Copy link
Copy Markdown
Contributor Author

Caleb Eden + GitHub Copilot pair-programming follow-up

@shanselman Thanks for the extensive hardening work. The latest 22 commits substantially redesign the original executable-binding approach around argument patterns, provenance-aware migration, and pinned carrier execution.

Since you are now driving the underlying authorization model, could you take ownership of the remaining implementation and validation? My review found three follow-ups in the current head:

  • Node-side rawCommand validation is stricter than upstream for trimmed text and safe PowerShell/POSIX wrapper previews.
  • Handwritten argPattern rules use .NET regex semantics, which can differ from the gateway’s JavaScript regex semantics.
  • Allowlist normalization deduplicates by (pattern, argPattern) even though source affects whether an entry authorizes anything, which can suppress a valid manual rule.

These appear fail-closed or limited to handwritten/low-level callers, but they are consequences of the redesigned model rather than the original fix. I would prefer not to keep layering contributor patches over an architecture you are actively revising.

@shanselman
shanselman merged commit c9608c8 into openclaw:main Aug 7, 2026
32 of 34 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

merge-risk: 🚨 compatibility 🚨 Merging this PR could break existing users, config, migrations, defaults, or upgrades. 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. proof: 📸 screenshot Contributor real behavior proof includes screenshot evidence. rating: 🧂 unranked krab Not merge-ready due to missing proof or serious correctness/safety concerns. 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.

2 participants