Skip to content

Commit 59d1301

Browse files
committed
Merge origin/main into bkudiess-connection-analysis
Co-authored-by: Copilot App <[email protected]> Copilot-Session: 84bc73e4-939a-4e25-ba88-26af9f4fc8b5
2 parents bb78e54 + 20d29e1 commit 59d1301

56 files changed

Lines changed: 6974 additions & 502 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

‎docs/ARCHITECTURE.md‎

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -146,6 +146,13 @@ leading and trailing pipe. Columns, in order:
146146
| functional-chat-default-mount | closed | src/OpenClaw.Tray.WinUI/Chat/FunctionalChatHostExtensions.cs | mounting the FunctionalUI chat tree as the default ChatPage or ChatWindow surface | ReactorChatHostExtensions and OpenClawReactorChatRoot | legacy FunctionalUI chat files may remain for focused compatibility coverage only | ChatPage and ChatWindow mount the Reactor root directly into their existing ChatHost Borders; no FunctionalUI component mounts or nests Reactor on the default path | review-only: user explicitly deferred new tests for this migration; required build and existing shared/tray suites still run | review-only | when legacy FunctionalUI chat surfaces are removed |
147147
| settings-store | authoritative | src/OpenClaw.Tray.WinUI/Pages/SettingsPage.xaml.cs | hand-rolled save/echo suppression flags for two-way settings binding | ISettingsStore | PermissionsPage and other surfaces may read SettingsManager directly until migrated | a save originating from Update does not echo Changed to the caller and external saves are republished on the UI thread | SettingsStoreTests.Update_DoesNotEchoChangedToSelf | behavioral | when all settings surfaces read and write through ISettingsStore |
148148
| settings-page-vm | authoritative | src/OpenClaw.Tray.WinUI/Pages/SettingsPage.xaml.cs | settings load, persist, echo-guard, and auto-save wiring | SettingsPageViewModel | code-behind keeps gateway-uninstall, gateway-info and uptime timer, saved-indicator visual, and app-info population | each settings control persists its field through the store preserving mutate-save-notify order and does not re-persist on external change | SettingsPageViewModelTests.ExternalChange_ReloadsWithoutRePersisting | behavioral | when the Settings page holds no settings persistence logic in code-behind |
149+
| exec-reusable-binding | authoritative | src/OpenClaw.Shared/ExecApprovals/ExecCommandResolution.cs | deriving durable allowlist identities and Allow Always patterns from multi-segment shell resolution | ExecReusableCommandBinder | ExecCommandResolver.Resolve stays the singular resolution used by the state machine and prompt display | at most one identity may be durably authorized per request and it is a fully qualified existing `.exe` image whose arguments are pinned by the generated rule | ExecReusableCommandBinderTests.MultiElementCarrierTail_Binds | behavioral | - |
150+
| exec-multi-segment-allowlist-closed | closed | src/OpenClaw.Shared/ExecApprovals/ExecCommandResolution.cs | ResolveForAllowlist and ResolveAllowAlwaysPatterns feeding allowlist matching or Allow Always patterns | ExecReusableCommandBinder | the two methods remain compiled with their historical tests until removed but have no production callers | the approval pipeline derives AllowlistResolutions and AllowAlwaysPatterns only from ExecReusableCommandBinder.TryBind | ExecApprovalV2NormalizationPipelineOwnershipTests.Normalizer_DerivesDurableIdentity_OnlyFromReusableBinder | source-shape | when ResolveForAllowlist and ResolveAllowAlwaysPatterns are deleted |
151+
| canonical-cmd-carrier | authoritative | src/OpenClaw.Shared/Mxc/MxcConfigBuilder.cs | recognizing the cmd.exe /d /s /c carrier and extracting its command payload | CanonicalCmdCarrier | MxcConfigBuilder keeps cmd command-mode switch detection and command-line construction | the approvals binder and the MXC command-line builder agree on which argv shapes are the canonical cmd carrier and what payload they carry | CanonicalCmdCarrierTests.BinderAndMxcBuilder_AgreeOnCarrierRecognition | behavioral | - |
152+
| exec-carrier-transport-identity | authoritative | src/OpenClaw.Shared/ExecApprovals/ExecApprovalsCoordinator.cs | deciding what a trusted canonical cmd carrier executes once its inner payload is durably authorized | ExecReusableCommandBinder builds the execution argv; CanonicalCmdCarrier.PinnedCarrierMatchesRequest enforces it | the coordinator still owns prompt, policy, and persistence decisions | a durably approved carrier executes a reconstruction of the validated carrier so the MXC in-band PATH/TEMP bootstrap survives; exactly two tokens may differ from the request, argv[0] pinned to the resolved System32 or SysWOW64 cmd.exe and the payload executable token pinned to its resolved absolute path, with every other token and all interior spacing ordinal-identical so no metacharacter drift can be introduced | ExecReusableCommandBinderTests.TrustedCarrier_KeepsTransportSeparateFromIdentity | behavioral | when MXC accepts an explicit environment and the bound direct argv can be executed instead |
153+
| cmd-payload-tokenization | authoritative | src/OpenClaw.Shared/ExecApprovals/ExecReusableCommandBinder.cs | parsing a cmd payload into tokens and rewriting its executable token | CmdPayloadTokenizer | ExecReusableCommandBinder.TryTokenizeStaticCmdPayload remains as a delegating wrapper for existing callers and tests | a payload rewrite is built from parsed token spans and is accepted only after re-parsing proves the argument list is unchanged except for the pinned executable | ExecReusableCommandBinderTests.PinnedCarrier_DoesNotRewriteArgumentsThatRepeatTheExecutableText | behavioral | - |
154+
| exec-carrier-cwd-ambiguity-check | closed | src/OpenClaw.Shared/ExecApprovals/ExecReusableCommandBinder.cs | deciding whether a carrier payload may be durably approved when the working directory could shadow it | CanonicalCmdCarrier.TryBuildPinnedCarrier (payload executable pinning) | - | the approval-time working-directory check is deleted, not merely bypassed: ExecCommandResolver exposes no HasCurrentDirectoryCandidate, a trusted carrier's payload executable is pinned to its resolved absolute path so cmd has nothing to search for, and a post-approval shadow cannot win | ExecReusableCommandBinderTests.PinnedCarrier_IgnoresShadowInsertedAfterApproval | behavioral | - |
155+
| exec-legacy-host-quarantine | authoritative | src/OpenClaw.Shared/ExecApprovals/ExecCommandToken.cs | deciding whether a provenance-less path-only allowlist entry authorizes an interpreter or code host | ExecAllowlistMatcher.MatchInternal via ExecCommandToken.IsLegacyQuarantinedHost | argument binding remains the security boundary for every rule this node generates | an allowlist entry with no source and no argPattern is inert when its resolved target is a command host the previous model refused, is never deleted or migrated, and is superseded only by an explicit allow-always sibling carrying source and argPattern | ExecAllowlistArgBindingTests.LegacyPathOnlyEntryForACommandHost_IsInert | behavioral | - |
149156
<!-- LEDGER:END -->
150157

151158
## Deferred test builders

‎docs/OPENCLAW_GATEWAY_NODE_EXEC_FAQ.md‎

Lines changed: 88 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -154,6 +154,31 @@ This preserves the authority split:
154154
Windows compare-and-swap and monotonicity checks are in
155155
[`SystemCapability.cs`](https://github.com/openclaw/openclaw-windows-node/blob/d7d153ca5d409487e06ef584b1de1184520e90e6/src/OpenClaw.Shared/Capabilities/SystemCapability.cs#L449-L698).
156156

157+
`baseHash` travels in one direction only, and the upstream schema enforces that.
158+
In
159+
[`exec-approvals.ts`](https://github.com/openclaw/openclaw/blob/db90dff1396fecbf7029e9e9ea19d6c6ca3e644e/packages/gateway-protocol/src/schema/exec-approvals.ts#L104-L165),
160+
`ExecApprovalsNodeSnapshotSchema` sets `additionalProperties: false` at line 119
161+
and its no-file branch lists `{ required: ["baseHash"] }` at line 126 inside a
162+
`not.anyOf` guard:
163+
164+
```ts
165+
additionalProperties: false,
166+
oneOf: [
167+
{
168+
required: ["path", "exists", "hash", "file"],
169+
not: {
170+
anyOf: [
171+
{ required: ["enabled"] },
172+
{ required: ["baseHash"] },
173+
```
174+
175+
A `get` response carrying `path`, `exists`, `hash`, `file`, and `baseHash`
176+
therefore matches no branch of the `oneOf` and is rejected by the gateway. The
177+
node must omit `baseHash` from the snapshot it returns. A client reads `hash`
178+
from that snapshot and passes it back as `baseHash` on the next `set`, which is
179+
how the compare-and-swap closes. Omitting it from the response is required for
180+
protocol conformance, not merely tidier.
181+
157182
## What happens when a user says "delete this"?
158183
159184
There is no universal "delete subsystem." The gateway agent first resolves what
@@ -224,12 +249,26 @@ gateway can build:
224249
225250
The gateway evaluates its `host=node` policy, dispatches `system.run`, and
226251
Windows separately evaluates the exact wrapper and payload under V2 before MXC
227-
or host execution. Windows resolves `argv[0]` to `cmd.exe`, so the approved
228-
executable is the command host itself. The inner `del` payload is considered
229-
for allowlist matching, but a shell built-in cannot resolve as a standalone
230-
executable. **Allow once** can run the command; **Allow always** is rejected
231-
with `persistent-approval-not-permitted-for-command-host` rather than creating
232-
a durable grant for general `cmd.exe` execution.
252+
or host execution. Windows recognizes the strict canonical `cmd.exe /d /s /c`
253+
carrier and looks through it to the payload, so the durable approval identity is
254+
the payload's resolved executable plus an exact argument pattern, not the command
255+
host. The carrier itself is never the approved identity.
256+
257+
In this specific example the payload is `del`, a `cmd` built-in with no standalone
258+
executable to resolve, so nothing is bindable: **Allow once** can run the command
259+
and **Allow always** is still rejected with
260+
`persistent-approval-not-permitted-for-command-host`. A payload that does resolve
261+
to a real `.exe` behaves differently. For
262+
`["cmd.exe","/d","/s","/c","hostname.exe"]`, **Allow always** is permitted and
263+
records `C:\Windows\System32\hostname.exe` with an argument pattern that matches
264+
only that exact argument list. It does not create a durable grant for general
265+
`cmd.exe` execution.
266+
267+
Binding is refused, leaving the request prompt-only, when the payload executable
268+
is not a plain `.exe`, when the payload cannot be tokenized unambiguously, when
269+
the resolved path contains a space or other character that `cmd /s` would not
270+
preserve verbatim, or when the carrier is not the strict canonical form. Fail
271+
closed is the intended outcome in each of those cases.
233272
234273
## How does agent `exec` become node `system.run`?
235274
@@ -465,7 +504,7 @@ boundary.
465504
| --- | --- | --- |
466505
| Input identity | Shell command text | Canonical argv plus resolved executable identity |
467506
| Typical rule | Command-text glob | Executable/argument-aware allowlist entries |
468-
| Shell ambiguity | Rule could accidentally authorize a reusable command host such as `cmd.exe` or PowerShell | Shell wrappers are normalized and indirect command hosts cannot receive unsafe persistent approval |
507+
| Shell ambiguity | Rule could accidentally authorize a reusable command host such as `cmd.exe` or PowerShell | Shell wrappers are structurally classified and bound to an exact argument pattern, so an indirect command host cannot receive unsafe persistent approval |
469508
| Prompt result | Legacy behavior | Explicit allow-once or allow-always, with deny |
470509
| Race handling | Limited | Policy snapshot and execution-boundary revalidation |
471510
| Execution | Could reparse shell text | Approved absolute executable and argv are passed to the runner |
@@ -476,6 +515,21 @@ mechanically converted. Conversion could widen a narrow-looking text rule into
476515
a grant for a general command interpreter. Existing V1 approvals therefore
477516
require a new attended decision under V2.
478517
518+
The mechanism behind the "shell ambiguity" row is structural, not a maintained
519+
list of dangerous program names. A resolved executable is classified by shape as
520+
a shell wrapper, interpreter, or code host, and every durable entry written by
521+
V2 carries an argument pattern that must match the exact argument list. A name
522+
catalog is not the security boundary, because renaming a binary would defeat it.
523+
524+
One narrow legacy case remains. An allowlist entry written before argument
525+
binding existed has neither a recorded source nor an argument pattern. Such an
526+
entry stays valid for an ordinary executable, but it is inert when its resolved
527+
executable is one of the interpreters or indirect command hosts that were
528+
already refused durable approval at the time the entry could have been written.
529+
Those requests prompt instead of matching. The entry is not deleted and is not
530+
silently upgraded; only an explicit **Allow always** creates a new
531+
argument-bound entry that can match.
532+
479533
Do not confuse the pipeline name with the persisted schema field.
480534
`exec-approvals.json` currently contains `"version": 1`; that is the file
481535
format version used by the V2 pipeline. Also, the store's "legacy migration"
@@ -563,6 +617,32 @@ Upstream also has separate sandbox and plugin concepts:
563617
Those extension points do not make MXC a gateway plugin. They are separate
564618
layers with different owners.
565619
620+
### Host limitation: some hosts cannot spawn a child executable under MXC
621+
622+
On some Windows hosts the AppContainer starts and runs `cmd` builtins, but the
623+
first child executable it tries to launch never runs. Two signatures have been
624+
observed for the same underlying incapacity:
625+
626+
- the child dies during DLL initialization, reported as exit code `0xC0000142`
627+
(`STATUS_DLL_INIT_FAILED`);
628+
- `CreateProcess` is refused outright, reported as exit code `1` with
629+
`Access is denied.` on stderr.
630+
631+
This is a sandbox-runtime property of the host. It is independent of exec
632+
approvals: it reproduces with `security=full`, with no allowlist entry
633+
involved, and with the command executed exactly as the gateway sent it, so it
634+
is not caused by argument binding, by pinning a payload to a resolved absolute
635+
path, or by any V2 decision. A `cmd` builtin such as `echo` still succeeds in
636+
the same container, which is what isolates the failure to process creation.
637+
638+
Consequences for validation on such a host: approval decisions are still
639+
provable end to end through a real gateway, because the decision is asserted
640+
from the node's own log and from the MXC request shape. Whether the approved
641+
command then produces output is not provable there. The MXC E2E records this
642+
explicitly rather than passing quietly, and it never tolerates any other
643+
nonzero exit code. See `Diagnostic_SystemRun_SpawnsChildExecutableInSandbox`
644+
and `AssertApprovedCommandRan` in `tests/OpenClaw.E2ETests/Setup/MxcSetupAndConnectTests.cs`.
645+
566646
By default, Windows enables sandboxing but preserves a compatibility host
567647
fallback if MXC is unavailable. Enabling **block host fallback when MXC is
568648
unavailable** changes that case to a deny. The actual result reports whether
@@ -695,7 +775,7 @@ Any layer can deny. A later layer cannot widen an earlier deny.
695775
| Exec host routing | n/a, Windows is the target host | `bash-tools.exec-run.ts`, `bash-tools.exec-host-gateway.ts`, `bash-tools.exec-host-node.ts` |
696776
| Shell argv construction | `LocalCommandRunner` for its legacy shell path; V2 approved runs are direct argv | `src/infra/node-shell.ts` |
697777
| Gateway node invoke gates | node receives only the post-gate request | `src/gateway/server-methods/nodes.invoke.ts` |
698-
| Windows local approval | `ExecApprovalsCoordinator`, `ExecApprovalsStore` | comparable node-host exec approval contracts |
778+
| Windows local approval | `ExecApprovalsCoordinator`, `ExecApprovalsStore`, `ExecReusableCommandBinder`, `CanonicalCmdCarrier`, `CmdPayloadTokenizer` | comparable node-host exec approval contracts |
699779
| Windows sandbox | `MxcCommandRunner`, `MxcPolicyBuilder`, `DirectAppContainerExecutor` | separate agent sandbox backend interfaces |
700780
| Protocol version | connect payloads | `packages/gateway-protocol/src/version.ts` |
701781
| Managed gateway release | `GatewayLkgVersion.cs`, setup engine | OpenClaw tag `v2026.6.11` |

0 commit comments

Comments
 (0)