Repository navigation
fix(exec): require approval for legacy arithmetic arguments - #187653
Conversation
Bash re-evaluates the text of a `$[...]` arithmetic expansion, so an array subscript rebuilt from ANSI-C numeric escapes can run command substitution even though no literal `$(` appears in the source. The shell authorization plan already blocked `$((...))` dynamic arguments but its expansion pattern missed the legacy `$[` form, so quoted `"$[...]"` operands on safe builtins such as `:` and `cd` were auto-allowed and executed unchanged. Treat `$[` like the other runtime shell expansions so these commands fall back to approval.
|
🦞👀 Pull request received. I will update this pull request when review starts. |
|
@clawsweeper re-review |
|
🦞👀 Re-review progress:
|
|
Codex review: needs maintainer review before merge. What this changesRequire legacy Bash arithmetic arguments to follow the existing approval policy for dynamic shell arguments. Example: Run
Review scores
ProductKind: Bug fix · Worth it: Yes · Fix scope: Complete Merge readiness✅ Ready for maintainer review This PR fixes a current approval bypass with a minimal change at the shared authorization owner; no actionable introduced defects remain. Priority: P1 Before mergeNone. FindingsNone. Agent review detailsHow this fits togetherGateway exec and node-host system.run pass shell commands through the command explainer and shared authorization planner before approval evaluation and process launch. flowchart LR
A[Shell command] --> B[Command explainer]
B --> C[Authorization planner]
C --> D[Host approval policy]
D --> E[Denied before launch]
D --> F[Authorized process execution]
Technical reviewBest possible solution: Land the existing shared-planner repair with its policy and pre-launch regressions. Do we have a high-confidence way to reproduce the issue? Current-main source shows arithmetic risks reaching a matcher that misses legacy syntax, and the contributor reports the new gateway regression failing on the original base because the command executes; this read-only review ran no target code. Is this the best way to solve the issue? The defect is missing legacy-expansion recognition, the invariant is that runtime shell expansion cannot inherit harmless-builtin trust, and extending the existing classifier is the smallest complete repair. AGENTS.md: found and applied where relevant. Codex review notes: model internal, reasoning medium; reviewed against 6c672d42f2de. Provenance checked
TestingProof path: in-process harness. SecurityNone. EvidenceWhat I checked:
Likely related people:
PR surfaceSource +2, Tests +36, Other +2. Total +40 across 4 files. Added test files: 0. View PR surface stats
Review metrics
LabelsLabel changes: No label changes. Label justifications:
Rating scale6/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. WorkflowClawSweeper edits this one comment on every review. Comment HistoryReview history (3 earlier review cycles)Reviewed October 29, 2026, 10:21 AM ET / 14:21 UTC (Revision 4). |
|
@clawsweeper re-review |
|
🦞👀 Re-review progress:
|
ClawSweeper reviewReviewed October 29, 2026, 1:14 PM UTC. What this changesThis PR makes legacy Bash PR surface: Source +2, Tests +36, Config +2. Total +40 across 4 files. Merge readinessResult: ready for maintainer review. Overall: 🦞 diamond lobster Reviewed head: Review scores
VerificationStatus: sufficient How this fits togetherThe command explainer emits dynamic-argument risks, and the shared authorization planner turns them into decisions consumed by Gateway exec and node-host system.run before process launch. flowchart LR
A[Shell command] --> B[Command explainer]
B --> C[Dynamic argument risk]
C --> D[Authorization planner]
D --> E[Approval policy]
E -->|denied| F[No process launch]
E -->|allowed| G[Process supervisor]
Before merge
Review detailsBest possible solution: Merge the one-owner planner check with its policy and real-process pre-launch regressions after ordinary exact-head checks complete. Do we have a high-confidence way to reproduce the issue? Yes: current main omits Is this the best way to solve the issue? Yes: extending the existing expansion classifier is the smallest complete fix and preserves the planner as the sole authorization owner without adding configuration, state, wrappers, or alternate paths. AGENTS.md: found_applied Codex review notes: model internal, reasoning medium; reviewed against a9c067b. Label detailsLabel justifications:
Evidence reviewedPR surface:
|
|
Behavior proof for exact head The isolated Linux/Bash gateway exec-tool regression and standalone runtime harness exercise the production authorization planner, shell preparation, and real process supervisor. With an empty allowlist and approval fallback set to deny, the literal control The standalone command
This proof used synthetic configuration and temporary state. No live external Gateway, channel, or model was used. The separate local typecheck was unavailable because its declaration wrapper rejects the borrowed dependency installation; canonical PR CI production and test typecheck jobs passed for this exact head. The shipped node-host |
|
Verification before merge: exact head
The PR has not been merged. |
Keep the main branch risk-classifier extraction and move the legacy arithmetic expansion check into exec-authorization-risks.ts. Retain both arithmetic and recursive-assignment execution regressions. Gateway and node-host production execution proofs pass on the resolved source: literal controls execute; legacy and modern arithmetic are denied before process launch. Focused lint, formatting, diff checks, and test/file line ratchets pass. The planner suite passed 19 tests; remaining Vitest execution is blocked by ENOSPC during runtime-worker compilation. Previous green PR CI: run 40875371853 at e9fe4f1; current-head CI must run after push.
…#187653) * fix(exec): gate legacy $[...] arithmetic arguments in allowlist mode Bash re-evaluates the text of a `$[...]` arithmetic expansion, so an array subscript rebuilt from ANSI-C numeric escapes can run command substitution even though no literal `$(` appears in the source. The shell authorization plan already blocked `$((...))` dynamic arguments but its expansion pattern missed the legacy `$[` form, so quoted `"$[...]"` operands on safe builtins such as `:` and `cd` were auto-allowed and executed unchanged. Treat `$[` like the other runtime shell expansions so these commands fall back to approval. * test(exec): verify arithmetic arguments stop before process launch
…#187653) * fix(exec): gate legacy $[...] arithmetic arguments in allowlist mode Bash re-evaluates the text of a `$[...]` arithmetic expansion, so an array subscript rebuilt from ANSI-C numeric escapes can run command substitution even though no literal `$(` appears in the source. The shell authorization plan already blocked `$((...))` dynamic arguments but its expansion pattern missed the legacy `$[` form, so quoted `"$[...]"` operands on safe builtins such as `:` and `cd` were auto-allowed and executed unchanged. Treat `$[` like the other runtime shell expansions so these commands fall back to approval. * test(exec): verify arithmetic arguments stop before process launch (cherry picked from commit 3f34977)
Alex, room openclaw#620. Of the 72 11.3..11.4 commits the census counted as production changes, six main fixes are ported: openclaw#187499, openclaw#187653, openclaw#188023, openclaw#195400, openclaw#196297 and openclaw#197960. PORTING-NOTES.md, "The 72 11.4 repairs reviewed against the carry", records each deferral with its reason, the two UNSURE outcomes, and the M4 qualification.
Backport #187653 into the existing release authorization planner. Source: 3f34977. Co-authored-by: Pavan Kumar Gondhi <[email protected]> Co-authored-by: RomneyDa <[email protected]>
What Problem This Solves
Fixes: exec allowlist evaluation could automatically accept legacy Bash arithmetic arguments even though equivalent modern arithmetic already requires approval.
User Impact
User impact:
$[...]arguments now follow the existing approval policy for dynamic shell arguments. Ordinary literal builtin commands continue to run under the same settings.Why This Change Was Made
The command explainer already identifies these arguments as dynamic. This adds the missing arithmetic form to the authorization planner's existing expansion check. No new policy owner or configuration is introduced.
Evidence
e9fe4f14b4c8a88531446c9fbfe5716fae85ab80.: benign; pwdcompletes with one process launch. Encoded legacy and modern arithmetic commands are rejected before process launch, with zero launches and no marker-file side effect.pnpm test src/infra/exec-safe-builtins.test.ts src/infra/exec-authorization-plan.test.ts src/infra/exec-authorization-render.test.ts src/infra/exec-authorization-allowlist.test.ts src/infra/exec-allow-always-persistence.test.ts src/infra/exec-approvals-safe-bins.test.ts src/node-host/invoke-system-run-allowlist.test.ts src/agents/bash-tools.exec-authorization.integration.test.ts --maxWorkers=1.git diff --checkpass. Test-line and line-cap ratchets pass against the original branch base.check-prod-types,check-test-types, and all fivecheck-test-types-core-*jobs passed at this head. Tests and formatting/lint ran without modifying the shared installation.Standalone execution receipt
Command: repository-pinned
bun .local/gateway-runtime-proof.ts, using Bun revision1.4.4-canary.1+191755ec1(the Node-compatible API reports v26.12.1); exit status 0. This standalone local harness runs outside Vitest. It seeds synthetic approval policy through the production maintenance API, calls the productioncreateExecTool, and counts supervisor launches while delegating to the real process supervisor. It uses no Gateway or process mock. Only the observed scalar results below are captured; no inherited environment or credentials are logged.Node-host system.run entry-point receipt
Command: repository-pinned
bun .local/node-host-runtime-proof.ts; exit status 0. This invokes the shippedhandleSystemRunInvokeentry point with a prepared synthetic runtime config and an empty executable allowlist. Its command-runner callback delegates to the productionrunCommand, so the allowed control executes real Bash. The two denied requests never call that runner. The receipt captures actual responses and marker checks; transport callbacks collect replies locally. No live external Gateway or model is used.Main CI run 40875371853 completed successfully for this exact head, including production/test types, lint, changed-path tests, and baseline checks.