Skip to content

Gateway-wrapped commands bypass usable Windows exec allow rules #971

Closed

Description

@steipete

Problem

Gateway node execution on Windows sends commands through the platform shell as an argv vector such as cmd.exe /d /s /c hostname. The Windows node formats that vector into one command string, evaluates the outer wrapper against the host exec policy, and returns on the default deny before ExecShellWrapperParser can evaluate the inner command.

This makes default low-risk allow rules such as the exact hostname rule unusable through the real Gateway exec host=node path even though direct Windows-node policy evaluation allows the inner command.

Reproduction

  1. Connect Windows Hub 0.6.12 as a node to a current OpenClaw Gateway.
  2. Confirm the host-native policy has the default exact hostname allow rule.
  3. Ask an agent to run exactly hostname through exec with host=node.
  4. Observe Command denied by exec policy.

The Gateway-generated argv is cmd.exe /d /s /c hostname. The host policy denies that wrapper before expanding it to the allowed nested target.

Expected

A recognized shell wrapper should be allowed when every parsed inner target is allowed, while malformed wrappers and explicit deny rules on either the wrapper or any nested target remain fail-closed.

Scope

This is a narrow Windows host exec-policy ordering bug. It does not change the broader Windows-vs-WSL command/path product contract tracked in #911.

Activity

  1. added
    P1
    impact:security
    no-stale
    issue-rating: 🦞 diamond lobster
    clawsweeper:source-repro
    clawsweeper:no-new-fix-pr
    clawsweeper:queueable-fix
    clawsweeper:fix-shape-clear
    clawsweeper:needs-security-review
    on Jul 11, 2026
  2. clawsweeper commented on Jul 11, 2026

    @clawsweeper

    Codex review: keeping this open for maintainer follow-up; there is still a little grit to resolve. Reviewed July 11, 2026, 7:42 PM ET / 23:42 UTC.

    Summary
    Current main still exhibits the reported authorization ordering, so this issue remains necessary and is suitable for a narrow repair rather than closure or product-direction review.

    Reproducibility: yes. at high confidence from current-main source: cmd.exe /d /s /c hostname falls to the default outer denial before the existing parser can evaluate hostname. This read-only review did not execute the live Windows Gateway path.

    Root-cause cluster
    Relationship: canonical
    Canonical: #971
    Summary: This issue is the canonical narrow authorization-ordering report; the linked open issue covers a broader and distinct Windows-versus-WSL command contract.

    Members:

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

    Next step
    Current main has a concrete, bounded ordering defect with clear implementation files and repository-defined validation, and no linked PR or product decision blocks a focused repair.

    Security
    Needs attention: The issue affects a command-authorization boundary, so the eventual repair needs focused proof that explicit deny and malformed-wrapper behavior remain fail-closed.

    Review details

    Best possible solution:

    Parse recognized wrappers before finalizing an unmatched outer default denial, require every extracted target to pass policy, retain explicit deny precedence at every level, and prove the exact Gateway argv through the repository MXC E2E path.

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

    Yes at high confidence from current-main source: cmd.exe /d /s /c hostname falls to the default outer denial before the existing parser can evaluate hostname. This read-only review did not execute the live Windows Gateway path.

    Is this the best way to solve the issue?

    Yes: changing only the wrapper-evaluation ordering is the narrowest maintainable fix because the parser, nested-target checks, and explicit-deny distinction already exist.

    AGENTS.md: found and applied where relevant.

    Remaining risk / open question:

    • The repair must distinguish an unmatched default outer denial from an explicit matched wrapper deny; otherwise an allowed inner target could override an administrator's wrapper-specific block.
    • Every parsed nested target and command-chain segment must remain independently authorized, while malformed or empty wrappers remain fail-closed.
    • The Gateway supplies the wrapper argv and effective shell metadata, so focused unit coverage alone cannot prove the real integration path.

    Codex review notes: model internal, reasoning high; reviewed against 622c0e27c6b0.

    Label changes

    Label changes:

    • add P1: An established default-safe Windows node command fails through the real Gateway agent workflow, breaking usable node command execution for affected users.
    • add impact:security: The issue affects the host command authorization boundary and requires preserving explicit deny and fail-closed semantics.
    • add issue-rating: 🦞 diamond lobster: Current issue advisory state selects this label.
    • add clawsweeper:source-repro: Current issue advisory state selects this label.
    • add clawsweeper:no-new-fix-pr: Current issue advisory state selects this label.
    • add clawsweeper:queueable-fix: Current issue advisory state selects this label.
    • add clawsweeper:fix-shape-clear: Current issue advisory state selects this label.
    • add clawsweeper:needs-security-review: Current issue advisory state selects this label.

    Label justifications:

    • P1: An established default-safe Windows node command fails through the real Gateway agent workflow, breaking usable node command execution for affected users.
    • impact:security: The issue affects the host command authorization boundary and requires preserving explicit deny and fail-closed semantics.
    Evidence reviewed

    Security concerns:

    • [high] Preserve explicit wrapper and nested-target denies — src/OpenClaw.Shared/Capabilities/SystemCapability.cs:550
      Reordering wrapper evaluation must not permit an allowed inner command to override an explicit rule denying the outer wrapper or any extracted target.
      Confidence: 0.97

    Acceptance criteria:

    • ./build.ps1
    • dotnet test ./tests/OpenClaw.Shared.Tests/OpenClaw.Shared.Tests.csproj --no-restore
    • dotnet test ./tests/OpenClaw.Tray.Tests/OpenClaw.Tray.Tests.csproj --no-restore
    • .\scripts\validate-mxc-e2e.ps1

    What I checked:

    Likely related people:

    • shanselman: Introduced system.run and its exec approval policy, added shell-wrapper security hardening, and has the largest contribution history across the central policy files. (role: feature owner and recent area contributor; confidence: high; commits: 4003e58d8f92, e772b5e6e90c, 4166e0fd63f8; files: src/OpenClaw.Shared/Capabilities/SystemCapability.cs, src/OpenClaw.Shared/ExecApprovalPolicy.cs, src/OpenClaw.Shared/ExecShellWrapperParser.cs)
    • Régis Brid: Recently added inline exec approval behavior in the same SystemCapability and policy area, making this contributor relevant to approval ordering. (role: recent approval-flow contributor; confidence: medium; commits: 4e7982bafb86; files: src/OpenClaw.Shared/Capabilities/SystemCapability.cs, src/OpenClaw.Shared/ExecApprovalPolicy.cs)
    • Vincent Koc: Authored the focused change preventing duplicate prompts for approved wrappers, directly adjacent to wrapper and nested-target authorization semantics. (role: adjacent wrapper-approval contributor; confidence: medium; commits: 1d58d59673c9; files: src/OpenClaw.Shared/Capabilities/SystemCapability.cs, tests/OpenClaw.Shared.Tests/ExecApprovalPolicyTests.cs)
    How this review workflow works
    • ClawSweeper keeps one durable marker-backed review comment per issue or PR.
    • Re-runs edit this comment so the latest verdict, findings, and automation markers stay together instead of adding duplicate bot comments.
    • A fresh review can be triggered by eligible @clawsweeper re-review comments, exact-item GitHub events, scheduled/background review runs, or manual workflow dispatch.
    • PR/issue authors and users with repository write access can comment @clawsweeper re-review or @clawsweeper re-run on an open PR or issue to request a fresh review only.
    • Maintainers can also comment @clawsweeper review to request a fresh review only.
    • Fresh-review commands do not start repair, autofix, rebase, CI repair, or automerge.
    • Maintainer-only repair and merge flows require explicit commands such as @clawsweeper autofix, @clawsweeper automerge, @clawsweeper fix ci, or @clawsweeper address review.
    • Maintainers can comment @clawsweeper explain to ask for more context, or @clawsweeper stop to stop active automation.
  3. moved this from Backlog to In progress in Windows Companion Appon Jul 12, 2026
  4. moved this from Channels to Connection and Pairing in Windows Companion Appon Jul 13, 2026
  5. moved this from Connection and Pairing to Local Gateway in Windows Companion Appon Jul 13, 2026
  6. locked as resolved and limited conversation to collaborators on Jul 14, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    P1clawsweeper:fix-shape-clearclawsweeper:needs-security-reviewclawsweeper:no-new-fix-prclawsweeper:queueable-fixclawsweeper:source-reproimpact:securityissue-rating: 🦞 diamond lobsterno-stale

    Type

    No type

    Fields

    Priority

    High

    Projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions