Repository navigation
fix(exec): require approval for recursive shell assignments - #187499
Conversation
Standalone assignments added no step or risk to the shell planner, but bash evaluates arithmetic, braced parameter expansion, and subscripted names recursively, so an allowlisted trailing step could hide arbitrary execution. Flag those assignments as unanalyzable, and treat NAME+=value cmd as an environment prelude like NAME=value cmd. Shell word text decoding and exec authorization risk classification move to sibling modules so the touched files stay within the line-cap ratchet.
|
🦞👀 Pull request received. I will update this pull request when review starts. ClawSweeper review completeClawSweeper finished reviewing this revision. The review result is being finalized. |
|
Codex review: needs maintainer review before merge. What this changesThis PR makes recursively evaluated standalone shell assignments require approval and recognizes append-style environment assignment preludes. Example: Run
Review scores
ProductKind: Bug fix · Worth it: Yes · Fix scope: Complete Merge readiness✅ Ready for maintainer review Keep this PR open for landing: it repairs an approval-boundary defect still present on main, and inspection found no introduced correctness defect. Priority: P1 Before mergeNone. FindingsNone. Agent review detailsHow this fits togetherShell source enters the Tree-sitter command explainer, whose syntax facts feed the shared authorization planner and gate gateway and node-host process execution. flowchart LR
A[Shell source] --> B[Command explainer]
B --> C[Assignment risk]
C --> D[Authorization planner]
D --> E[Approval policy]
E --> F[Process runner]
Technical reviewBest possible solution: Land the parser-owned risk classification and existing fail-closed mapping with the distinct syntax, authorization, and process-boundary regressions. Do we have a high-confidence way to reproduce the issue? Current-main source omits assignment risks while retaining trailing command candidates, and the supplied parent-baseline regressions report execution completing before the repair; this review ran no target code. Is this the best way to solve the issue? The smallest complete fix records the missing syntax fact at the explainer and reuses existing authorization policy; the sibling-module moves preserve their implementations and satisfy the existing file-budget constraint. AGENTS.md: found and applied where relevant. Codex review notes: model internal, reasoning medium; reviewed against 39b0e6ffaa2d. Provenance checked
TestingProof path: shipped entry point. SecurityNone. EvidenceWhat I checked:
Likely related people:
PR surfaceSource +41, Tests +96, Docs +5, Other 0. Total +142 across 11 files. Added test files: 0. View PR surface stats
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 (1 earlier review cycle)
Reviewed October 29, 2026, 8:30 AM ET / 12:30 UTC (Revision 2). |
ClawSweeper reviewReviewed October 29, 2026, 10:33 AM UTC. What this changesThe PR classifies recursively evaluated standalone shell assignments as unanalyzable so they require exec approval before process launch. PR surface: Source +41, Tests +96, Docs +5. Total +142 across 11 files. Merge readinessResult: ready for maintainer review. Overall: 🦞 diamond lobster Reviewed head: Review scores
VerificationStatus: sufficient How this fits togetherShell source enters the Tree-sitter command explainer, which emits command and risk facts consumed by the exec authorization planner; the resulting allowlist or approval decision gates gateway and node-host process creation. flowchart LR
A[Shell source] --> B[Command explainer]
B --> C[Assignment risk]
C --> D[Authorization planner]
D --> E[Approval gate]
E --> F[Process runner]
Before merge
Review detailsBest possible solution: Merge the producer-side classification and existing fail-closed mapping after the required exact-head checks finish successfully, retaining the distinct parser, authorization, and pre-spawn regressions. Do we have a high-confidence way to reproduce the issue? Yes at source level: the base explainer records no command step or blocking risk for a standalone assignment, while the trailing allowlisted command remains visible, and the supplied parent-baseline regressions failed because those commands completed. Is this the best way to solve the issue? Yes; the patch fixes the missing syntax fact at the command explainer, reuses the existing unanalyzable-risk policy, preserves literal assignments and command preludes, and proves rejection before process creation. AGENTS.md: found_applied Codex review notes: model internal, reasoning medium; reviewed against 4ececc4. Label detailsLabel justifications:
Evidence reviewedPR surface:
|
|
Behavior proof for exact head
The terminal proof used synthetic configuration and isolated state; it did not modify a live Gateway, channel, or model session. |
|
Verification before merge: exact head
The PR has not been merged. |
|
@clawsweeper re-review |
|
🦞👀 Re-review progress:
|
…#187499) * fix(exec): require approval for recursively evaluated shell assignments Standalone assignments added no step or risk to the shell planner, but bash evaluates arithmetic, braced parameter expansion, and subscripted names recursively, so an allowlisted trailing step could hide arbitrary execution. Flag those assignments as unanalyzable, and treat NAME+=value cmd as an environment prelude like NAME=value cmd. Shell word text decoding and exec authorization risk classification move to sibling modules so the touched files stay within the line-cap ratchet. * test(exec): prove recursive assignments stop before spawn * fix(exec): block keyed compound assignments * fix(exec): cover keyed array append entries * fix(exec): remove stale lint suppressions * chore(exec): prune stale line baselines
…#187499) * fix(exec): require approval for recursively evaluated shell assignments Standalone assignments added no step or risk to the shell planner, but bash evaluates arithmetic, braced parameter expansion, and subscripted names recursively, so an allowlisted trailing step could hide arbitrary execution. Flag those assignments as unanalyzable, and treat NAME+=value cmd as an environment prelude like NAME=value cmd. Shell word text decoding and exec authorization risk classification move to sibling modules so the touched files stay within the line-cap ratchet. * test(exec): prove recursive assignments stop before spawn * fix(exec): block keyed compound assignments * fix(exec): cover keyed array append entries * fix(exec): remove stale lint suppressions * chore(exec): prune stale line baselines (cherry picked from commit f980e01)
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 #187499 with existing helper locations retained. Co-authored-by: RomneyDa <[email protected]>
What Problem This Solves
Fixes: exec allowlist checks could treat a shell command as safe even when a standalone assignment performs recursive arithmetic, parameter, subscript, or keyed compound-array evaluation before an allowlisted command runs.
User Impact
User impact: recursively evaluated standalone assignments now fail closed instead of executing silently. Ordinary scalar assignments, unkeyed arrays, and command-prefixed environment assignments keep their existing behavior. Keyed compound-array assignments now require approval because their key semantics depend on prior shell array state.
Why This Change Was Made
The shell command explainer now marks recursively evaluated standalone assignments as unanalyzable, so the existing authorization policy fails closed. This includes keyed compound-array entries that tree-sitter flattens and cannot safely classify using prior indexed-versus-associative array state. Assignment preludes also recognize
NAME+=value commandconsistently withNAME=value command. Existing shell-text decoding and risk classification were moved into focused sibling modules to keep the owning files within the repository line-cap policy.Evidence
befe832957da3f58ae0bb6a7eb7f8d925d94c532.dynamic-assignmentrisk and require approval.NAME=value commandandNAME+=value commandremain environment preludes.system.runentry point launchedSTATIC=value; /usr/bin/echo static-okonce and returnedstatic-ok. It rejected all three recursive forms before the process runner, with zero launches and no marker files.pnpm test src/infra/command-explainer/extract.test.ts src/infra/command-explainer/format.test.ts src/infra/exec-authorization-allowlist.test.ts src/infra/exec-authorization-plan.test.ts src/infra/exec-authorization-render.test.ts src/infra/exec-safe-builtins.test.ts src/infra/exec-approvals-allow-always.test.ts src/infra/exec-approvals-safe-bins.test.ts src/node-host/invoke-system-run-allowlist.test.ts src/agents/bash-tools.exec-host-gateway.test.ts src/agents/bash-tools.exec-host-node.test.ts src/agents/bash-tools.exec-authorization.integration.test.ts --maxWorkers=1: 12 files passed, 292 tests passed, 3 skipped because optional local shells were unavailable.oxfmt, focusedoxlint --openclaw-focused-config, line-cap and test-line ratchets,tsgo:core,tsgo:test:src, andgit diff --checkpassed. CI identified two stalemax-linesdirectives and their corresponding baseline entries after the refactor shortened both files; those four stale records were removed, focused lint passed, and the max-lines plus line-cap ratchets passed at this head.Sanitized exact-head terminal receipt from an isolated node-host invocation:
The proof used synthetic configuration, isolated state, loopback-only execution, and no live external Gateway, channel, or model.