Repository navigation
fix(cron): capture Codex shell aliases under canonical tool identity with a restrict-only exec pin - #130579
Conversation
|
🦞👀 Pull request received. I will update this pull request when review starts. |
379f68d to
571e62c
Compare
|
Codex review: needs maintainer review before merge. Reviewed August 28, 2026, 3:42 PM ET / 19:42 UTC. ClawSweeper reviewWhat this changesThe PR translates Codex Gateway shell aliases to canonical cron tool names and persists a Gateway-only exec restriction that is restored only for a valid scheduled job. Regression provenancePossible regression — probable (reviewed change; failure trace). No predecessor PR is attributed. Merge readinessKeep open for human security-boundary review. The checked code fixes the capture-time alias mismatch and fails closed when the persisted exec restriction is damaged, but this maintainer-labeled PR adds durable execution-policy state and the required local Codex checkout was unavailable for an independent protocol audit. Priority: P1 Review scores
Verification
How this fits togetherCodex-backed turns capture the tools available when creating a cron job, while later trigger and isolated-agent runs rebuild core tools from that saved policy. The change maps a host-issued alias to canonical flowchart LR
A[Codex creator turn] --> B[Gateway shell alias]
B --> C[Canonical cron capture]
C --> D[Stored cron job]
D --> E[Restriction validation]
E --> F[Rebuilt exec tool]
F --> G[Gateway command execution]
Decision needed
Why: This changes how a scheduled job regains shell capability after persistence, so the remaining question is a security policy decision rather than a mechanical code correction. Before merge
Findings
Agent review detailsSecurityNeeds attention: The code has concrete fail-closed checks, but durable scheduled shell authority and the unavailable direct Codex protocol audit require security-owner review before merge. PR surfaceSource +888, Tests +886, Other -1. Total +1773 across 58 files. View PR surface stats
Review metrics
Stored data modelPersistent data-model change detected: Merge-risk optionsMaintainer options:
Technical reviewBest possible solution: Retain capture-time canonicalization and the single restrictive exec wrapper, but merge only after a security owner accepts the persisted-pin and legacy-alias reauthorization policy with the Codex protocol premise independently checked. Do we have a high-confidence way to reproduce the issue? Yes, at source level: current main captures the Codex-facing alias name, while scheduled execution rebuilds canonical core tools; the PR adds capture-time translation and focused trigger coverage. The cited live proof was not rerun in this read-only environment. Is this the best way to solve the issue? Unclear: capture-time canonicalization is the right owner boundary and the implementation consistently applies the restrictive target, but the durable authority representation and external Codex protocol premise still require security-owner acceptance. AGENTS.md: found and applied where relevant. Codex review notes: model internal, reasoning high; reviewed against 4395a0cc3e6a. LabelsLabel justifications:
EvidenceSecurity concerns:
What I checked:
Likely related people:
Rank-up movesOptional improvements that raise the rating; they are not merge blockers.
Rating scale
Overall follows the weaker of proof and patch quality. Workflow
HistoryReview history (9 earlier review cycles; latest 8 shown)
|
|
Known sibling, intentionally out of scope: the same capture invariant is still violated for CLI-backend (bundled-MCP/loopback) creator sessions, where a requested finite |
|
Exact-head live proof and direct Codex contract audit are complete. Managed Gateway proofThe active OCM-managed Gateway was bound to installed runtime A fresh Codex-created canary (
The naturally due run completed at A later WebChat ACK experiment is deliberately excluded from this proof: its Direct Codex 0.149.1 contract auditI inspected sibling
This closes the two ClawSweeper rank-up requests for exact-head managed-Gateway behavior and the pinned Codex protocol premise. It is targeted real-behavior proof for canonical creator capture plus natural trigger execution; it does not replace review of the broader persistence/continuation/security-boundary tests already listed in the PR body. |
|
Natural-run proof on exact PR head
This is targeted real-behavior proof for canonical Codex capture plus scheduled trigger reconstruction. It does not claim coverage of unrelated WebChat delivery: a separate ACK experiment reached Direct pinned-Codex audit: tag |
571e62c to
a186669
Compare
e91faf5 to
2ec4233
Compare
Exact-head fail-closed security follow-upExact head: The security follow-up is now implemented at the cron policy owner boundary:
Direct Codex contract inspectionThe supported dependency is
That confirms the producer binding must remain the pre-protocol OpenClaw object-identity check. Persisted reconstruction must rely on the server-authored target/requirement pair and fail closed when it is incomplete; a name-only Exact-head proofThe new tests protect observable security behavior: damaged required pins cause no trigger/script/agent invocation or filesystem effect; storage cannot persist or restore broad Exact-head CI run 33202265563 completed successfully, including The retained product decision is explicit: historical literal alias jobs are not automatically granted canonical shell authority; operators recreate or explicitly reauthorize them. The requested |
|
@openclaw/openclaw-secops Final owner decision requested before landing. Please approve or reply accepting these security-boundary choices:
Pinned Codex 0.150.1 was directly checked: its dynamic-tool protocol carries name/namespace/schema/arguments and correlation, but no trustworthy OpenClaw producer identity or approval floor. Exact head 1e5dbcd is mergeable, openclaw/ci-gate is green, the real-Gateway deny/no-side-effect plus independent allow-once proof is recorded above, and fresh whole-branch autoreview is clean. |
…with a restrict-only exec pin (openclaw#130579) * oc-18a,oc-e8d,oc-592,oc-660: canonical cron capture for scheduled tool aliases + restrict-only exec pin Co-Authored-By: Claude Fable 5 <[email protected]> * oc-db4: create Codex gateway shell aliases through the host-owned projection factory Co-Authored-By: Claude Fable 5 <[email protected]> * oc-729: regression coverage for canonical capture, pin persistence, and enforcement Co-Authored-By: Claude Fable 5 <[email protected]> * oc-729: consolidate cap-authority reconciliation into one seam; gate fixes Co-Authored-By: Claude Fable 5 <[email protected]> * oc-f0f: pin whole exec lifecycle, cover continuation path, harden context re-resolution Autoreview findings: continuation slot now carries the restrict-only pin; pinExecToolTarget pins preparation/finalize/execute; trusted contexts with execTarget survive re-resolution. Co-Authored-By: Claude Fable 5 <[email protected]> * oc-979: read scheduled tool projections through a structural key The creator-cap capture iterates tools typed only as { name: string }, and reaching the projection registry required a chained `as unknown as` assertion that the boundary-guard lint rejects. Key the registry WeakMap by plain object identity and give the reader a structural parameter covering exactly what it checks (name plus executable identity), so the caller passes its tools directly. Tamper checks are unchanged. Co-Authored-By: Claude Fable 5 <[email protected]> * fix(cron): preserve scheduled exec approval floor * fix(cron): preserve scheduled approval above session mode * test(ui): restore mock gateway event types * test(agents): split scheduled projection coverage * fix(cron): fail closed on lost exec pins --------- Co-authored-by: Claude Fable 5 <[email protected]>
Supersedes #126496. Related: #92238.
What Problem This Solves
Cron trigger scripts created from a Codex-backed turn fail with
Unknown tool id: execwhen they use the documentedexec(...)contract. Codex sessions present OpenClaw'sexecas a runtime-specific dynamic tool namedgateway_exec; creator capture recorded that presentation name into the persistedtoolsAllowcap, and the headless trigger runtime — which rebuilds canonical core tools — could not resolve it.Why This Change Was Made
The violated invariant: the core-owned
toolsAllowcap must be recorded in core's canonical tool vocabulary, not a runtime's presentation names. #126496 compensated downstream — persisting the alias name plus a sealed sidecar binding that authorized a trigger-timegateway_exec→execprojection — and the granting nature of that persisted artifact forced SHA-256 seals, downgrade recovery, and a schema change.This PR fixes the capture instead:
exec/processtool objects it constructs; a host-private,ownerPluginId-gated factory is the only way to mint a Codex gateway alias from those exact objects. Capture consults the registry and records the alias under its canonical name. A foreign tool merely namedgateway_exechas no registry entry, captures literally, and stays fail-closed. Nothing about the registry is persisted.execgrant position. Storage removesexecfrom the generic persisted cap and restores it only when the requirement and target validate; missing, malformed, or mismatched state stays without broadexecand fails before trigger, script, or agent execution. Detached-media continuation copies and revalidates the same requirement. Legacy unmarked jobs retain their existing baseline policy. No SQLite schema change.createOpenClawCodingToolspins the rebuilt exec tool (host default, argument rewrite, schema stripping, and the before-tool-call preparation/finalization lifecycle) when the scheduled context carries the pin — covering trigger scripts, script payloads, non-Codex isolated agent turns, and the cron run continuation path. Codex-runtime payload runs already rebuild pinned aliases via the landed scheduled-app-authority round trip.node_exec) and sandbox aliases stay unmapped (fail closed), matching fix(cron): preserve Codex trigger exec authority #126496's scoping. Existing jobs with persistedgateway_execcaps are not migrated (explicit maintainer decision): recreate them from a creator turn.User Impact
Automations created from a Codex-backed session can call
exec(...)in trigger and script payloads without wideningtoolsAllow. The persisted cap is the ordinary canonical shape (toolsAllow: ["exec", ...]), inspectable with standard tooling. The command stays pinned to the Gateway even when cron's configured default exec host differs, and the pin survives detached-media run continuations. Same-name non-Codex tools, literal alias-name caps, and node/sandbox aliases fail closed.Evidence
Current exact-head follow-up: rebased onto
869cf47b8dafe7c372a788c615ee7e7acc5bd85d; exact headddef1ff060da565f589291cdb623dc90bb6887e8. Full build, 6 focused Vitest shards / 195 tests, everycheck-changedlane, and fresh whole-branch autoreview passed. ClawSweeper dispositions, exact-head real-Gateway deny/no-side-effect plus allow-once proof, direct Codex contract links, managed scheduler evidence, and cleanup are recorded in the durable proof comment. Exact-head CI is attached as run 33183670282.Original validation on head
713294f66ab(approval-floor repair plus the existing canonical-capture change):pnpm check:changedover the full changed set passes every lane (format, ratchets, dead-export scan, core/extension typechecks, core/extension lint, import cycles, plugin boundaries, SDK surface budget).dynamic-tool-buildsuite (90 tests exercising the production host-capability + projection-factory path).gateway_execcaptured literally; trigger errorsexec is not definedwith no filesystem effect); pin persistence round-trip with tolerant normalization (foreign shapes dropped, future extra keys tolerated); pin enforcement across schema/arguments/preparation lifecycle; continuation-slot round-trip; trusted-context re-resolution.ask: "always". A real Gateway E2E starts fromtools.exec.ask: "off"; denial prevents the marker side effect, while a separate allow-once request completes.exec(...)gateway-pinned while the configured default exec host is a nonexistent node, proving the pin (not config luck) carries execution; the same script with a literalgateway_execcap fails closed.Managed-Gateway proof was later completed on packaged substantive head
713294f66ab(patch-equivalent to the previous PR head except a lint-only refactor): guarded canonical capture persistedask: "always", its natural trigger was denied with no marker effect, an unguarded comparison succeeded, trigger updates retained the floor, and a separate five-minute one-shot visibly delivered into WebChat. It is explicitly not exact-current-head proof. The ClawSweeper persistent-full-session repair is covered on exact current head by a real-Gateway deny/no-side-effect plus allow-once E2E; full evidence and cleanup are in the follow-up comment. The earlier canonical-capture run was:openai/gpt-5.6-luna,agentRuntime: { id: "codex" }) called the automations tool once to add a trigger job withouttoolsAllow.cron_jobs.job_json):toolsAllowcontains canonicalexecandprocess(plusnode_execcaptured literally, unmapped by design),toolsAllowIsDefault: true,toolsAllowExecTarget: { version: 1, host: "gateway" },toolsAllowProvenance: { source: "final-executable-surface", ... }, account-modescheduledToolPolicy— nogateway_execanywhere.execwrote the allowed marker file.toolsAllow: ["gateway_exec"]and the same trigger script recordedcron trigger evaluation failed (internal_error): ReferenceError: exec is not definedin run history, and the forbidden marker check returned ENOENT — stopped before any filesystem I/O.Direct Codex contract inspection used the exact pinned
@openai/codex0.150.1 source (sibling../codexcheckout, tagrust-v0.150.1, commit90854393966b21e9ebfd21b122334eb09a20c93d), personally inspected by the acting agent:codex-rs/protocol/src/dynamic_tools.rs—DynamicToolFunctionSpeccarries name/description/input_schema/defer_loading;DynamicToolCallRequestcarries call_id/turn_id/started_at_ms/namespace/tool/arguments. No producer identity crosses the protocol, which is why producer identity lives in OpenClaw's object-identity registry rather than anything round-tripped through Codex.codex-rs/app-server/src/request_processors/thread_processor.rs:326-411—validate_dynamic_toolsrejects empty/whitespace/reserved names, duplicate names per namespace, and duplicate namespaces, so a colliding registration cannot shadow the harness alias within a namespace.codex-rs/core/src/tools/handlers/dynamic.rs— dispatch reconstructsToolNamefrom namespace+name and round-trips arguments only.Follow-up uncommitted-diff autoreview on the approval-floor repair (Codex
gpt-5.6-sol) was clean at 0.98 confidence with no accepted/actionable findings. Earlier branch autoreview (Codexgpt-5.5,--mode branch --base origin/main): final run clean — "no actionable defects; the patch consistently carries the captured Gateway exec target from the Codex host projection through cron creation, persistence, and scheduled runtime reconstruction" (0.83). Three earlier accepted findings were fixed with regression tests (continuation-path pin propagation, whole-lifecycle pinning including exec preparation, trusted-context re-resolution); one finding (alias identity loss via bridge re-wrap) was rejected with direct evidence — the spread-carried symbol wrap marker makes the bridge skip re-wrapping (extensions/codex/src/app-server/dynamic-tools.ts:1075), confirmed by the live managed run.Current production LOC: net +595 (+814/−219); tests/tooling net +648 (+896/−248). The growth funds the host-identity alias issuance, canonical capture, restrict-only pin across persistence/continuation, and lifecycle-complete enforcement; the follow-up approval-floor repair itself is one non-bypassable owner-boundary expression.
This PR is AI-assisted. I reviewed the implementation and validation results and understand the change.