Repository navigation
fix: require approval for dynamic shell predicates - #187884
Conversation
|
🦞👀 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 requires normal authorization for dynamic shell predicates and corrects ANSI-C quote handling during enforced command rendering. Example: Run
Review scores
ProductKind: Bug fix · Worth it: Yes · Fix scope: Complete Merge readiness✅ Ready for maintainer review Keep this PR open: it repairs a current approval-boundary defect, the maintainer accepted the compatibility tradeoff, and no introduced correctness defect remains; current-head CI is still pending. Priority: P1 Before mergeNone. FindingsNone. Agent review detailsHow this fits togetherAgent exec commands enter shared shell planning and allowlist evaluation; authorized commands pass through rendering and live policy checks before the process supervisor launches them. flowchart LR
A[Agent exec command] --> B[Shell authorization planner]
B --> C[Allowlist and builtin classification]
C --> D[Operator approval when required]
C --> E[Authorized command rendering]
D --> E
E --> F[Current authority check]
F --> G[Process supervisor]
Technical reviewBest possible solution: Retain the existing classifier and renderer owners, restrict automatic predicate trust to static source, and preserve live approval checks before launch. Do we have a high-confidence way to reproduce the issue? Current source exposes the argv/source mismatch, and supplied red/green evidence confirms classifier and renderer failures before the repair; this read-only review ran no target code. Is this the best way to solve the issue? The patch repairs the shared trust boundary without adding policy state or configuration, retains literal predicates, and addresses the independently reported dollar-pair regression. AGENTS.md: found and applied where relevant. Codex review notes: model internal, reasoning medium; reviewed against a1d1da77f8e8. Provenance checked
TestingProof path: shipped entry point. SecurityNone. EvidenceWhat I checked:
Likely related people:
PR surfaceSource +26, Tests +221, Other +2. Total +249 across 8 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 (8 earlier review cycles)
Reviewed October 30, 2026, 7:21 PM ET / 23:21 UTC (Revision 9). |
|
🦞👀 Re-review progress:
|
|
🦞👀 Re-review progress:
|
|
🦞👀 Re-review progress:
|
|
Maintainer decision: accept conservative literal predicate gating. I accept that quoted literal filenames containing shell metacharacters, such as This explicitly resolves the quoted-literal authorization decision requested by the human review and Clawsweeper for head |
|
🦞👀 Re-review progress:
|
Integrate canonical main 4368b27, including merged upstream PR openclaw#188780 restoring measured test-code headroom. Retain the eight PR-owned files byte-for-byte from reviewed head 9f951bd, including every regression assertion and the exact 221-line test allocation. No separate PR-local baseline raise is introduced.
|
@clawsweeper re-review |
|
🦞👀 Re-review progress:
|
eleqtrizit
left a comment
There was a problem hiding this comment.
Re-reviewed at 640fd5d1ff4. All four findings from my previous review are resolved:
$$'scanner regression (HIGH) — fixed in 9f951bd: the scanner now consumes$$in pairs (previousUnescapedDollar = char === "$" && !previousUnescapedDollar), so only an unmatched$opens ANSI-C mode. Even/odd dollar-run regressions added ($$'and$$$$'fail closed; one/three-dollar genuine ANSI-C controls stay green). Verified by reading the final code in the worktree.- Maintainer confirmation — recorded on the PR (2026-10-30, conservative literal predicate gating accepted).
- CI — 60 checks passing, 0 failing at this head.
- Mergeability — MERGEABLE (BLOCKED only by this outstanding review).
The dead optional chaining was also cleaned up, and the upstream-main integration brought in the adjacent exec-gating fixes (arithmetic #187653, recursive assignments #187499) with their regressions retained.
Verification executed locally at the exact head (Node 24, Linux): focused suites exec-safe-builtins + exec-authorization-render + bash-tools.exec-authorization.integration → 57 passed | 2 skipped, including the 9 new dollar-pair regressions; real-gateway approval e2e → 3/3 passed, including the dynamic-predicate approval/revocation test with real approval RPCs and no mocks. Not executed here: full CI matrix and Windows paths (covered by CI).
The static-source gate, literal-predicate preservation, and approval-path behavior are unchanged from the previously reviewed core repair. Approving — this also clears the review-requested block.
* fix: require approval for dynamic shell predicates * test: prove gateway predicate approval outcomes * test: use managed config reload in gateway approval e2e * test: prove predicate policy in gateway agent turn
* fix: require approval for dynamic shell predicates * test: prove gateway predicate approval outcomes * test: use managed config reload in gateway approval e2e * test: prove predicate policy in gateway agent turn
* fix: require approval for dynamic shell predicates * test: prove gateway predicate approval outcomes * test: use managed config reload in gateway approval e2e * test: prove predicate policy in gateway agent turn (cherry picked from commit 3f7ee38) Release adaptation: Apply both production owners and adapt Gateway approval and model-planned QA coverage to the release APIs, including managed config reload. Co-authored-by: RomneyDa <[email protected]>
Adapt approved source fixes to the September extended-stable owners. Preserve original APIs and custody; include review-driven regressions. Backport-of: 0a171b4 — Leizhen Zhang — fix(auto-reply): long punctuation runs stall abort-trigger detection (#184433) Backport-of: 49600b5 — Long Jin — fix(memory): preserve inline notes during MEMORY.md compaction (#164089) Backport-of: 982f3b1 — RoboClaw — fix(imessage): report Automation failures after Gateway updates (#186117) Backport-of: 3f7ee38 — art22s — fix: require approval for dynamic shell predicates (#187884) Validation: independent source review, exact patch/file identity and git diff --check. Runtime tests, types and builds deferred to authorized remote CI; not run locally. Co-authored-by: RomneyDa <[email protected]>
* fix(gateway): publish node reapproval with committed pairing facts Adapt main commit 94f180d to the extended-stable worker dispatcher, retaining cleanup admission and stale-session fencing. Co-authored-by: RomneyDa <[email protected]> * test(gateway): clarify CLI announcement tool-only phase Keep exact token, barrier, and completion ordering assertions intact while explicitly excluding narration before the barrier. Co-authored-by: RomneyDa <[email protected]> * style(gateway): format node reapproval regression Reflow the spy chain reported by hosted CI; no behavioral changes. Co-authored-by: RomneyDa <[email protected]> * test(secrets): decouple Telegram fixture from plugin discovery Import the real public Telegram secret collector directly so collection does not depend on Gateway discovery environment. Exercise collection with bundled plugins disabled while retaining existing token assertions. Gateway timeout attribution remains unresolved; no production behavior or timeout changes. Co-authored-by: RomneyDa <[email protected]> * test(secrets): load Telegram fixture through public resolver Replace the static extension import rejected by core type and boundary checks with the existing test public-artifact resolver. Keep the real collector in the Vitest module graph and preserve the disabled-discovery regression. Independent source review accepted; local test, typecheck, build, install, and performance execution remain excluded by operator instruction. Hosted CI must validate the correction. Co-authored-by: RomneyDa <[email protected]> * style(secrets): format Telegram fixture import Co-authored-by: RomneyDa <[email protected]> * fix(ui): honor recovery holds before initial chat history Keep drafting available while the existing send owner holds recovery or a retained initial turn. Restore Send when that hold clears without waiting for initial history or submitting the draft automatically. Add renderer regressions for both holds and clarify the pre-history outbox contract. Controlled real-Gateway red/green evidence: 42523861169 / 42526889715. Diagnostic branch is not merged. Co-authored-by: RomneyDa <[email protected]> * fix(ui): preserve startup status presentation while holding send Restore the existing connected startup/history status suppression without reopening Send admission. Extend both durable hold regressions to reject the duplicate composer status band. Existing cloud E2E assertions remain unchanged. Co-authored-by: RomneyDa <[email protected]> * fix(release): backport installer, service, path and telemetry repairs Adapt approved source fixes to the September extended-stable owners. Preserve original APIs and custody; include review-driven regressions. Backport-of: eb5d0cb — Javier MV — fix(install): keep the installed runtime private under umask 0002 (#186782) Backport-of: b079019 — Sukhdeep — fix(daemon): Gateway repair stops the Gateway and fails when macOS denies the Trash (#189321) Backport-of: 558e2f3 — YangManBOBO — fix(cli): compare gateway state dirs case-insensitively on Windows (#185917) Backport-of: b7ce1c3 — Peter Steinberger — test(windows): keep ordinary CLI coverage in one partition Backport-of: ba75cf7 — Juan Buhagiar Duijst — fix(diagnostics-otel): gateway stalls after model calls on large sessions with content capture on (#186666) Validation: independent source review, exact patch/file identity and git diff --check. Runtime tests, types and builds deferred to authorized remote CI; not run locally. Co-authored-by: RomneyDa <[email protected]> * fix(release): preserve notes and harden messaging and exec approval Adapt approved source fixes to the September extended-stable owners. Preserve original APIs and custody; include review-driven regressions. Backport-of: 0a171b4 — Leizhen Zhang — fix(auto-reply): long punctuation runs stall abort-trigger detection (#184433) Backport-of: 49600b5 — Long Jin — fix(memory): preserve inline notes during MEMORY.md compaction (#164089) Backport-of: 982f3b1 — RoboClaw — fix(imessage): report Automation failures after Gateway updates (#186117) Backport-of: 3f7ee38 — art22s — fix: require approval for dynamic shell predicates (#187884) Validation: independent source review, exact patch/file identity and git diff --check. Runtime tests, types and builds deferred to authorized remote CI; not run locally. Co-authored-by: RomneyDa <[email protected]> * fix(release): retain sandbox, recovery lease and Matrix boundaries Adapt approved source fixes to the September extended-stable owners. Preserve original APIs and custody; include review-driven regressions. Backport-of: a19f1bf — Agustin Rivera — fix(agents): fail closed when sandboxed spawned children resolve CLI-backed models (#178742) Backport-of: c9f3f82 — Peter Steinberger — fix(agents): release restart-recovery fences for killed runs (#181992) Backport-of: dfb6454 — Leizhen Zhang — fix(matrix): crafted formatted_body stalls the Gateway in the mention check (#184432) Validation: independent source review, exact patch/file identity and git diff --check. Runtime tests, types and builds deferred to authorized remote CI; not run locally. Co-authored-by: RomneyDa <[email protected]> * fix(config): preserve last-good state through writes and rollback Adapt approved source fixes to the September extended-stable owners. Preserve original APIs and custody; include review-driven regressions. Backport-of: 99418fc — weiqinl — fix(config): keep last-known-good when the observer flags the config as truncated (#152565) Validation: independent source review, exact patch/file identity and git diff --check. Runtime tests, types and builds deferred to authorized remote CI; not run locally. Co-authored-by: RomneyDa <[email protected]> * fix(sessions): preserve history when relocating relative stores Adapt approved source fixes to the September extended-stable owners. Preserve original APIs and custody; include review-driven regressions. Backport-of: a64daf7 — Peter Steinberger — fix(sessions): resolve relative session stores against the state dir, not the working directory (#182444) Validation: independent source review, exact patch/file identity and git diff --check. Runtime tests, types and builds deferred to authorized remote CI; not run locally. Co-authored-by: RomneyDa <[email protected]> * fix(release): repair September backport type contracts Split terminal recovery actions into distinct discriminants without changing behavior. Use the branch-native Doctor import signature, checking held maintenance authority before and after the awaited import. Validation: independent exact-diff source review, formatter and git diff --check passed. Local tests, typechecks and builds not run per operator restriction; fresh exact-head remote qualification required. Repairs CI 42643973970 attempt 1. Co-authored-by: RomneyDa <[email protected]> * fix(release): align backport regressions with September contracts Preserve uncertain config-write outcomes while correcting branch-native fixture APIs and lint errors found by hosted CI. Co-authored-by: RomneyDa <[email protected]> * test(ci): separate Windows capacity from growing inventory Keep package coverage and the five-job limit independent of a historical timing snapshot. Preserve the rounded capacity boundary and exercise the documented bounded-growth fallback with fixed estimates. Co-authored-by: RomneyDa <[email protected]> * test(node-host): keep launcher cleanup with its invoke owner Wait for a positive launcher PID before probing liveness, and cancel through the existing invocation owner on every exit path. Never send SIGKILL to file-derived PID zero. Co-authored-by: RomneyDa <[email protected]> * test(release): observe owned Gateway reservation cleanup Verify the real reservation closes before relaunch instead of rebinding an already-released port that another socket can acquire. Preserve all seven packaged startup recovery scenarios. Co-authored-by: RomneyDa <[email protected]> * test(release): capture native compiler busy-executable evidence Preserve real API execution and errors while recording failure-only executable inode and writable descriptor metadata. Add a Linux kernel-path diagnostic regression; no retry or copy change. Co-authored-by: RomneyDa <[email protected]> * test(release): repair stability regression fixtures Register CLI admission metadata through the runtime registry, observe the rollback health baseline, and preserve exact SQLite byte expectations. Co-authored-by: RomneyDa <[email protected]> --------- Co-authored-by: Peter Steinberger <[email protected]> Co-authored-by: RomneyDa <[email protected]>
Restrict the predicate builtin exemption to static raw operands and track ANSI-C shell quoting when rendering authorized commands. Preserve ordinary static predicates and existing live-authority checks. Proof: baseline 7 failing focused regressions; 147 focused checks and 4 isolated Gateway checks pass. Two platform fixtures and nine unselected QA cases remain skipped. Loopback-only NO_PROXY resolves the ambient proxy failure in the model fixture. Co-authored-by: RomneyDa <[email protected]>
Summary
Require normal exec approval for predicates whose shell source can expand or be interpreted differently from parsed argv. This narrows the safe-builtin exemption introduced by #79363 and extended to predicates in the later builtin work, while retaining ordinary literal predicate checks. It complements the exact
-vguard from #180880 and corrects the quote scanner added with the shared authorization planner in #84172.What Problem This Solves
What this Problem Solves
In gateway
execallowlist mode, a predicate can appear harmless tosrc/infra/exec-safe-builtins.tswhile Bash later synthesizes a different operand and runs an external command.src/infra/exec-authorization-render.tscan also miss a glob after an escaped quote in an ANSI-C string. Together, these mismatches can let a model supplied command cross the approval boundary without a matching allowlist entry or operator approval. The classifier now withholds automatic trust from ambiguous predicate source, and the renderer catches that escaped quote form before dispatch.What was wrong
src/infra/exec-safe-builtins.tschecked the parsedtestor[argv for an exact-vtoken. Shell expansion could produce a different operand after that check.src/infra/exec-authorization-render.tstreated an escaped single quote inside$'...'as the end of an ordinary single-quoted string, hiding a following glob from the enforced renderer.The combined effect was automatic authorization of a command whose final Bash behavior exceeded the reviewed predicate.
Why this design
$$PID parameter as a pair so the following ordinary single quote keeps Bash semantics.test -dand[ -d ]checks, including quoted paths with spaces, on the existing automatic path.Why this does not conflict with related PRs
-vrejectionThese changes are based on
mainafter those PRs and change only the predicate trust and renderer checks.Evidence of Fix
node --import ./scripts/tsx.mjs --input-type=modulesource probe of the benign ANSI-C quote plus glob regression shapeanalysisOk=true,allowlistSatisfied=true,safeBuiltins; new classifier test failedallowlistSatisfied=false; classifier test passesok=true; new renderer test failedshell expansion in enforced argumentseval git status $$'a\'?vand the four-dollar variant, with null satisfaction metadata8bca86cd, the renderer returnedok=truefor both; the two new rejection cases failed. Ordinary direct$$arguments were already blocked upstream asdynamic-argumentshell expansion in enforced arguments; one- and three-dollar ANSI-C quoted-glob controls remain acceptedtest -e *.txtplus allowlistedprintfexec denied: allowlist missbefore process launchexec.approval.resolveRPCapprovedexec.approvals.setchanged security to deny before allow-once resolutionExec approval changed before execution; no process resultchat.sendturns withtest -e proof.txt && pwdandtest -e *.txt && pwdunder the same real allowlist/off policy; observed the pairedexectool outputsexec denied: allowlist missand nopwdoutputnode scripts/run-vitest.mjs src/infra/exec-safe-builtins.test.ts --maxWorkers=1testand[checks pass, including a quoted path with spaces[email protected]CLIapprovals set --file <synthetic-policy>; patcheddoctor --fix --non-interactive,approvals get --json, then shared evaluator, all in isolated statetest -d .remained automatic andtest -e *.txtrequired approvalnode scripts/run-vitest.mjs src/infra/exec-safe-builtins.test.ts src/infra/exec-authorization-render.test.ts src/agents/bash-tools.exec-authorization.integration.test.ts --maxWorkers=1The real-owner gateway test exercises operator approval RPC and the process supervisor; its approved outcome is observed at the process output, and its denied and policy-changed outcomes stop before execution.
SDK / caller upgrade contract
Callers using ordinary static predicates keep automatic execution. Predicates with dynamic or ambiguous source syntax require the existing allowlist or approval decision; with approval disabled, they are denied. A policy written by the latest published stable CLI remained readable after the patched runtime's supported doctor migration, with the same defaults and agent allowlist. The classifier and real Gateway boundary tests cover these outcomes.
Boundary decision
art22s: quoted literal filenames containing shell metacharacters, such as[ -f 'report[v2].txt' ], use the existing allowlist/approval authority. With approval disabled and no matching entry, these forms are denied. Retain the current static-source gate; ordinary static predicates and quoted paths containing spaces remain automatic. The explicit decision is recorded on this PR.Testing
main: 57 passed, 2 skipped (10.47 s Vitest). The two new PID-prefixed quote rejection cases failed at the intended renderer assertion before the dollar-pair repair; both pass after it, and ANSI-C quoted-glob controls remain green.node scripts/run-vitest.mjs src/agents/bash-tools.exec-gateway-approval.e2e.test.ts --maxWorkers=1: all 3 tests passed on the final integrated candidate (17.42 s Vitest). The new predicate test uses the real Gateway and approval/process owners with no RPC or process mocks; the existing hook reload test now updates config through the Gateway's managedconfig.patchpath to avoid a missed file-watcher event.8bca86cd, cross-process QA agent-turn E2E: focused case passed after matching each model-planned tool call to its result; the complete QA file passed 10/10 before that final assertion refinement (110.22 s Vitest, 127.03 s wrapper). The local provider is deterministic and does not represent a live model decision.git diff --checkpassed. The four-file validation wrapper took 338.64 s including a fresh 271.3 s runtime build required after integratingmain.640fd5d1ff47with no findings or Before merge items, sufficient proof (4/6), and Ready for maintainer review. The quoted-literal authorization decision is explicitly accepted above.config/test-lines-allocations/static-predicate-approval.txtallocates exactly the 221 added LF lines for distinct classifier, renderer, real approval/revocation, and agent-turn contracts; carry this reason into the squash body. Integrated canonical main commit4368b276f5a3, which includes the published budget repair #188780. The eight PR-owned file blobs remain byte-identical to reviewed head9f951bd673cf, and the shared baseline matches canonical main exactly. The staged canonical test-line check now passes: 6,313,918 lines, effective ceiling 6,345,942, slack 32,024. Hosted CI run 41143275791 completed successfully on640fd5d1ff47. The baseline check, aggregate CI gate, and required CI status all pass.