Repository navigation
Commit c9608c8
fix: honor exec allowlists for Windows node commands (#1109)
* fix: align exec approval snapshot schema
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]>
* fix: bind reusable Windows exec commands
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]>
* fix: harden reusable exec host checks
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]>
* fix: correct carrier recognition and tighten reusable exec binding
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
* fix: only look through a trusted system cmd carrier
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
* fix: verify resolved cmd carrier identity
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]>
* fix(exec-approvals): bind durable approvals to arguments, not executable 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
* fix(exec-approvals): execute trusted carriers via resolved System32 path
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
* docs+test: document argPattern identity model and prove CAS stale-hash 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
* fix: close three authorization holes in exec approval binding
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
* fix: harden the exec approval authorization checks against bypass
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
* docs: record the carrier payload resolution rule and its residual risk
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
* fix: hash retained-entry identities to keep the remote set check bounded
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
* fix: quarantine legacy command-host rules and pin the trusted cmd carrier
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
* test: harden pinned-carrier coverage and reconcile .com classification
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
* fix: keep durable binding .exe-only and verify pinned payloads by reconstruction
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
* fix(exec-approvals): restore the full pre-binding catalog for D6 quarantine
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
* fix(exec-approvals): keep NormalizedBasename .exe-only and drop the .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
* docs: drop the .com discussion from the legacy quarantine section
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
* refactor: delete the superseded working-directory ambiguity helper
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
* test: make carrier binding tests independent of the developer's PATH
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
* fix(exec-approvals): close two adversarial-review gaps in carrier pinning 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
* fix(exec-approvals): fail closed on any provenance marker; make MXC proof 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
* test(mxc-e2e): recognize the second host child-spawn incapacity signature
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
* test(mxc-e2e): report an incomplete child-spawn probe as host capability, 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
* fix: pin the canonical cmd carrier for one-time allows too
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
* fix: pin execution transport on every approved exec path
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
---------
Co-authored-by: Copilot App <[email protected]>
Co-authored-by: Scott Hanselman <[email protected]>
Copilot-Session: 1223ff2c-11b6-48d9-937b-a56408e99b931 parent 01faa64 commit c9608c8
40 files changed
Lines changed: 5359 additions & 205 deletions
File tree
- docs
- src
- OpenClaw.WinNode.Cli
- tests
- OpenClaw.E2ETests/Setup
- OpenClaw.Tray.IntegrationTests
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
144 | 144 | | |
145 | 145 | | |
146 | 146 | | |
| 147 | + | |
| 148 | + | |
| 149 | + | |
| 150 | + | |
| 151 | + | |
| 152 | + | |
| 153 | + | |
147 | 154 | | |
148 | 155 | | |
149 | 156 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
154 | 154 | | |
155 | 155 | | |
156 | 156 | | |
| 157 | + | |
| 158 | + | |
| 159 | + | |
| 160 | + | |
| 161 | + | |
| 162 | + | |
| 163 | + | |
| 164 | + | |
| 165 | + | |
| 166 | + | |
| 167 | + | |
| 168 | + | |
| 169 | + | |
| 170 | + | |
| 171 | + | |
| 172 | + | |
| 173 | + | |
| 174 | + | |
| 175 | + | |
| 176 | + | |
| 177 | + | |
| 178 | + | |
| 179 | + | |
| 180 | + | |
| 181 | + | |
157 | 182 | | |
158 | 183 | | |
159 | 184 | | |
| |||
224 | 249 | | |
225 | 250 | | |
226 | 251 | | |
227 | | - | |
228 | | - | |
229 | | - | |
230 | | - | |
231 | | - | |
232 | | - | |
| 252 | + | |
| 253 | + | |
| 254 | + | |
| 255 | + | |
| 256 | + | |
| 257 | + | |
| 258 | + | |
| 259 | + | |
| 260 | + | |
| 261 | + | |
| 262 | + | |
| 263 | + | |
| 264 | + | |
| 265 | + | |
| 266 | + | |
| 267 | + | |
| 268 | + | |
| 269 | + | |
| 270 | + | |
| 271 | + | |
233 | 272 | | |
234 | 273 | | |
235 | 274 | | |
| |||
465 | 504 | | |
466 | 505 | | |
467 | 506 | | |
468 | | - | |
| 507 | + | |
469 | 508 | | |
470 | 509 | | |
471 | 510 | | |
| |||
476 | 515 | | |
477 | 516 | | |
478 | 517 | | |
| 518 | + | |
| 519 | + | |
| 520 | + | |
| 521 | + | |
| 522 | + | |
| 523 | + | |
| 524 | + | |
| 525 | + | |
| 526 | + | |
| 527 | + | |
| 528 | + | |
| 529 | + | |
| 530 | + | |
| 531 | + | |
| 532 | + | |
479 | 533 | | |
480 | 534 | | |
481 | 535 | | |
| |||
563 | 617 | | |
564 | 618 | | |
565 | 619 | | |
| 620 | + | |
| 621 | + | |
| 622 | + | |
| 623 | + | |
| 624 | + | |
| 625 | + | |
| 626 | + | |
| 627 | + | |
| 628 | + | |
| 629 | + | |
| 630 | + | |
| 631 | + | |
| 632 | + | |
| 633 | + | |
| 634 | + | |
| 635 | + | |
| 636 | + | |
| 637 | + | |
| 638 | + | |
| 639 | + | |
| 640 | + | |
| 641 | + | |
| 642 | + | |
| 643 | + | |
| 644 | + | |
| 645 | + | |
566 | 646 | | |
567 | 647 | | |
568 | 648 | | |
| |||
695 | 775 | | |
696 | 776 | | |
697 | 777 | | |
698 | | - | |
| 778 | + | |
699 | 779 | | |
700 | 780 | | |
701 | 781 | | |
0 commit comments