Skip to content

fix(agents): honor exec allowlists for Claude native Bash - #141471

Merged
steipete merged 2 commits into
mainfrom
codex/claude-cli-native-bash-allowlist
Sep 7, 2026
Merged

steipete merged 2 commits into
mainfrom
codex/claude-cli-native-bash-allowlist

Conversation

@steipete

@steipete steipete commented Sep 7, 2026 •

Copy link
Copy Markdown
Contributor

Related: #140473. Reported by @docfernando.

What Problem This Solves

Fixes an issue where operators using the Claude CLI backend had to approve every native Bash invocation even after allowlisting the binary for their agent. This blocked unattended CLI automation.

Why This Change Was Made

The native permission path previously considered only exec security and ask settings. It now reuses the exec shell evaluator, authorization renderer, and current-grant usage recorder. With ask: on-miss, fully classified commands whose binaries explicitly match the agent allowlist can auto-allow; the returned native input pins the resolved executable paths. Actual hook cwd and configured exec PATH prepends participate in evaluation. Manual approvals retain the native launch environment for file binding.

The existing binding owner still denies pipelines, substitutions, subshells, write redirections, and unparseable commands before prompting. Bindable misses explain the first unmatched segment or classification failure. ask: always, security: deny, ask-off policy, Bash allow-always refusal, description bounds, and current run authority remain enforced.

Ordinary sessions continue to use native Bash. The mediated exec seam remains scoped to its existing restricted runs. This is argument-level policy for the command Claude Code runs; cwd, environment, PATH, and sandboxing remain Claude Code's. Use a paired node or the embedded runtime with sandboxing when sandboxed execution is required.

User Impact

Operators can use an existing per-agent exec allowlist for unattended native Bash calls under ask: on-miss. Commands requiring manual approval still offer only allow-once or deny for Bash. Both CLI-backend and exec-approval documentation describe the boundary.

Evidence

  • Pre-fix synthetic regression: an explicitly allowlisted absolute executable returned deny/unavailable through the unfulfilled approval path instead of auto-allowing.
  • Focused tests: 105 passed across native approval, execution-host permission, and Claude native runtime suites. Covers absolute/PATH matches, configured PATH prepends, usage metadata, mandatory prompting, pipeline/binding denials, grant revocation, native executable drift, and cwd forwarding.
  • Production delta: +160/-120, net +40. Tests and test support: +211/-3, net +208. Docs: +38/-1, net +37.
  • Independent Codex autoreview: scoped-clean at P0–P2, including the test-file split.
  • node scripts/check-changed.mjs and git diff --check: PASS. The changed gate includes formatting, core/plugin and test typechecks, lint, max-lines and other repository guards, and dead-export scans.
  • Refreshed candidate head: d5c905919abca6a6720aea8e17bfa46eef6800e8. This is a patch-identical rebase onto repaired main; git range-diff reports both original commits unchanged. The focused tests, live proof, and independent review above were performed before that mechanical rebase; the refreshed head passed required hosted CI.

The live proof used an isolated state directory, fresh loopback Gateway, and the committed production build through node openclaw.mjs. The API-key profile existed before startup and was explicitly selected for the CLI route. A diagnostic preload observed credential-fingerprint creation and the API-key FD selection without logging credentials or changing the returned values. The first probe omitted the client approvals capability; after correcting that fixture, both real native Bash calls completed with the expected policy outcomes. No operator Gateway was touched.

Sanitized Gateway/probe excerpts:

{"event":"Claude credential prepared","fingerprintPresent":true}
2026-09-07T12:01:25.721-07:00 Claude CLI native Bash auto-allowed via exec allowlist
2026-09-07T12:01:31.963-07:00 [ws] → event plugin.approval.requested seq=per-client clients=2 targets=1 dropIfSlow=true
ALLOWLISTED_TURN {"status":"ok","text":["2026"],"tools":{"calls":1,"tools":["Bash"],"failures":0},"authMode":"auth-profile"}
APPROVAL_REQUEST {"phase":"non-allowlisted","title":"claude-cli native tool: Bash","description":"{\"command\":\"/usr/bin/uname -s\",\"description\":\"Print kernel name\"}\nExec allowlist miss: /usr/bin/uname -s","allowedDecisions":["allow-once","deny"]}
NON_ALLOWLISTED_TURN {"status":"ok","text":["It didn't run — the command was denied. Per your instructions I won't retry."],"tools":{"calls":1,"tools":["Bash"],"failures":1}}
SAW_MISS_APPROVAL true

Root-cause owner: src/agents/cli-runner/cli-native-tool-approval.ts; effective policy and PATH composition: src/agents/cli-runner/execute-plugin.ts. Hook cwd comes from extensions/anthropic/cli.runtime.ts. This deliberately reuses existing evaluator/renderer/binding owners rather than introducing another parser or exposing mediated local exec to ordinary CLI sessions.

Focused proof command (105 passed):

node scripts/run-vitest.mjs src/agents/cli-runner/cli-native-tool-approval.test.ts src/agents/cli-runner/execute-plugin.test.ts src/agents/cli-runner/execute-plugin-native-bash.test.ts extensions/anthropic/cli-runtime.test.ts

The original hosted run was blocked by check-lint-core-2: an unrelated main-file max-lines failure in ui/src/components/markdown.test.ts. That guard was repaired on main by #141466 in 7a1f677e3cb5d4882c0cff0d76dd4af196c27c58. Verified the landed split preserves all original suite bodies, passes all 115 Markdown tests and changed-file lint, and remains below the unchanged 1,000-line limit. The parallel focused repair #141486 was closed as superseded. This PR was then rebased without patch changes to obtain fresh exact-head CI evidence.

Native prepare and merge completed successfully. Landed as e57e375a40266b93fd1c9e66b9f0dc03da7d368a; main ancestry and all ten landed file contents were verified before closing #140473.

@clawsweeper

clawsweeper Bot commented Sep 7, 2026 •

Copy link
Copy Markdown
Contributor

🦞👀
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.

@steipete
steipete marked this pull request as ready for review September 7, 2026 19:07
@openclaw-barnacle openclaw-barnacle Bot added docs Improvements or additions to documentation gateway Gateway runtime agents Agent runtime and tooling extensions: anthropic size: M maintainer Maintainer-authored PR labels Sep 7, 2026
@clawsweeper clawsweeper Bot added P2 Normal backlog priority with limited blast radius. proof: sufficient ClawSweeper judged the real behavior proof convincing. 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. labels Sep 7, 2026
@clawsweeper

clawsweeper Bot commented Sep 7, 2026 •

Copy link
Copy Markdown
Contributor

Codex review: needs maintainer review before merge. Reviewed September 7, 2026, 3:42 PM ET / 19:42 UTC.

ClawSweeper review

What this changes

Claude native Bash calls reuse the agent’s exec allowlist, pin approved executable paths, and explain commands that still require approval.

Merge readiness

✅ Ready for maintainer review

This remains a useful fix: current main and the latest release still prompt for allowlisted native Bash commands. No blocking defect was found, and the supplied live evidence demonstrates both successful allowlisted execution and denial of a non-allowlisted command.

Priority: P2
Reviewed head: d5c905919abca6a6720aea8e17bfa46eef6800e8

Review scores

Measure Result What it means
Overall readiness 🐚 platinum hermit (4/6) A focused repair with relevant live evidence, meaningful regression coverage, and no blocking findings.
Proof confidence 🐚 platinum hermit (4/6) Sufficient (logs): The captured production Gateway and real Claude CLI logs exercise native Bash permission handling: an allowlisted call completes, while a non-allowlisted call prompts and is denied. Source and focused regression coverage support current-grant and run-lifecycle enforcement; the live evidence predates the reported mechanical rebase.
Patch quality 🐚 platinum hermit (4/6) No actionable review findings were identified.

Verification

Check Result Evidence
Real behavior Verified Sufficient (logs): The captured production Gateway and real Claude CLI logs exercise native Bash permission handling: an allowlisted call completes, while a non-allowlisted call prompts and is denied. Source and focused regression coverage support current-grant and run-lifecycle enforcement; the live evidence predates the reported mechanical rebase.
Evidence reviewed 9 items Current main still needs the fix: The fetched main implementation proceeds from Bash binding to interactive approval without evaluating the exec allowlist.
Latest release comparison: The v2026.9.2 implementation also lacks native Bash allowlist evaluation; the requested behavior is not already supplied by the latest release.
Allowlist authorization and binding: Auto-allow requires explicit allowlist matches for every directly executable candidate, successful enforced rendering, and successful binding. The existing usage recorder rereads current policy and grants before authorizing the result.
Findings None None.
Security None None.

How this fits together

The Claude CLI backend asks OpenClaw to authorize native tool calls before Claude Code executes them. This change connects Bash requests to the existing exec allowlist while retaining command binding and run-lifecycle checks.

flowchart TD
  A[Claude native Bash request] --> B[Run and tool policy checks]
  B --> C[Exec allowlist evaluation]
  C --> D[Command binding checks]
  D --> E[Pin allowlisted executable]
  D --> F[Prompt or deny other commands]
  E --> G[Current authority check]
  F --> G
  G --> H[Claude executes or rejects]
Loading

Before merge

None.

Agent review details

Security

None.

PR surface

Source +40, Tests +208, Docs +37. Total +285 across 10 files.

View PR surface stats
Area Files Added Removed Net
Source 4 160 120 +40
Tests 4 211 3 +208
Docs 2 38 1 +37
Config 0 0 0 0
Generated 0 0 0 0
Other 0 0 0 0
Total 10 409 124 +285

Review metrics

Metric Value Why it matters
Production versus test growth Production net +40 lines; tests and test support net +208 lines Production growth connects existing authorization owners, with focused coverage for matching, policy, binding, and revocation.

Technical review

Best possible solution:

Keep native Bash execution with Claude Code while applying the existing per-agent allowlist, command binding, and current-run authority at OpenClaw’s permission boundary.

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

Yes, from source: on current main, a native Bash request under ask on-miss reaches interactive approval even when its executable is allowlisted. This review did not execute a reproduction.

Is this the best way to solve the issue?

Yes. Reusing the existing evaluator, renderer, binding guard, and grant recorder addresses unattended execution without adding a competing shell parser or exposing mediated exec to ordinary CLI sessions.

AGENTS.md: found and applied where relevant.

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

Labels

Label justifications:

  • P2: Repairs unattended command execution for Claude CLI users with existing exec allowlists.
  • rating: 🐚 platinum hermit: Overall readiness is 🐚 platinum hermit; proof is 🐚 platinum hermit and patch quality is 🐚 platinum hermit.
  • status: 👀 ready for maintainer look: ClawSweeper has no concrete contributor-facing blocker left for this PR. Sufficient (logs): The captured production Gateway and real Claude CLI logs exercise native Bash permission handling: an allowlisted call completes, while a non-allowlisted call prompts and is denied. Source and focused regression coverage support current-grant and run-lifecycle enforcement; the live evidence predates the reported mechanical rebase.
  • proof: sufficient: Contributor real behavior proof is sufficient. The captured production Gateway and real Claude CLI logs exercise native Bash permission handling: an allowlisted call completes, while a non-allowlisted call prompts and is denied. Source and focused regression coverage support current-grant and run-lifecycle enforcement; the live evidence predates the reported mechanical rebase.

Evidence

What I checked:

  • Current main still needs the fix: The fetched main implementation proceeds from Bash binding to interactive approval without evaluating the exec allowlist. (src/agents/cli-runner/cli-native-tool-approval.ts, bc79a198dc0d)
  • Latest release comparison: The v2026.9.2 implementation also lacks native Bash allowlist evaluation; the requested behavior is not already supplied by the latest release. (src/agents/cli-runner/cli-native-tool-approval.ts, 3928bad9badf)
  • Allowlist authorization and binding: Auto-allow requires explicit allowlist matches for every directly executable candidate, successful enforced rendering, and successful binding. The existing usage recorder rereads current policy and grants before authorizing the result. (src/agents/cli-runner/cli-native-tool-approval.ts:140, d5c905919abc)
  • Current grants and final transport authority: The shared authorization owner rejects removed grants and tightened policy. The execution handler rechecks admission after approval, and the Claude transport invokes the run-bound response callback immediately before writing its control response. (src/infra/exec-approvals-authorization.ts:34, d5c905919abc)
  • Captured real behavior proof: The supplied PR body describes an isolated Gateway using the production build and real Claude CLI. Its logs show an allowlisted Bash call returning 2026 without failure, followed by a non-allowlisted uname request offering only allow-once or deny and ending denied. The body explicitly says this proof preceded the reported patch-identical rebase; no fresh runtime execution was performed during this review.
  • Focused regression coverage: Read the added tests covering PATH and absolute matches, executable pinning, usage metadata, mandatory prompting, binding rejection, grant revocation, and differing native versus configured PATH. Existing coverage also rejects retained callbacks and late approvals after run cancellation. The reported 105-test pass is contributor evidence, not a reviewer-executed result. (src/agents/cli-runner/execute-plugin-native-bash.test.ts:26, d5c905919abc)

Likely related people:

  • steipete: Suggested for follow-up; no historical authorship or introduction is verified. (role: unverified routing candidate; confidence: low)

Rating scale

Score Internal tier Crab rank Meaning
6/6 S 🦀 challenger crab Exceptional readiness
5/6 A 🦞 diamond lobster Very strong readiness
4/6 B 🐚 platinum hermit Good normal PR; ordinary maintainer review
3/6 C 🦐 gold shrimp Useful, but confidence is limited
2/6 D 🦪 silver shellfish Proof or implementation needs work
1/6 F 🧂 unranked krab Not merge-ready
N/A NA 🌊 off-meta tidepool Rating does not apply

Overall follows the weaker of proof and patch quality.
Shiny media proof means a screenshot, video, or linked artifact directly shows the changed behavior. Runtime, network, CSP, and security claims still need visible diagnostics.

Workflow

  • 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.

History

Review history (1 earlier review cycle)
  • reviewed 2026-09-07T19:23:10.961Z sha 871c65028e8f2012b498f8b9b611a7cb24951d49 :: needs maintainer review before merge. :: none

Reuse exec command authorization for native Bash under on-miss prompting. Preserve binding denials, mandatory prompting, current grants, and native execution ownership. Explain allowlist misses without granting standing Bash permission.

Related: #140473. Reported by @docfernando.
@steipete
steipete force-pushed the codex/claude-cli-native-bash-allowlist branch from 871c650 to d5c9059 Compare September 7, 2026 19:35
@steipete
steipete merged commit e57e375 into main Sep 7, 2026
180 checks passed
@steipete
steipete deleted the codex/claude-cli-native-bash-allowlist branch September 7, 2026 19:50
@steipete

steipete commented Sep 7, 2026

Copy link
Copy Markdown
Contributor Author

Merged via squash.

github-actions Bot pushed a commit to Desicool/openclaw that referenced this pull request Sep 8, 2026
…41471)

* fix(anthropic): honor native Bash exec allowlists

Reuse exec command authorization for native Bash under on-miss prompting. Preserve binding denials, mandatory prompting, current grants, and native execution ownership. Explain allowlist misses without granting standing Bash permission.

Related: openclaw#140473. Reported by @docfernando.

* test(agents): split native Bash policy coverage
necromman pushed a commit to necromman/openclaw that referenced this pull request Sep 16, 2026
…41471)

* fix(anthropic): honor native Bash exec allowlists

Reuse exec command authorization for native Bash under on-miss prompting. Preserve binding denials, mandatory prompting, current grants, and native execution ownership. Explain allowlist misses without granting standing Bash permission.

Related: openclaw#140473. Reported by @docfernando.

* test(agents): split native Bash policy coverage

(cherry picked from commit e57e375)
necromman pushed a commit to necromman/openclaw that referenced this pull request Sep 16, 2026
배치 A 체리픽이 이 포크에 없는 중간 리팩터링에 걸린 지점을 포크 코드에 맞춰 정리했다.

- 문자열 이스케이프 복구: attempt-prompt-build.ts, attempt-prompt-context.test.ts
- openclaw#140859: session-accessor.entry-mutation.ts 의 transcript 헤더 import 복원
- openclaw#141247: runs.ts 에서 포크에 없는 projectSessionActive 조건 제거
- openclaw#141471: execute-plugin.test-support.js 가 없어 native-bash 테스트 파일 제거
- openclaw#141960: quickjs-wasi 3.6.0 의 MAX_STACK_SIZE 를 쓸 수 없어 되돌림(포크는 3.5.0 핀)
- openclaw#142130: agents.ts 의 assertCurrent 호출 제거, cleanup-utils 는 선택 인자로 유지
- openclaw#142158: manifest-planner.ts 의 remoteModelIds·manifestModelsById 복원
- openclaw#143308: simple-completion-runtime.ts 에 acquireSimpleCompletionModelForAgent 래퍼 추가
- openclaw#143899: src/infra/file-descriptor.ts 의 fingerprint 비교 헬퍼 이식, backup-shared 의 configCapture 참조 제거

Co-Authored-By: Claude Fable 5.1 <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

agents Agent runtime and tooling docs Improvements or additions to documentation extensions: anthropic gateway Gateway runtime maintainer Maintainer-authored PR P2 Normal backlog priority with limited blast radius. proof: sufficient ClawSweeper judged the real behavior proof convincing. rating: 🐚 platinum hermit Good normal PR readiness with ordinary maintainer review expected. size: M status: 👀 ready for maintainer look ClawSweeper has no concrete contributor-facing blocker left for this PR.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant