Skip to content

fix: recognize more shell wrappers [AI] - #112955

Merged
pgondhi987 merged 23 commits into
openclaw:mainfrom
pgondhi987:fix/fix-878
Jul 24, 2026
Merged

pgondhi987 merged 23 commits into
openclaw:mainfrom
pgondhi987:fix/fix-878

Conversation

@pgondhi987

@pgondhi987 pgondhi987 commented Jul 23, 2026 •

Copy link
Copy Markdown
Contributor

What Problem This Solves

Fixes an issue where exec approval checks could treat less-common shell wrappers as opaque executables, so inline command payloads were not surfaced consistently for review when those wrappers were allow-listed.

Why This Change Was Made

The shell-wrapper registry now recognizes additional -c capable shells and the shared inline-command parser recognizes Nushell's --commands form. Internal consumers now distinguish wrapper recognition from the narrower shell set that is safe to feed through reusable Bash-style parsing.

User Impact

Users and operators get consistent exec approval behavior across the expanded shell set: wrapper allowlist entries no longer hide changed inline payloads for those shells, while existing Bash, Zsh, Fish, PowerShell, cmd, and shell-multiplexer behavior stays unchanged.

Evidence

  • node scripts/run-vitest.mjs src/infra/exec-wrapper-resolution.test.ts src/infra/exec-wrapper-trust-plan.test.ts src/infra/exec-approvals-allow-always.test.ts
  • git diff --check

AI-assisted: yes.

@openclaw-barnacle openclaw-barnacle Bot added size: S maintainer Maintainer-authored PR labels Jul 23, 2026
@openclaw-barnacle openclaw-barnacle Bot added the agents Agent runtime and tooling label Jul 23, 2026
@pgondhi987

Copy link
Copy Markdown
Contributor Author

ClawSweeper proof for current head f06324c

Behavior proved: shell-wrapper inline payloads no longer satisfy an allow-always entry for the wrapper executable itself, while parseable shell script operands still match their intended allow-always entry.
Environment: local PR checkout on Linux using the real OpenClaw exec approval analysis/evaluation path. Temporary executable fixtures stub only filesystem command resolution; no subprocess payload is executed.
Command/artifact:

  • node scripts/run-vitest.mjs src/infra/exec-approvals-allow-always.test.ts --testNamePattern 'prevents allowlist bypass for .* inline shell payloads|prevents allowlist bypass for nu .* inline shell payloads|does not bind option values as shell script allowlist targets'
    Evidence:
  • fixed/denied: recognized shell wrappers csh, tcsh, mksh, yash, nu, nu.exe, xonsh, elvish, and osh with inline payloads were evaluated with allowlistSatisfied=false; the approval policy returned requiresExecApproval=true, so the protected approval decision did not auto-approve the payload.
  • fixed/denied: Nushell command forms --commands, --commands=, --execute, --execute=, and -e were evaluated with allowlistSatisfied=false; the approval policy returned requiresExecApproval=true, covering attached-value command flags.
  • control: parseable shell invocations with option values for mksh, yash, and bash rejected decoy option-value entries and accepted the real run.sh script entry, preserving intended script allow-always behavior.
  • output: Test Files 1 passed (1); Tests 17 passed | 74 skipped (91); Duration 1.93s.
    Compatibility/operator note: existing allow-always entries for actual script operands still work; bare shell-wrapper entries no longer approve hidden inline payloads.
    Live gaps: no external provider, native desktop client, browser, or channel service is involved in this approval decision. The proof uses the nearest production adapter for the changed boundary and stubs only temporary executable paths.

@pgondhi987

Copy link
Copy Markdown
Contributor Author

Codex review: needs maintainer review before merge. Reviewed July 23, 2026, 7:34 PM UTC.

Summary
Keep open: this is an active maintainer PR for a real exec-approval security boundary, current main does not already contain the wrapper expansion, and I found no blocking patch defect. The only maintainer-visible blocker is accepting the intentional fail-closed compatibility impact for existing bare shell-wrapper allow-always entries.

PR surface: Source +289, Tests +638. Total +927 across 19 files.

Reproducibility: Yes, source-reproducible: current main lacks the expanded wrapper recognition, and the PR discussion reports focused production-path approval evaluation where wrapper allowlist entries no longer satisfy hidden inline payloads. I did not rerun tests because this review is read-only.

Review metrics:

  • New shell-wrapper surface: 8 canonical wrappers added; Windows .exe aliases covered through normalization - Expanding the recognized wrapper set changes which existing allowlist entries are treated as shell transports instead of opaque executables.

Merge readiness
Overall: 🐚 platinum hermit
Proof: 🦞 diamond lobster
Patch quality: 🐚 platinum hermit
Result: needs maintainer review before merge.

Overall follows the weaker of proof and patch quality, so missing proof can cap an otherwise strong patch.

Risk before merge

  • [P0] Merging intentionally changes upgrade behavior for operators who already allow-listed a newly recognized shell wrapper executable such as nu, csh, tcsh, or xonsh: hidden inline payloads will require approval instead of being covered by the bare wrapper entry.

Maintainer decision needed

  • Question: Should OpenClaw intentionally fail closed for allow-always entries on the newly recognized opaque shell wrappers, even if existing operator allowlists for those shell executables start requiring approval?
  • Rationale: The code path appears correct, but changing approval behavior for existing operator allowlists is a security-versus-compatibility choice that automation should not silently make.
  • Likely owner: pgondhi987 - pgondhi987 has the densest recent history in this exec allowlist hardening path and authored the current security-boundary change.
    Options:
  1. Accept fail-closed hardening (recommended)
    Merge with the intentional behavior that bare wrapper allowlist entries no longer approve hidden inline payloads for the expanded shell set.
  2. Require compatibility plan first
    Pause until the PR body or follow-up docs explicitly call out the operator upgrade impact and any expected mitigation.
  3. Preserve old wrapper behavior
    Keep bare wrapper allowlist compatibility for these shells, accepting that the reported approval gap remains narrower or unresolved.

Next step before merge

  • Have the maintainer/security owner explicitly accept or document the fail-closed allowlist compatibility impact before landing.

Security
Cleared: The diff strengthens the exec approval boundary and does not introduce a concrete supply-chain, secret-handling, or permission-broadening regression.

Review details

Best possible solution:

Land the centralized fail-closed wrapper hardening after a maintainer/security owner accepts the operator compatibility impact and exact-head CI remains green.

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

Yes, source-reproducible: current main lacks the expanded wrapper recognition, and the PR discussion reports focused production-path approval evaluation where wrapper allowlist entries no longer satisfy hidden inline payloads. I did not rerun tests because this review is read-only.

Is this the best way to solve the issue?

Yes, this appears to be the best maintainable fix shape: the central wrapper registry, allowlist matcher, command explanation, authorization planning, and system.run execution boundary are updated together while opaque shells are kept out of reusable Bash-style parsing. The remaining question is the intentional compatibility impact, not a patch defect.

AGENTS.md: found_applied

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

Label details

Label justifications:

  • P0: The PR addresses a host exec approval allowlist bypass where a shell-wrapper allowlist entry could hide inline payload changes.
  • merge-risk: 🚨 compatibility: Existing operators with bare allow-always entries for newly recognized shell wrappers may see approvals or denials after upgrade.
Evidence reviewed

PR surface:

Area Files Added Removed Net
Source 12 335 46 +289
Tests 7 638 0 +638
Docs 0 0 0 +0
Config 0 0 0 +0
Generated 0 0 0 +0
Other 0 0 0 +0
Total 19 973 46 +927
  • Changed wrapper registry: The PR adds csh, elvish, mksh, nu, osh, tcsh, xonsh, and yash to the shell-wrapper registry and introduces a narrower parseable-wrapper set so non-Bash-compatible shells stay out of reusable parser paths.
  • Allowlist hardening path: The allowlist matcher now suppresses returned inline-command fallback for opaque POSIX shell wrappers and prevents opaque wrappers from being treated as script-operand allowlist targets.
  • Execution fails closed for opaque transports: system.run argv resolution returns null when an allowlist-satisfied, unprompted shell payload is carried by an opaque POSIX shell transport, avoiding rewrite/execution of an unmodeled wrapper path.
  • Regression coverage: The added tests cover denial for csh, tcsh, mksh, yash, nu, nu.exe, xonsh, elvish, and osh inline payloads plus Nushell command forms and opaque transport execution failures.
  • Current-main comparison: Current main still lists only ash, bash, dash, fish, ksh, sh, and zsh as POSIX shell wrappers, so the central requested behavior is not already implemented there.
  • Contributor proof in discussion: The PR discussion reports focused proof on head f06324c: 17 targeted tests passed while exercising the real exec approval analysis/evaluation path with temporary executable fixtures only.
  • CI status from review context: The provided check summary shows openclaw/ci-gate, Real behavior proof, security-fast, Opengrep OSS, and relevant check suites completed successfully for this PR head.
  • History provenance: Shell wrapper resolution was split into its current module by c041f85, and later exec allowlist hardening in 50f4440 introduced the bound-argument protection this PR extends.
    • file: src/infra/shell-wrapper-resolution.ts:20
    • command: git blame -L 20,90 -- src/infra/shell-wrapper-resolution.ts && git log -S 'requiresBoundArgPattern' --date=short --pretty='%H%x09%ad%x09%an%x09%s' -- src/infra/exec-approvals-allowlist.ts | sed -n '1,20p'
    • sha: c041f8587b35

@pgondhi987

Copy link
Copy Markdown
Contributor Author

Verification before merge

Head: f06324c4fe594b3a77b2ef8beedfd54e18bcc73d

Review gates:

  • review-pr review-only gate passed with validated artifacts and zero findings.
  • Codex autoreview passed with no accepted or actionable findings.
  • Local ClawSweeper source review passed with no findings.
  • Local ClawSweeper proof review passed using current-head behavior evidence.

Validation:

  • node scripts/run-vitest.mjs src/node-host/invoke-system-run-plan.test.ts src/infra/exec-approvals-allow-always.test.ts src/infra/exec-wrapper-resolution.test.ts src/infra/exec-wrapper-trust-plan.test.ts src/infra/shell-inline-command.test.ts src/infra/system-run-command.test.ts src/infra/system-run-command.contract.test.ts src/node-host/invoke-system-run-allowlist.test.ts src/agents/bash-tools.exec-approval-request.test.ts
  • node scripts/run-tsgo.mjs -p test/tsconfig/tsconfig.core.test.json --incremental --tsBuildInfoFile .artifacts/tsgo-cache/core-test.tsbuildinfo
  • git diff --check
  • GitHub CI: 79 passed, 42 skipped, no failures after rerunning one unrelated flaky shard.

Behavior proof:

  • node scripts/run-vitest.mjs src/infra/exec-approvals-allow-always.test.ts --testNamePattern 'prevents allowlist bypass for .* inline shell payloads|prevents allowlist bypass for nu .* inline shell payloads|does not bind option values as shell script allowlist targets'
  • Result: Test Files 1 passed (1); Tests 17 passed | 74 skipped (91).
  • Denied path: recognized shell wrappers and Nushell attached command flags do not satisfy a bare wrapper allow-always entry and still require approval.
  • Control path: parseable shell calls still reject option-value decoys and accept the real script operand entry.

Merge notes:

  • PR is mergeable; GitHub currently reports the branch behind main but without conflicts.
  • No config, storage, protocol, or documented CLI surface changes were introduced.

@pgondhi987
pgondhi987 merged commit 2628fae into openclaw:main Jul 24, 2026
40 checks passed
vincentkoc added a commit that referenced this pull request Jul 24, 2026
…omic-publication-20260724

* origin/main:
  refactor(memory-lancedb): remove dead legacy path scan (#113299)
  fix(test): satisfy no-map-spread in exec approvals (#113303)
  fix: keep OAuth refresh failures terminal [AI] (#112957)
  fix: reusable exec approvals apply to approved arguments (#112946)
  refactor(agents): split tool search internals (#113296)
  fix: keep inline eval approvals one-shot [AI] (#112956)
  refactor(normalization): reuse trimmed list helpers (#113295)
  fix(openai): fail fast on invalid TLS certificates (#111818)
  fix: recognize more shell wrappers [AI] (#112955)
  fix(i18n): correct Indonesian seconds labels
  chore(i18n): refresh native locales
  fix: block opaque exec dispatch wrappers (#112953)
github-actions Bot pushed a commit to Desicool/openclaw that referenced this pull request Jul 25, 2026
* fix: recognize more shell wrappers

* fix: cover windows shell wrapper aliases

* fix: limit shell rewrite parsing set

* fix: recognize yash cmdline option

* fix: fail closed for opaque shell rewrites

* fix: recognize nushell execute mode

* fix: fail opaque shell allowlist matches closed

* fix: suppress opaque shell positional previews

* fix: parse nushell value options before commands

* fix: block opaque shell script fallbacks

* fix: keep nushell startup configs bound

* fix: preserve plus-option shell script binding

* fix: fail opaque shell fallback paths closed

* fix: reject shell inline flags in script fallback

* fix: block nushell startup option binding

* fix: fail opaque system run transports closed

* fix: deny hidden opaque shell approvals

* fix: keep startup shell payloads opaque

* fix: keep osh shell payloads opaque

* fix: use analysis result in allowlist test

* fix: parse nushell attached command flags

* fix: keep nushell attached parsing local
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

agents Agent runtime and tooling maintainer Maintainer-authored PR size: XL

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant