Skip to content

fix(exec): PowerShell /c and bash -l -c can be saved as allow-always rules - #1511

Merged
bkudiess merged 21 commits into
openclaw:mainfrom
SebTardif:fix/f108-inline-shell-allow-rules
Oct 20, 2026
Merged

bkudiess merged 21 commits into
openclaw:mainfrom
SebTardif:fix/f108-inline-shell-allow-rules

Conversation

@SebTardif

@SebTardif SebTardif commented Sep 24, 2026 •

Copy link
Copy Markdown
Contributor

What Problem This Solves

Fixes: Allow always can save PowerShell -c and Bash -l -c inline commands as reusable rules, so a later command can run without a fresh prompt.

User Impact

Inline shell commands stay one-time. A direct program, a direct script, and Bash noclobber -C can still be reusable. A previously saved allow-always rule for a newly recognized inline command stays on disk and does not authorize that run.

Why This Change Was Made

The existing reusable-command binder already refuses a shell wrapper. This head makes PowerShell, Bash, and fish classification match the real host flags, including PowerShell value aliases, File prefixes, and a lone Windows PowerShell positional command. Stored records are not rewritten.

Evidence

Head ddcf698fd5d1cee6d7f27077897775348b6cb28a. The earlier October 1 note that alias and File-prefix cases were still misclassified described older candidates. Those parser holes are fixed on this head. The trace below is the current-head gateway path.

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

Required proof pools

  • windows-wsl-mxc: the direct-script allow reached mxc-direct-appc with host fallback blocked.
  • windows-wsl-gateway-e2e: saved inline-rule denial, direct-script allow, and revoked in-flight approval were node.invoke calls.
  • windows-winui-interactive: the command approval window was present and Allow Once was clicked after the policy was tightened.

Validation

Windows x64, worktree wt-wn-1511, OPENCLAW_REPO_ROOT set to that worktree.

Command Result
.\build.ps1 Exit 0. All builds succeeded.
dotnet test .\tests\OpenClaw.Shared.Tests\OpenClaw.Shared.Tests.csproj Passed 4135, failed 0, skipped 32, total 4167.
dotnet test .\tests\OpenClaw.Tray.Tests\OpenClaw.Tray.Tests.csproj Passed 3067, failed 5, skipped 0, total 3072. The five failures are the LF source-contract checks in #1518. This head does not change those files.

.\scripts\validate-mxc-e2e.ps1 was started through the MXC E2E fixture. Setup stopped in run-wizard with GATEWAY_RESTART_PREPARATION_REFUSED (cannot verify a live serving Gateway owner). That is the shared #1498 failure. It was not run again and setup was not patched. The approval trace below uses the Ubuntu-24.04 gateway that was already listening on port 18789.

Real Behavior Proof

  • Environment: isolated tray data under a temp ocwn1511 directory, current-head Debug tray, SystemRunBlockHostFallbackWhenMxcUnavailable true and SystemRunAllowWindowsUi true. Gateway OpenClaw on Ubuntu-24.04 at ws://127.0.0.1:18789. The paired node reported version 2026.9.5-fix-f108-inline-shell-allow-rules.1.
  • PR head: ddcf698fd5d1cee6d7f27077897775348b6cb28a.
  • Exec policy: security=allowlist, ask=off, askFallback=deny, with two allow-always entries for **/powershell.exe. One entry's argument pattern was the inline -c command. The other was powershell.exe -NoProfile -File plus the direct script path.

Old inline rule, openclaw gateway call node.invoke for system.run:

  • Gateway result: ok=false, exec-approvals-v2: AllowlistMiss (allowlist-miss).
  • Tray log correlation c242ff24: decision=deny reason=allowlist-miss promptAttempted=False. No sandbox request for that correlation.
  • The inline command would have written OPENCLAW_1511_INLINE_RAN. That file was not created.

Direct script control, same gateway call, powershell.exe -NoProfile -File on a local .ps1:

  • Tray log correlation 0709ac2b: decision=allow reason=approved promptAttempted=false grant=arg-bound.
  • The next line is [mxc] system.run sandbox request with executor=mxc-direct-appc, contained=True, blockHostFallbackWhenMxcUnavailable=True, shell=<direct-argv>.
  • Gateway payload stdout was OPENCLAW_1511_DIRECT_OK. Stderr said the sandbox denied Set-Content to the host temp file. The host file was not created. The script still ran inside MXC.

Revoked approval while the window was open:

  • Policy was switched to ask=always with the direct-script rule still present, then system.run was invoked again.
  • UI Automation found a top-level window named OpenClaw Companion - Command Approval and the ExecApprovalAllowOnceAction button.
  • Before the click, the approvals file was rewritten to security=deny with an empty allowlist.
  • The button was clicked. Gateway result: exec-approvals-v2: ValidationFailed (policy-changed-before-execution).
  • Tray log correlation 060d156d: decision=deny reason=policy-changed-before-execution promptAttempted=True. The direct marker file was still absent.

MCP, same isolated tray:

  • winnode --list-tools included system.run, system.run.prepare, system.which, and system.execApprovals.get.

  • winnode --command system.run.prepare for powershell.exe -NoProfile -c "Write-Output OPENCLAW_1511_INLINE_RAN" returned that argv in plan and did not create the marker file.

  • winnode --command system.which --params {"bins":["powershell.exe"]} returned {"bins":{}}.

  • Screenshot or artifact links verified? No. PrintWindow of the approval window was a black frame with only the caption buttons, so it is not attached.

  • Not verified or blocked: .\scripts\validate-mxc-e2e.ps1 did not finish the three named Gateway MXC proofs because the fresh setup fixture hit Gateway 2026.9.6 blocks WSL setup at guarded post-wizard restart #1498. The contained system.run above is the MXC observation for this head.

Security Impact

  • New permissions or capabilities? No
  • Secrets or tokens handling changed? No
  • New or changed network calls? No
  • Command or tool execution surface changed? Yes
  • Data access scope changed? No
  • If any answer is Yes, explain the risk and mitigation: inline shell commands no longer receive a reusable allow identity. A saved inline rule does not run the command. A direct -File script can still match an argument-bound rule. Tightening the policy while the approval window is open fails closed before process I/O. No saved record is deleted.

Compatibility and Migration

  • Backward compatible? No for previously saved rules that this head now classifies as inline. Those records remain on disk and do not authorize the run.
  • Config or environment changes? No
  • Migration needed? No automatic migration, deletion, or rewrite.
  • Operators approve recognized inline commands individually. Direct scripts that still bind can keep an argument-bound allow rule.

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.

Allow-always could store powershell.exe /c and bash -l -c as reusable
rules because those spellings were not treated as inline shells.

- Treat PowerShell /c, /command, and colon-attached forms as wrappers
- Treat POSIX -c, --command, and -lc in any argument after the shell name
- Keep bash script.sh and bash -l script.sh bindable

Signed-off-by: Sebastien Tardif <[email protected]>
@clawsweeper

clawsweeper Bot commented Sep 24, 2026 •

Copy link
Copy Markdown

🦞👀
ClawSweeper picked this up.

Pull request received. I will update this pull request when review starts.

ClawSweeper review complete

ClawSweeper finished reviewing this revision. The review result is being finalized.

View the workflow run.

@clawsweeper clawsweeper Bot added P2 Normal priority bug or improvement with limited blast radius. merge-risk: 🚨 compatibility 🚨 Merging this PR could break existing users, config, migrations, defaults, or upgrades. 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. labels Sep 24, 2026
@clawsweeper

clawsweeper Bot commented Sep 24, 2026 •

Copy link
Copy Markdown

Codex review: needs real behavior proof before merge.

What this changes

The PR prevents recognized inline shell commands from receiving reusable approvals while preserving supported direct-script approvals.

Example: An agent requests powershell.exe /c "Get-Date".

  • Before: The command can receive a reusable Allow Always rule.
  • After: The command requires individual approval, and an existing reusable rule cannot authorize it.

Review scores

Measure Result What it means
Overall readiness 🧂 unranked krab (1/6) Earlier production-path evidence is useful, but the remaining authorization regression blocks merging and current-head validation is incomplete.
Proof confidence 🦐 gold shrimp (3/6) Real behavior proof is necessary before merge. See Before merge.
Patch quality 🧂 unranked krab (1/6) Security review found an item that needs attention.

Product

Kind: Bug fix · Worth it: Yes · Fix scope: Complete
User problem: Allow Always can authorize subsequent inline shell execution without a fresh approval.
Reason: The repair enforces the established one-time-inline policy, and maintainer discussion approves leaving newly ineffective stored rules intact.

Merge readiness

⛔ Blocked before merge - 5 items remain

Keep this PR open: main still needs the fix, but a remaining PowerShell prefix regression blocks merging.

Priority: P1
Reviewed head: 1812fd4525731228d16c63e45bd6132252a76b4f

Before merge

  • Add real behavior proof - Authority-chain proof required: The supplied ddcf698 gateway trace shows saved-inline-rule denial, direct-script MXC execution, and rejection after policy revocation, but predates the current EncodedArguments changes. Supply current-head allowed and forbidden execution evidence, including the repaired Configuration prefix and revoked approval before process I/O, complete strict validate-mxc-e2e.ps1 without AllowSkip, and demonstrate upgrade from the latest stable release with stored records intact. Redact credentials and private endpoints. After adding proof, update the PR body, then request a new review with @clawsweeper re-review. The PR author or someone with repository write access can request it.
  • Honor ConfigurationName's supported prefixes before counting ambiguity (P1) - On Windows with an accessible Microsoft.PowerShell session configuration, pwsh.exe -NoProfile -Configuration Microsoft.PowerShell -c "Write-Output marker" is an inline command. PowerShell accepts ConfigurationName prefixes beginning at config, while ConfigurationFile requires its full spelling. Here both names contribute to valueMatches, so this returns false; the next iteration treats Microsoft.PowerShell as a positional script and returns NotWrapper before reaching -c. TryBind can consequently produce a reusable identity and match a stored rule, whereas the original flat scan rejected this invocation. Apply the host's minimum-prefix precedence and cover the saved-rule path. This is a late discovery: the same logic was already visible unchanged at the previously reviewed ddcf698.
  • Resolve security concern: Inline commands can retain durable authorization - The finding permits an agent request to reach allowlist evaluation with a reusable identity despite invoking command text; execution-boundary policy revalidation does not correct a misclassified identity.
  • Complete next step - Resolve the GitHub-reported merge conflict against main while preserving the approval boundary and fixture isolation.
  • Add data-model compatibility proof - The review found that existing stored data may not work after upgrade. Show that existing data still loads and works with this change.

Findings

  • [P1] Honor ConfigurationName's supported prefixes before counting ambiguity — src/OpenClaw.Shared/ExecApprovals/ExecShellWrapperNormalizer.cs:238
  • [high] Inline commands can retain durable authorization — src/OpenClaw.Shared/ExecApprovals/ExecShellWrapperNormalizer.cs:238

Tests

  • Missing end-to-end proof: The current parser additions lack real saved-rule rejection and direct-script controls, latest-stable upgrade evidence, and a completed strict MXC run; base-failing regression execution was not supplied.
Agent review details

How this fits together

Gateway and MCP system.run requests enter the shared approval pipeline, which classifies argv, derives reusable identities, evaluates stored policy, and supplies approved execution to the sandbox.

flowchart TD
Request[Gateway or MCP request] --> Classifier[Shell wrapper classifier]
Classifier --> Binder[Reusable command binder]
Binder --> Policy[Approval coordinator]
Store[Stored approval rules] --> Policy
Policy --> Recheck[Execution policy recheck]
Recheck --> Sandbox[MXC process execution]
Loading

Technical review

Best possible solution:

Keep classification in the existing normalizer and match PowerShell's parameter-specific minimum prefixes instead of requiring globally unique prefixes.

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

Source establishes both the original classification gaps on main and the remaining Configuration prefix failure; no target code was executed during this review.

Is this the best way to solve the issue?

Repairing the existing classifier is the right boundary, but its global prefix-count heuristic must follow the host's actual parameter precedence.

Full review comments:

  • [P1] Honor ConfigurationName's supported prefixes before counting ambiguity — src/OpenClaw.Shared/ExecApprovals/ExecShellWrapperNormalizer.cs:238
    On Windows with an accessible Microsoft.PowerShell session configuration, pwsh.exe -NoProfile -Configuration Microsoft.PowerShell -c "Write-Output marker" is an inline command. PowerShell accepts ConfigurationName prefixes beginning at config, while ConfigurationFile requires its full spelling. Here both names contribute to valueMatches, so this returns false; the next iteration treats Microsoft.PowerShell as a positional script and returns NotWrapper before reaching -c. TryBind can consequently produce a reusable identity and match a stored rule, whereas the original flat scan rejected this invocation. Apply the host's minimum-prefix precedence and cover the saved-rule path. This is a late discovery: the same logic was already visible unchanged at the previously reviewed ddcf698.
    Confidence: 0.97
    Late finding: first raised on code an earlier review cycle already covered.

Overall correctness: patch is incorrect
Overall confidence: 0.96

AGENTS.md: found and applied where relevant.

Codex review notes: model internal, reasoning medium; reviewed against 0131e4ce1f79.

Provenance checked

  • Shell normalization keeps the original intent (57ebebc: Produce one canonical command identity and fail closed on ambiguous shell forms, as described in feat: normalize, resolve, and build canonical command identity #260.)
  • Durable authorization eligibility keeps the original intent (c9608c8: Bind reusable approvals to one executable and argument identity while keeping inline command hosts individually approved.)
  • E2E environment isolation keeps the original intent (cefce39: Run setup and teardown through the out-of-process SetupEngine fixture; the new separate roaming root preserves fixture-owned lifecycle isolation.)

Testing

Proof path: shipped entry point.

Security

Needs attention: The remaining prefix mismatch weakens the boundary between individual approval and reusable command authorization.

Evidence

Security concerns:

  • [high] Inline commands can retain durable authorization — src/OpenClaw.Shared/ExecApprovals/ExecShellWrapperNormalizer.cs:238
    The finding permits an agent request to reach allowlist evaluation with a reusable identity despite invoking command text; execution-boundary policy revalidation does not correct a misclassified identity.
    Confidence: 0.97

What I checked:

Likely related people:

  • AlexAlves87: Raw commit 57ebebc adds src/OpenClaw.Shared/ExecApprovals/ExecShellWrapperNormalizer.cs:15 relative to its recorded parents. This identifies author metadata, not feature responsibility or a PR merger. (role: source-line author; confidence: high; commits: 57ebebc725ff; files: src/OpenClaw.Shared/ExecApprovals/ExecShellWrapperNormalizer.cs)
  • Caleb Eden: Raw commit c9608c8 adds src/OpenClaw.Shared/ExecApprovals/ExecReusableCommandBinder.cs:144 relative to its recorded parents. This identifies author metadata, not feature responsibility or a PR merger. (role: source-line author; confidence: high; commits: c9608c8e54e6; files: src/OpenClaw.Shared/ExecApprovals/ExecReusableCommandBinder.cs)

Labels

Label changes:

  • add merge-risk: 🚨 security-boundary: A valid PowerShell prefix can still make an inline command eligible for durable authorization.
  • add rating: 🧂 unranked krab: Overall readiness is 🧂 unranked krab; proof is 🦐 gold shrimp and patch quality is 🧂 unranked krab.
  • add status: 📣 needs proof: The PR needs real behavior proof before ClawSweeper can clear the contributor ask.
  • remove rating: 🐚 platinum hermit: Current PR rating is rating: 🧂 unranked krab, so this older rating label is no longer current.
  • remove status: 👀 ready for maintainer look: Current PR status label is status: 📣 needs proof.
  • remove proof: sufficient: Current real behavior proof status is insufficient, not sufficient.

Label justifications:

  • P1: The change governs whether agent-requested inline commands can bypass a fresh human approval.
  • merge-risk: 🚨 security-boundary: A valid PowerShell prefix can still make an inline command eligible for durable authorization.
  • merge-risk: 🚨 compatibility: Previously saved rules for corrected inline forms intentionally stop authorizing execution; the maintainer discussion accepts retaining those records unchanged.
  • rating: 🧂 unranked krab: Overall readiness is 🧂 unranked krab; proof is 🦐 gold shrimp and patch quality is 🧂 unranked krab.
  • status: 📣 needs proof: The PR needs real behavior proof before ClawSweeper can clear the contributor ask.

Rating scale

6/6 🦀 challenger crab · 5/6 🦞 diamond lobster · 4/6 🐚 platinum hermit · 3/6 🦐 gold shrimp · 2/6 🦪 silver shellfish · 1/6 🧂 unranked krab. Overall follows the weaker of proof and patch quality; ✨ marks media proof (a screenshot, video, or linked artifact) that directly shows the changed behavior.

Workflow

ClawSweeper edits this one comment on every review. Comment @clawsweeper re-review for a fresh review only. Repair and merge execution lanes are retired.

History

Review history (24 earlier review cycles; latest 8 shown)
  • reviewed 2026-10-01T18:56:20.631Z sha c470a0c :: needs real behavior proof before merge. :: [P1] [P1] Normalize value aliases before matching PowerShell operands | [P1] [P1] Recognize File abbreviations before positional command handling
  • reviewed 2026-10-01T19:13:13.155Z sha 74fb0d5 :: needs real behavior proof before merge. :: [P1] Consume the OutputFormat alias before scanning its operand
  • reviewed 2026-10-01T19:29:53.855Z sha 13441c6 :: needs real behavior proof before merge. :: none
  • reviewed 2026-10-01T19:37:58.492Z sha 13441c6 :: needs real behavior proof before merge. :: none
  • reviewed 2026-10-01T19:48:49.156Z sha a7da850 :: needs real behavior proof before merge. :: none
  • reviewed 2026-10-01T20:28:39.550Z sha 413a4c2 :: needs real behavior proof before merge. :: none
  • reviewed 2026-10-01T20:47:16.792Z sha ddcf698 :: needs real behavior proof before merge. :: none
  • reviewed 2026-10-06T10:54:16.403Z sha ddcf698 :: blocked before merge. :: none

Reviewed October 20, 2026, 1:47 PM ET / 17:47 UTC (Revision 25).

@karkarl

karkarl commented Sep 25, 2026

Copy link
Copy Markdown
Collaborator

Global triage: HOLD_FOR_AUTHOR. Take confidence 5%; recommendation confidence 99%; effort medium; risk high.

Three verified parsing gaps block this security-boundary change:

  1. Valid combined Bash option clusters such as -ec still permit durable inline-command approval. Together with existing slash/backslash argument normalization, an approved escaped separator can be replayed as an executable separator.
  2. POSIX scanning continues after the script operand, so bash script.sh -c value incorrectly treats the script argument as a shell switch and disables reusable approval.
  3. PowerShell scanning likewise continues after -File script.ps1, misclassifying script arguments such as /c or -c:value.

Please implement operand-aware, shell-specific option parsing and add saved-rule replay coverage for combined flags, post-script arguments, PowerShell -File, and existing-rule upgrades.

The PR must declare and run windows-wsl-mxc with validate-mxc-e2e.ps1 without -AllowSkip, plus real system.run approval and MCP discovery/invocation proof. The current none declaration is not valid for exec-approval behavior.

The red hosted lanes are not linked to this patch: Core failed an unrelated bounded-cancellation test, the E2E shards failed during shared setup initialization, and CI Gate is derivative. They do not replace the missing MXC proof.

bash script.sh -c value and pwsh -File script.ps1 /c value are direct script invocations. Scanning past the script operand classified those arguments as inline shell commands and blocked reusable approval. Inline -c and /c before the script operand still stay one-time.

Shared tests: 4125 passed, 32 skipped. Tray tests: 3067 passed, 5 failed on the LF source-contract mismatch tracked in openclaw#1518.

Signed-off-by: Sebastien Tardif <[email protected]>
@clawsweeper clawsweeper Bot added the merge-risk: 🚨 security-boundary 🚨 Merging this PR could weaken sandboxing, authorization, credentials, or sensitive data. label Sep 26, 2026
A single-dash letter cluster that contains c, such as -ec or -ce, is an inline shell command. The next argument is the payload. Scanning still stops at the script name, so bash script.sh -ec value stays a direct script.

Shared tests: 4128 passed, 32 skipped. Tray tests: 3067 passed, 5 failed on the LF source-contract mismatch tracked in openclaw#1518.

Signed-off-by: Sebastien Tardif <[email protected]>
A combined flag is inline only when it contains a lowercase c. Uppercase C is noclobber, so bash -C and bash -eC script.sh stay direct scripts. bash -ec remains inline. Exact POSIX flags are case-sensitive, so -C does not match -c.

Shared tests: 4129 passed, 32 skipped. Tray tests: 3067 passed, 5 failed on the LF source-contract mismatch tracked in openclaw#1518.

Signed-off-by: Sebastien Tardif <[email protected]>
@shanselman shanselman added the status: 🚢 actively landing A maintainer or agent is actively driving this item through implementation, validation, or merge. label Sep 30, 2026
@shanselman

Copy link
Copy Markdown
Collaborator

HOLD_FOR_AUTHOR at e2d175c0ad5afc9e38717adc5fcba5fe90b3c27a. The old September 25 findings about literal -ec, post-script Bash arguments and explicit PowerShell -File have been fixed. The remaining blocker is not that old review: the new File guard introduces an operand-arity bypass.

I ran harmless native commands with profiles disabled, bounded completion and task-owned scripts/directories. In an owned working directory containing a directory literally named -File:

pwsh -NoProfile -NonInteractive -NoLogo -WorkingDirectory -File -c "Write-Output pr1511-inline"
native: exit 0, stdout pr1511-inline
current Extract: IsWrapper=false
current TryBind: non-null, BindFailure.None

The old scanner reached -c and refused reusable binding. The new scanner stops on -File, although that token is the value of -WorkingDirectory. This is a new weakening, not a preexisting alias gap.

Both independent reviewers used the same prompt and agree:

Issue Opus 5 Codex 5.3 Fix confidence
PowerShell option value -File terminates the scan HIGH HIGH 90%
Bash option operands / + flags hide a later -c HIGH HIGH 90%
Newly recognized /c after a positional PowerShell script is misclassified MEDIUM MEDIUM 90%

Single-reviewer findings and scope disposition:

Issue Opus 5 Codex 5.3 Fix confidence
PowerShell -cwa inline form, native-confirmed but preexisting — HIGH 95%
Binder controls depend on Bash/pwsh installation on PATH MEDIUM — 95%
EncodedCommand checks live only in the unused legacy resolver HIGH — 80%

The last two are portability/adjacent-contract follow-up evidence, not a request to expand this lane. The reported WSL proxy, Unicode dash, log-only upgrade explanation and unused payload-tail findings are also preexisting or outside the live changed boundary, so no speculative redesign or patches were made for them.

Additional native controls: bash -o errexit -c 'printf "%s\n" pr1511-inline', bash -O extglob -c ... and bash +e -c ... print the inline marker but remain bindable. These are remaining gaps in the same Bash option grammar, not newly introduced ones. pwsh script.ps1 /c value and pwsh -fi script.ps1 /c value execute the owned script with /c as an argument, but the new classifier rejects reusable binding. Both PowerShell 5.1 and 7 accept /co as Command; it still binds. PowerShell 7 -cwa is likewise an existing missed form. The tested colon-attached -c:Write-Output ... is not a working Command alias on these native hosts; classifier assertions alone should not establish that contract.

One separate introduced cross-shell regression is source-backed, not native-fish proof: the case-sensitive flag set applies to fish as well as Bash. fish -C COMMANDS means init-command, not Bash noclobber; it was classified as a wrapper before and is no longer classified at this head. Preserve Bash -C without generalizing Bash's grammar to every shell.

Please keep the repair in this PR's classifier owner, with shell-specific switch position, operand arity, termination and PowerShell prefix rules backed by actual CLI semantics, rather than another special-case token patch. Add binder/saved-rule regressions for the newly weakened case and direct-script controls. I confirmed that a missed Bash wrapper allows slash/backslash-normalized argument patterns to match two payloads with different actual semicolon behavior. That observation is native shell plus helper-level matching evidence, not Gateway-to-node final-I/O proof.

The intended upgrade behavior enforces the existing documented one-time shell policy: recognized inline wrappers have no reusable identity or saved-rule matches. Existing records remain untouched; this is not permission to delete, rewrite or keep unsafe rules.

Validation is green but does not override these source blockers. Original head: full build passed, Shared 4129 passed / 32 skipped, Tray 3072 passed, focused exec 339 passed. Unpushed normal integration 6559a590df776d7fdd354b0c92c2e8bcfdd5209e with main 04a880fe9488dbbd68ef786c1ebdc03c240c26c6: full build passed, Shared 4191 passed / 33 skipped, Tray 3363 passed, focused exec 339 passed. One earlier Shared run hit a 2-second shutdown-telemetry observation timeout; its exact retry and a complete build/Shared/Tray rerun passed. Structured autoreview also reports the new PowerShell arity bypass and implicit-script regression.

Live MXC 0.8.0 probe still reports tier=base-container, needsDaclAugmentation=false; this is not containment E2E proof. No shared desktop/Gateway/WSL fixture was started because source did not clear. Non-skipping validate-mxc-e2e.ps1, real saved-rule denial/direct positive control, approval UI and MCP discovery/invocation remain blocked. Current-head hosted Setup/Connect failed specifically at wizard restart with GATEWAY_RESTART_PREPARATION_REFUSED and SQLite state-lifecycle contention; CI Gate is derivative. No CI/check bypass, contributor push, force-push or merge was performed.

@shanselman shanselman removed the status: 🚢 actively landing A maintainer or agent is actively driving this item through implementation, validation, or merge. label Sep 30, 2026
@clawsweeper clawsweeper Bot added P1 Urgent regression or broken agent/channel workflow affecting real users now. rating: 🧂 unranked krab Not merge-ready due to missing proof or serious correctness/safety concerns. and removed P2 Normal priority bug or improvement with limited blast radius. rating: 🦪 silver shellfish Thin PR readiness signal; proof, validation, or implementation needs work. labels Sep 30, 2026
A PowerShell option value named -File stopped classification before a
later -c, so the binder could save that inline command. A positional
script made a later /c look like a host switch. fish -C is an init
command and stays a wrapper. bash -C stays noclobber.

Validation: ./build.ps1 exit 0. Shared 4132 passed, 32 skipped.
ExecApprovalV2NormalizationTests 120 passed. Tray 3067 passed and 5
failed, the LF source-contract mismatch in openclaw#1518.

Signed-off-by: Sebastien Tardif <[email protected]>
@clawsweeper clawsweeper Bot added rating: 🦪 silver shellfish Thin PR readiness signal; proof, validation, or implementation needs work. and removed rating: 🧂 unranked krab Not merge-ready due to missing proof or serious correctness/safety concerns. labels Sep 30, 2026
Core and CLI failed only
RunAsync_OutputDrainIsBoundedAndPreservesFinalFragments_WhenDescendantRetainsHandles.
The drain took 1547 ms against a 1 second bound. That test is not in this change.

Signed-off-by: Sebastien Tardif <[email protected]>
pwsh binds -wd as the WorkingDirectory alias and unique prefixes such as
-wo and -wor the same way. An operand named -File was classified as file
mode, so a later -c could be saved as an allow-always rule. Consume those
forms, and the other documented value aliases, before the file check.

Normalization tests cover -wd, -wo, -wor, /wd, -w, and -ep, including the
binder and the allow-always identity. Native pwsh -wd -File -c and
-wo -File -c still print the inline command.

Signed-off-by: Sebastien Tardif <[email protected]>
@clawsweeper clawsweeper Bot added rating: 🦐 gold shrimp Decent PR readiness signal, but merge confidence is limited. and removed rating: 🦪 silver shellfish Thin PR readiness signal; proof, validation, or implementation needs work. labels Oct 1, 2026
-i and -in match Interactive, which takes no argument. The value-option
prefix matcher treated them as InputFormat and skipped the following -c,
so the inline command could be saved as an allow-always rule. A prefix
that also matches a no-value switch stays a switch. -inp still consumes
its format value.

Normalization tests cover -i, -in, and -int with the binder and the
allow-always identity, and -inp Text -c still stays inline.

Signed-off-by: Sebastien Tardif <[email protected]>
@clawsweeper clawsweeper Bot added the rating: 🧂 unranked krab Not merge-ready due to missing proof or serious correctness/safety concerns. label Oct 1, 2026
@clawsweeper clawsweeper Bot added rating: 🦐 gold shrimp Decent PR readiness signal, but merge confidence is limited. and removed rating: 🧂 unranked krab Not merge-ready due to missing proof or serious correctness/safety concerns. labels Oct 1, 2026
@shanselman shanselman added the status: 🚢 actively landing A maintainer or agent is actively driving this item through implementation, validation, or merge. label Oct 1, 2026
@shanselman

Copy link
Copy Markdown
Collaborator

Narrow current-head check at 13441c63776e51be53e0982c0cd15306037bc21c: -of is now fixed. The lone Windows PowerShell command-string case remains.

powershell.exe -NoProfile -NonInteractive -NoLogo "Write-Output pr1511-inline; Write-Output pr1511-second"
native: exit 0
stdout:
pr1511-inline
pr1511-second
Extract: IsWrapper=false
TryBind: non-null, BindFailure.None

ExecShellWrapperNormalizer.cs:194-196 still says a lone positional stays a script and requires another token before recognizing Windows PowerShell command mode. Installed Windows PowerShell 5.1 executes this single argv element as command text. This false-negative predates the PR, but it remains in the positional-mode branch authored by this repair and prevents the relevant one-time-inline policy from being satisfied. It is not a new regression attributed to the -of commit.

Exact-head fixed controls: pwsh -of Text -c ..., --if Text -c ... and --wd <owned-directory> -c ... now return ShellWrapper. Windows PowerShell explicit -File and abbreviated -fi direct-script controls run and remain bindable. These repaired findings are closed for this snapshot.

Please finish this classifier-owned default-command boundary and provide a stable candidate for the next floor/proof pass. No Bash/fish expansion, stored-rule redesign or downstream authorization changes are requested.

This pass ran only the Shared dependency build (exit 0) and six harmless native/binder controls, with profiles disabled, task-owned files/cwd and bounded completion. Runtime used normal unpushed integration a3ccf1b46497159bf214f8aa119e559d88be5cd4; parser/tests match 13441c63, and all previous author/local history is preserved. Full suites, another review pair and Gateway/MXC/MCP/UI lifecycle were not started because source still fails this case. No earlier head's green validation is claimed for 13441c63, and no patch, push, merge or fixture reservation was made.

@shanselman shanselman removed the status: 🚢 actively landing A maintainer or agent is actively driving this item through implementation, validation, or merge. label Oct 1, 2026
@shanselman

Copy link
Copy Markdown
Collaborator

I am preparing one local, uncommitted correction against 13441c6 for the sole Windows PowerShell implicit-command argument-count guard, with explicit File and pwsh positional-script controls. No alias grammar, Bash/fish, storage or protocol expansion, and no branch push or fixture launch. Please keep this candidate stable while I validate an applyable two-file patch; if you are already repairing this boundary, reply and I will stop rather than compete. Native Windows PowerShell treats implicit positional text as evaluated Command mode; explicit File mode remains the reusable script control.

@shanselman shanselman added the status: 🚢 actively landing A maintainer or agent is actively driving this item through implementation, validation, or merge. label Oct 1, 2026
@shanselman

Copy link
Copy Markdown
Collaborator

Validated two-file maintainer patch for the sole Windows PowerShell positional-command guard. No commit or push was made.

The patch is against 13441c63776e51be53e0982c0cd15306037bc21c. Your new a7da850e496c5a79271a4405de1b5f560cf25e75 is a CI-only commit with identical source/tests, so the same patch applies. The new head was checked only for that delta, not relabeled as fully tested.

The only production change removes the second-argument requirement. Native Windows PowerShell 5.1 evaluates a single positional command string, including an implicit script-path string. Both now remain runnable one-time but cannot obtain durable approval. Explicit Windows PowerShell -File/-fi, including value options before File, and positional pwsh scripts still execute and bind. No .ps1 suffix exception, new option grammar, Bash/fish change, storage mutation or saved-rule deletion was added.

Validation of uncommitted patch SHA-256 707D8464E98B10664DBC3D683CA3D5C1759E253944259CBC232F136AC8292779 on preserved local integration a3ccf1b46497159bf214f8aa119e559d88be5cd4:

  • .\build.ps1: passed, exit 0.
  • dotnet test .\tests\OpenClaw.Shared.Tests\OpenClaw.Shared.Tests.csproj --no-restore: final full default run Passed 4259, Failed 0, Skipped 33, Total 4292.
  • dotnet test .\tests\OpenClaw.Tray.Tests\OpenClaw.Tray.Tests.csproj --no-restore: Passed 3859, Failed 0, Skipped 0.
  • Focused normalization/binder/coordinator/SystemCapabilityV2/argument-pattern filter: Passed 352, Failed 0, Skipped 0.
  • Eleven bounded native/binder controls: all execution outcomes and command/File-mode distinctions passed.
  • Identical-prompt direct claude-opus-5.5 / gpt-6-astra (long_context) review: both reported no actionable findings in this local delta. This is not a repeated full-PR review.
  • Exact-author patch applicability checked using an isolated Git index; no author branch/index changes.

The first full Shared run failed McpHttpServerTests.Dispose_DuringInFlightHandler_DoesNotSurfaceObjectDisposedException:412: its process-global unobserved-task capture plus forced GC recorded disposed SafeFileHandle/StreamReader.ReadToEndAsync exceptions, without semaphore/server frames. The producing task was not established from that stack. The exact test passed 1/1 in isolation, then the entire default build/Shared/Tray floor passed unchanged. No MCP test/assertion changes, serialization, process kill or blanket flake claim was used.

Apply the following patch locally with git apply, then publish a stable author candidate and reply with its SHA. Stable-head real Gateway saved-rule denial/direct positive control, MCP/approval-state evidence and strict non-skipping MXC still gate landing. No fixture or lifecycle reservation was started for this local repair.

diff --git a/src/OpenClaw.Shared/ExecApprovals/ExecShellWrapperNormalizer.cs b/src/OpenClaw.Shared/ExecApprovals/ExecShellWrapperNormalizer.cs
index 14d0f2c4..ac0a1c48 100644
--- a/src/OpenClaw.Shared/ExecApprovals/ExecShellWrapperNormalizer.cs
+++ b/src/OpenClaw.Shared/ExecApprovals/ExecShellWrapperNormalizer.cs
@@ -190,9 +190,9 @@ internal static class ExecShellWrapperNormalizer
 
             if (!t.StartsWith('-') && !t.StartsWith('/'))
             {
-                // Windows PowerShell joins a positional token and everything
-                // after it into command text. A lone positional stays a script.
-                if (windowsPowerShell && i + 1 < command.Count)
+                // Windows PowerShell evaluates positional input as command text,
+                // even one token. Explicit File mode was handled above.
+                if (windowsPowerShell)
                     return t;
                 return null;
             }
diff --git a/tests/OpenClaw.Shared.Tests/ExecApprovalV2NormalizationTests.cs b/tests/OpenClaw.Shared.Tests/ExecApprovalV2NormalizationTests.cs
index 5fe408b2..cc0ac650 100644
--- a/tests/OpenClaw.Shared.Tests/ExecApprovalV2NormalizationTests.cs
+++ b/tests/OpenClaw.Shared.Tests/ExecApprovalV2NormalizationTests.cs
@@ -235,6 +235,51 @@ public class ExecApprovalV2NormalizationTests
         Assert.NotNull(bound);
     }
 
+    [Theory]
+    [InlineData("Write-Output marker")]
+    [InlineData("Write-Output marker; Write-Output second")]
+    [InlineData("script.ps1")]
+    public void Normalizer_WindowsPowerShellSinglePositional_IsOneTimeCommand(string command)
+    {
+        string[] argv = ["powershell.exe", "-NoProfile", command];
+        AssertWrapper(argv, command);
+        Assert.Null(ExecReusableCommandBinder.TryBind(argv, cwd: null, env: null, out var failure));
+        Assert.Equal(ExecReusableCommandBinder.BindFailure.ShellWrapper, failure);
+
+        var outcome = ExecApprovalV2Normalizer.Normalize(Req(argv));
+        Assert.True(outcome.IsResolved);
+        Assert.Null(outcome.Identity!.ReusableCommand);
+        Assert.Empty(outcome.Identity.AllowAlwaysPatterns);
+        Assert.Empty(outcome.Identity.AllowlistResolutions);
+    }
+
+    [Theory]
+    [InlineData("powershell.exe", "-File")]
+    [InlineData("powershell.exe", "-fi")]
+    [InlineData("powershell.exe", "-InputFormat", "Text", "-File")]
+    [InlineData("pwsh.exe")]
+    public void Normalizer_SingleScriptInFileMode_RemainsReusable(string executable, params string[] options)
+    {
+        var directory = Directory.CreateTempSubdirectory("exec-single-script");
+        try
+        {
+            var tool = Path.Combine(directory.FullName, executable);
+            File.WriteAllBytes(tool, [0x4D, 0x5A]);
+            var argv = new List<string> { tool, "-NoProfile" };
+            argv.AddRange(options);
+            argv.Add("script.ps1");
+
+            Assert.False(ExecShellWrapperNormalizer.Extract(argv).IsWrapper);
+            var bound = ExecReusableCommandBinder.TryBind(argv, cwd: null, env: null, out var failure);
+            Assert.Equal(ExecReusableCommandBinder.BindFailure.None, failure);
+            Assert.NotNull(bound);
+        }
+        finally
+        {
+            directory.Delete(recursive: true);
+        }
+    }
+
     [Fact]
     public void Normalizer_FishInitCommand_IsWrapper()
     {
@@ -1078,15 +1123,14 @@ public class ExecApprovalV2NormalizationTests
     }
 
     [Fact]
-    public void ResolveForAllowlist_DirectPowerShellScriptFile_NotFailClosed()
+    public void ResolveForAllowlist_WindowsPowerShellPositionalScript_ResolvesCommandText()
     {
-        // Direct exec path: ["powershell", "script.ps1"] — no inline flag, no -EncodedCommand.
-        // DirectExecUsesEncodedCommand must not trigger; must resolve as a single resolution.
+        // This historical resolver inspects the command text, not durable eligibility.
         var resolutions = ExecCommandResolver.ResolveForAllowlist(
             ["powershell", "script.ps1"],
             evaluationRawCommand: null, cwd: null, env: null);
         Assert.Single(resolutions);
-        Assert.Contains("powershell", resolutions[0].ExecutableName, StringComparison.OrdinalIgnoreCase);
+        Assert.Equal("script.ps1", resolutions[0].ExecutableName);
     }
 
     [Fact]

@shanselman shanselman removed the status: 🚢 actively landing A maintainer or agent is actively driving this item through implementation, validation, or merge. label Oct 1, 2026
powershell Get-Date runs as command text, but a lone positional was saved as a script. Command text is now inline, including when nothing follows it. A lone script.ps1 path stays a script.

Signed-off-by: Sebastien Tardif <[email protected]>
A lone script name is still implicit -Command. Guessing from a .ps1 suffix left that command bindable. Explicit -File remains the reusable script form.

Signed-off-by: Sebastien Tardif <[email protected]>
@clawsweeper clawsweeper Bot added proof: sufficient Contributor real behavior proof is sufficient. rating: 🐚 platinum hermit Good normal PR readiness with ordinary maintainer review expected. status: 👀 ready for maintainer look ClawSweeper has no concrete contributor-facing blocker left for this PR. and removed status: 📣 needs proof The PR needs real behavior proof before ClawSweeper can clear the contributor ask. rating: 🦐 gold shrimp Decent PR readiness signal, but merge confidence is limited. merge-risk: 🚨 security-boundary 🚨 Merging this PR could weaken sandboxing, authorization, credentials, or sensitive data. labels Oct 6, 2026
@karkarl

karkarl commented Oct 9, 2026

Copy link
Copy Markdown
Collaborator

Global triage: HOLD_FOR_AUTHOR. Take confidence 20%; recommendation confidence 98%; effort small; risk high.

Reviewed exact head ddcf698fd5d1. GitHub currently reports CLEAN with 28 passing, 0 failing, and 0 pending checks. proof label is sufficient. Durable automated signal: Codex review: blocked before merge..

Author: resolve the current durable review findings, add focused regressions, and request a fresh exact-head review.

This is a triage classification, not a merge action. No branch changes were made.

Recognize EncodedArguments aliases without changing EncodedCommand prefixes, and preserve ServerMode switch arity. Add normalization and persistent-approval regressions plus isolated script controls. Separate the E2E roaming root and guard its lifecycle wiring.

Co-authored-by: Copilot App <[email protected]>
@clawsweeper clawsweeper Bot added clawsweeper:intake:bug Preliminary submission classification; full source review pending. merge-risk: 🚨 security-boundary 🚨 Merging this PR could weaken sandboxing, authorization, credentials, or sensitive data. 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. and removed rating: 🐚 platinum hermit Good normal PR readiness with ordinary maintainer review expected. status: 👀 ready for maintainer look ClawSweeper has no concrete contributor-facing blocker left for this PR. proof: sufficient Contributor real behavior proof is sufficient. clawsweeper:intake:bug Preliminary submission classification; full source review pending. labels Oct 20, 2026
Integrate main at 431bd8f. Preserve both the E2E roaming-root guard and the independent startup safety tests when resolving their insertion conflict.

Co-authored-by: Copilot App <[email protected]>
@bkudiess
bkudiess merged commit f39d4f0 into openclaw:main Oct 20, 2026
23 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. 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.

4 participants