Skip to content

fix(exec): require approval for recursive shell assignments - #187499

Merged
pgondhi987 merged 7 commits into
openclaw:mainfrom
pgondhi987:fix/fix-1145
Oct 30, 2026
Merged

pgondhi987 merged 7 commits into
openclaw:mainfrom
pgondhi987:fix/fix-1145

Conversation

@pgondhi987

@pgondhi987 pgondhi987 commented Oct 29, 2026 •

Copy link
Copy Markdown
Contributor

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 command consistently with NAME=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

  • Exact head: befe832957da3f58ae0bb6a7eb7f8d925d94c532.
  • Negative cases: scalar arithmetic indirection, subscripted assignment names, direct keyed arrays, keyed-array entry appends, outer append keyed arrays, and numeric keyed arrays produce a dynamic-assignment risk and require approval.
  • Positive controls: literal and quoted scalar assignments and unkeyed arrays remain analyzable, while NAME=value command and NAME+=value command remain environment preludes.
  • Final-effect proof: the shipped node-host system.run entry point launched STATIC=value; /usr/bin/echo static-ok once and returned static-ok. It rejected all three recursive forms before the process runner, with zero launches and no marker files.
  • Parent baselines: the scalar gateway regression failed on the original parent because the command completed; the compound parser and gateway regressions failed before their respective compound-array remediations for the same reason.
  • 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.
  • Focused oxfmt, focused oxlint --openclaw-focused-config, line-cap and test-line ratchets, tsgo:core, tsgo:test:src, and git diff --check passed. CI identified two stale max-lines directives 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:

OPENCLAW_PROOF {
  "head": "befe832957da3f58ae0bb6a7eb7f8d925d94c532",
  "route": "node-host system.run -> exec authorization -> process runner",
  "staticAssignment": {
    "result": {
      "ok": true,
      "payload": {
        "exitCode": 0,
        "timedOut": false,
        "success": true,
        "stdout": "static-ok\n",
        "stderr": "",
        "error": null
      }
    },
    "processLaunches": 1
  },
  "recursiveScalarAssignment": {
    "result": {
      "ok": false,
      "error": {
        "code": "SYSTEM_RUN_DENIED",
        "message": "SYSTEM_RUN_DENIED: approval required"
      }
    },
    "processLaunches": 0,
    "markerExists": false
  },
  "recursiveKeyedAssignment": {
    "result": {
      "ok": false,
      "error": {
        "code": "SYSTEM_RUN_DENIED",
        "message": "SYSTEM_RUN_DENIED: approval required"
      }
    },
    "processLaunches": 0,
    "markerExists": false
  },
  "recursiveKeyedAppendAssignment": {
    "result": {
      "ok": false,
      "error": {
        "code": "SYSTEM_RUN_DENIED",
        "message": "SYSTEM_RUN_DENIED: approval required"
      }
    },
    "processLaunches": 0,
    "markerExists": false
  }
}

The proof used synthetic configuration, isolated state, loopback-only execution, and no live external Gateway, channel, or model.

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.
@clawsweeper

clawsweeper Bot commented Oct 29, 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.

@openclaw-barnacle openclaw-barnacle Bot added docs Improvements or additions to documentation size: L labels Oct 29, 2026
@clawsweeper clawsweeper Bot added clawsweeper:intake:bug Preliminary submission classification; full source review pending. clawsweeper:intake:needs-environment Preliminary submission classification; full source review pending. P1 High-priority user-facing bug, regression, or broken workflow. merge-risk: 🚨 security-boundary 🚨 May affect sandboxing, authorization, credentials, or sensitive data. rating: 🧂 unranked krab Not merge-ready due to missing proof or serious correctness/safety concerns. status: 📣 needs proof The PR needs real behavior proof before ClawSweeper can clear the contributor ask. and removed clawsweeper:intake:bug Preliminary submission classification; full source review pending. clawsweeper:intake:needs-environment Preliminary submission classification; full source review pending. labels Oct 29, 2026
@clawsweeper

clawsweeper Bot commented Oct 29, 2026 •

Copy link
Copy Markdown
Contributor

Codex review: needs maintainer review before merge.

What this changes

This PR makes recursively evaluated standalone shell assignments require approval and recognizes append-style environment assignment preludes.

Example: Run x[y]=1; true with executable allowlisting and approval required on misses.

  • Before: The assignment contributes no blocking risk, so the trailing builtin can satisfy authorization.
  • After: The assignment produces a dynamic-assignment risk and requires approval.

Review scores

Measure Result What it means
Overall readiness 🦞 diamond lobster (5/6) A focused approval-boundary repair with supplied execution evidence, meaningful regressions, successful exact-head checks, and no actionable finding.
Proof confidence 🦞 diamond lobster (5/6) Sufficient (terminal): The exact-head node-host system.run terminal receipt exercises isolated synthetic policy: a literal assignment launches successfully, while recursive scalar, keyed, and keyed-append assignments are rejected before the runner with zero launches and no marker side effects; the gateway regression independently covers its pre-spawn consumer boundary.
Patch quality 🦞 diamond lobster (5/6) No actionable review findings were identified.

Product

Kind: Bug fix · Worth it: Yes · Fix scope: Complete
User problem: Executable allowlisting can silently permit additional shell evaluation hidden in a standalone assignment.
Reason: The change restores the established executable-trust boundary with no new configuration or public API, and the supplied maintainer-author direction accepts the narrower automatic execution behavior.

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
Reviewed head: befe832957da3f58ae0bb6a7eb7f8d925d94c532

Before merge

None.

Findings

None.

Agent review details

How this fits together

Shell 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]
Loading

Technical review

Best 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

  • Command explanation and shell-text decoding keeps the original intent (207aa18: The original explainer records command structure and risk facts; subsequent decoder refactors preserve argv and source spans.)
  • Authorization planning, risk mapping, and assignment preludes keeps the original intent (c9707ab: The planner rewrite made one parsed command model authoritative for allowlisting, persistence, and rewriting, with unrepresented evaluation approval-gated.)
  • File-budget metadata keeps the original intent (f81f9d8: The suppression ratchet allows its existing baseline to shrink; this PR removes stale suppressions and their records after extracting existing implementation.)
  • Advanced approval documentation keeps the original intent (0054818: The advanced guide documents which shell forms executable allowlisting can safely represent.)

Testing

Proof path: shipped entry point.

Security

None.

Evidence

What I checked:

  • Producer-side repair: The introduced predicate classifies standalone subscripted assignments, keyed compound-array entries, arithmetic expansions, and braced expansions while preserving command and declaration handling. (src/infra/command-explainer/extract.ts:339, befe832957da)
  • Existing authorization owner reused: The new risk joins the existing unanalyzable-risk set; ordinary shell plans fail closed without adding another approval mechanism. (src/infra/exec-authorization-risks.ts:18, befe832957da)
  • Gateway process boundary: The added regression runs a literal assignment through the real process supervisor and rejects scalar, keyed, and keyed-append recursive assignments before spawn; the body reports the relevant parent regressions failing because execution completed. (src/agents/bash-tools.exec-authorization.integration.test.ts:124, befe832957da)
  • Exact-head execution evidence: The PR body and fix(exec): require approval for recursive shell assignments #187499 (comment) supply an isolated node-host system.run receipt: the static control returns static-ok after one launch, while three recursive forms return approval-required errors with zero launches and no marker files. (befe832957da)
  • Earlier proof request reassessed: The earlier node request now has execution evidence, and the gateway has a production-owner pre-spawn regression. Additional wrapper, revocation, and upgrade runs are not required for this syntax-fact repair: wrapper fallback retains its existing bound-argument matching, launch revalidation remains unchanged, and no persisted authority or storage format is introduced. (src/infra/exec-approvals-allowlist.ts:481, befe832957da)
  • Current-main defect remains: Fetched main retains the original assignment omission and the non-append prelude matcher; the relevant parser and planner files have no changes between the merge base and fetched main. (src/infra/exec-authorization-plan.ts:301, 39b0e6ffaa2d)

Likely related people:

  • Jesse Merhi: Raw commit c9707ab adds src/infra/exec-authorization-plan.ts:685 relative to its recorded parents. This identifies author metadata, not feature responsibility or a PR merger. (role: source-line author; confidence: high; commits: c9707ab635b9; files: src/infra/exec-authorization-plan.ts)
  • Peter Steinberger: Raw commit 385f80a adds src/infra/command-explainer/extract.ts:812 relative to its recorded parents. This identifies author metadata, not feature responsibility or a PR merger. (role: source-line author; confidence: high; commits: 385f80ac5fc9; files: src/infra/command-explainer/extract.ts)
  • Vincent Koc: Raw commit 0d43a6a adds src/infra/command-explainer/extract.ts:515 relative to its recorded parents. This identifies author metadata, not feature responsibility or a PR merger. (role: source-line author; confidence: medium; commits: 0d43a6abb149; files: src/infra/command-explainer/extract.ts)

PR surface

Source +41, Tests +96, Docs +5, Other 0. Total +142 across 11 files. Added test files: 0.

View PR surface stats
Area Files Added Removed Net
Source 5 263 222 +41
Tests 3 96 0 +96
Docs 1 6 1 +5
Config 0 0 0 0
Generated 0 0 0 0
Other 2 2 2 0
Total 11 367 225 +142

Labels

Label changes:

No label changes.

Label justifications:

  • P1: Recursive shell evaluation can perform side effects beyond the executable trust granted by an allowlist.
  • merge-risk: 🚨 compatibility: Existing workflows using recursive or keyed standalone assignments intentionally require approval after this repair; that tradeoff is recorded and accepted.
  • merge-risk: 🚨 security-boundary: The changed syntax fact controls whether executable trust can authorize shell evaluation before process launch.
  • rating: 🦞 diamond lobster: Overall readiness is 🦞 diamond lobster; proof is 🦞 diamond lobster and patch quality is 🦞 diamond lobster.
  • status: 👀 ready for maintainer look: ClawSweeper has no concrete contributor-facing blocker left for this PR.
  • proof: sufficient: Contributor real behavior proof is sufficient.

Rating scale

6/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.

Workflow

ClawSweeper edits this one comment on every review. Comment @clawsweeper re-review for a fresh review only. Repair and merge execution lanes are retired.

History

Review history (1 earlier review cycle)
  • reviewed 2026-10-29T08:39:25.939Z sha da32076 :: needs real behavior proof before merge. :: none

Reviewed October 29, 2026, 8:30 AM ET / 12:30 UTC (Revision 2).

@openclaw-barnacle openclaw-barnacle Bot added the agents Agent runtime and tooling label Oct 29, 2026
@pgondhi987

pgondhi987 commented Oct 29, 2026 •

Copy link
Copy Markdown
Contributor Author

ClawSweeper review

Reviewed October 29, 2026, 10:33 AM UTC.

What this changes

The 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 readiness

Result: ready for maintainer review.

Overall: 🦞 diamond lobster
Proof: 🦞 diamond lobster
Patch quality: 🦞 diamond lobster

Reviewed head: befe832957da

Review scores

  • Overall: 🦞 diamond lobster
  • Proof: 🦞 diamond lobster (sufficient)
  • Patch quality: 🦞 diamond lobster
  • Security: cleared

Verification

Status: sufficient

How this fits together

Shell 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]
Loading

Before merge

  • None from local ClawSweeper.
Review details

Best 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 details

Label justifications:

  • P1: The defect can execute shell side effects across the exec approval boundary before an allowlisted command.
  • merge-risk: 🚨 compatibility: Existing automation using recursive standalone assignments will intentionally stop auto-running and require approval after merge.
  • merge-risk: 🚨 security-boundary: The syntax classification directly controls whether recursive shell evaluation can reach process launch without approval.
Evidence reviewed

PR surface:

Area Files Added Removed Net
Source 5 263 222 +41
Tests 3 96 0 +96
Docs 1 6 1 +5
Config 2 2 2 +0
Generated 0 0 0 +0
Other 0 0 0 +0
Total 11 367 225 +142
  • Recursive assignment classification: Standalone subscripted, keyed-array, arithmetic, and braced-expansion assignments produce the new dynamic-assignment risk at the syntax-fact owner.
  • Existing fail-closed policy reused: The new risk is part of the existing unanalyzable-risk set, and a blocking risk makes the authorization plan unsuccessful rather than introducing another policy path.
  • Process-boundary regression: The integration regression allows one literal assignment and rejects recursive scalar, keyed, and keyed-append assignments before the supervisor spawn boundary.
  • Exact-head final-effect proof: The PR body records node-host system.run launching the static control once and denying all three recursive forms with zero launches and no marker files on the reviewed head.
  • Authorization ownership history: The earlier planner rewrite made the Tree-sitter explanation authoritative for allowlist and approval decisions, so this patch repairs the missing fact at the intended producer.
  • Latest-head delta: Changes after the previous reviewed head only remove two stale max-lines baseline entries; the reviewed security behavior is unchanged.
  • Maintainer direction: The PR author has MEMBER association, so the stricter approval behavior is already an owner decision under the review policy.

@pgondhi987

Copy link
Copy Markdown
Contributor Author

Behavior proof for exact head befe832957da3f58ae0bb6a7eb7f8d925d94c532:

  • The shipped node-host system.run path allowed STATIC=value; /usr/bin/echo static-ok, launched one process, and returned static-ok.
  • Recursive scalar, keyed =, and keyed += assignment forms were each denied with SYSTEM_RUN_DENIED: approval required before the process runner; every case recorded zero process launches and no marker-file side effect.
  • The focused 12-file regression suite passed 292 tests with 3 optional-shell skips. Focused formatting, repository-supported focused lint, type checks, line-cap/test-line/max-lines ratchets, and git diff --check passed.
  • GitHub CI run 40857716789 completed successfully with zero failed jobs. The aggregate security workflow also completed successfully, and the final A-tier ClawSweeper review found no correctness or security concerns.

The terminal proof used synthetic configuration and isolated state; it did not modify a live Gateway, channel, or model session.

@pgondhi987

Copy link
Copy Markdown
Contributor Author

Verification before merge: exact head befe832957da3f58ae0bb6a7eb7f8d925d94c532 is fully converged.

  • Implementation and focused local validation passed at this pushed head.
  • Shipped node-host behavior proof passed: one static-assignment launch succeeded, while recursive scalar, keyed =, and keyed += forms were denied before process creation with no side effects.
  • Canonical local ClawSweeper rated the PR A/A/A with 0.97 confidence, no findings or structured risks, and a cleared security review.
  • GitHub CI run 40857716789 and the aggregate security workflow completed successfully with no failed or pending checks.
  • The exact-head conflict recorder reported MERGEABLE/BLOCKED; mergeability is clean and the remaining block was the delivery gate sequence.
  • Final deterministic dry-run and real delivery gates passed for this unchanged candidate.

The PR has not been merged.

@pgondhi987

Copy link
Copy Markdown
Contributor Author

@clawsweeper re-review

@clawsweeper

clawsweeper Bot commented Oct 29, 2026 •

Copy link
Copy Markdown
Contributor

🦞👀
Exact review queued.

Re-review progress:

@clawsweeper clawsweeper Bot added clawsweeper:intake:bug Preliminary submission classification; full source review pending. merge-risk: 🚨 compatibility 🚨 May break existing users, config, migrations, defaults, or upgrade paths. proof: sufficient ClawSweeper judged the real behavior proof convincing. and removed rating: 🧂 unranked krab Not merge-ready due to missing proof or serious correctness/safety concerns. status: 📣 needs proof The PR needs real behavior proof before ClawSweeper can clear the contributor ask. clawsweeper:intake:bug Preliminary submission classification; full source review pending. labels Oct 29, 2026
@clawsweeper clawsweeper Bot added rating: 🦞 diamond lobster Very strong PR readiness with only minor maintainer review expected. status: 👀 ready for maintainer look ClawSweeper has no concrete contributor-facing blocker left for this PR. labels Oct 29, 2026
@pgondhi987
pgondhi987 merged commit f980e01 into openclaw:main Oct 30, 2026
15 checks passed
github-actions Bot pushed a commit to Desicool/openclaw that referenced this pull request Oct 31, 2026
…#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
amittell pushed a commit to amittell/openclaw that referenced this pull request Nov 16, 2026
…#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)
amittell added a commit to amittell/openclaw that referenced this pull request Nov 16, 2026
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.
RomneyDa added a commit that referenced this pull request Nov 17, 2026
Backport #187499 with existing helper locations retained.

Co-authored-by: RomneyDa <[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 merge-risk: 🚨 compatibility 🚨 May break existing users, config, migrations, defaults, or upgrade paths. merge-risk: 🚨 security-boundary 🚨 May affect sandboxing, authorization, credentials, or sensitive data. P1 High-priority user-facing bug, regression, or broken workflow. proof: sufficient ClawSweeper judged the real behavior proof convincing. rating: 🦞 diamond lobster Very strong PR readiness with only minor maintainer review expected. size: L 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