Repository navigation
Harden Codex native execution in OpenClaw sandboxes - #84388
Conversation
|
Codex review: needs maintainer review before merge. Workflow note: Future ClawSweeper reviews update this same comment in place. How this review workflow works
Summary Reproducibility: yes. Current main source shows sandboxed Codex native execution is represented as a Codex PR rating Rank-up moves:
What the crustacean ranks mean
Shiny media proof means a screenshot, video, or linked artifact directly shows the changed behavior. Runtime, network, CSP, and security claims still need visible diagnostics. Real behavior proof Risk before merge
Maintainer options:
Next step before merge Security Review detailsBest possible solution: Land only after maintainer/security approval accepts the fail-closed default and experimental exec-server bridge scope, with exact-head checks green; keep full Codex app-server containment tracked separately if that remains required. Do we have a high-confidence way to reproduce the issue? Yes. Current main source shows sandboxed Codex native execution is represented as a Codex Is this the best way to solve the issue? Mostly yes. Failing closed by default with a deliberately experimental sandbox exec-server opt-in is a conservative repair path, but final merge depends on maintainer/security acceptance that full app-server containment can remain separate. Label justifications:
Acceptance criteria:
What I checked:
Likely related people:
Codex review notes: model gpt-5.5, reasoning high; reviewed against c2004fe6622d. |
c3001dd to
ba939b0
Compare
|
ClawSweeper PR egg ✨ Hatched: 🥚 common Velvet Branchling Hatch commandComment Hatchability rules:
Rarity: 🥚 common. What is this egg doing here?
|
ba939b0 to
444e396
Compare
444e396 to
9a6ce31
Compare
|
This PR only addresses the This does not address all the issues of running the orchestrator/harness OUTSIDE of the agent sandbox as per #83796. The codex process, if running on the gateway host/container, still doesn't inherit the env, resource quotas, security caps, network and filesystem of the sandbox container. |
9a6ce31 to
926e38d
Compare
|
Checked against ../codex and found two blockers to fix here:
I'll push fixups for both and rerun focused checks. |
|
Found 1 test failure on Blacksmith runners: Failure
|
|
Fixups pushed:
Verification run locally:
CI on |
3a47492 to
185df49
Compare
|
I pushed a cleanup commit that keeps the sandbox bridge behavior intact but splits the large files into focused modules:
I also checked whether this could be smaller by outsourcing more. Proof:
Thanks @joshavant. |
|
Landed via squash merge on
Thanks @joshavant. |
Summary
/codexcommand execution are blocked instead of bypassing the OpenClaw sandbox contract.sandbox_exec/sandbox_processdynamic tools by default.appServer.experimental.sandboxExecServeras an explicit opt-in for operators who want Codex-native execution routed through the OpenClaw sandbox-backed exec-server integration.Fixes #83796
Verification
$autoreviewfinal pass viacodex --dangerously-bypass-approvals-and-sandbox --sandbox danger-full-access review --base origin/main: no findings.node scripts/run-vitest.mjs extensions/codex/src/app-server/sandbox-exec-server.test.ts extensions/codex/src/app-server/config.test.ts extensions/codex/src/app-server/request.test.ts extensions/codex/src/app-server/thread-lifecycle.test.ts extensions/codex/src/app-server/run-attempt.test.ts extensions/codex/src/commands.test.ts— 408 tests passed.node scripts/run-tsgo.mjs -p tsconfig.extensions.json --incremental --tsBuildInfoFile .artifacts/tsgo-cache/extensions.tsbuildinfonode scripts/run-tsgo.mjs -p test/tsconfig/tsconfig.extensions.test.json --incremental --tsBuildInfoFile .artifacts/tsgo-cache/extensions-test.tsbuildinfopnpm plugin-sdk:api:checkgit diff --checkaws, runrun_c7c6c0fe083c, leasecbx_c702c397b8b1; 222 tests passed forextensions/codex/src/app-server/run-attempt.test.tsandextensions/codex/src/app-server/sandbox-exec-server.test.ts.aws, runrun_fb6b5f5ce13d, leasecbx_9a4f664dca8e, exit 0.appServer.experimental.sandboxExecServeroff blocked/codex bind, completed a normal sandboxed turn returningOC84388_DEFAULT_OK, and did not logcodex sandbox exec-server started.appServer.experimental.sandboxExecServer: trueloggedcodex sandbox exec-server started, used Docker runtimeopenclaw-sbx-agent-dev-manual-exec-server-fb6dfa64, returnedOC84388_EXECSERVER_OK, and wrote the same token to/private/tmp/openclaw-84388-manual/exec-server/workspace/manual-exec-server-proof.txt.Exec-Server Audit Coverage
0.132.0+).environment/addregistration, with remote app-server rejection and numeric loopback validation.externalSandboxpolicy projection.turn/startfailure, context-engine retry setup failure, startup timeout, shared refcounts, and unauthorized socket rejection.Real behavior proof
Behavior addressed: Codex-native execution no longer escapes an active OpenClaw sandbox by default; the only native Codex execution path under an active sandbox is the explicit
appServer.experimental.sandboxExecServer: trueopt-in, which routes execution through the sandbox-backed exec-server contract.Real environment tested: AWS Crabbox Linux host with Docker sandbox image
openclaw-sandbox:bookworm-slim, real Codex model turn usingcodex/gpt-5.5, provideraws, runrun_fb6b5f5ce13d, leasecbx_9a4f664dca8e. Local macOS manual TUI sanity checks also exercised the user-facing Gateway/TUI flow with Docker sandbox containers.Exact steps or command run after this patch: Installed dependencies, built the sandbox image, started a foreground Gateway from the source checkout, and ran two live Gateway agent turns with
agents.defaults.sandbox.mode=all: one default fail-closed turn withoutappServer.experimental.sandboxExecServer, and one opt-in turn withappServer.experimental.sandboxExecServer: true. The local manual sanity pass repeated the same two scenarios through the user-facingopenclaw tuiflow rather than a harness script.Evidence after fix: In the default fail-closed scenario, the live model used OpenClaw
sandbox_exec; the proof capturedsandboxExecStart: trueandsandboxExecResult: true. In the exec-server opt-in scenario, the live model used Codex-native shell execution, the sandbox exec-server started, the command wrote/workspace/exec-server-proof.txt, and the proof capturedusedSandboxExec: falsewith the expected token in the proof file. In the local manual pass,/codex bindwas blocked under the active sandbox, the default normal turn returnedOC84388_DEFAULT_OK, the exec-server turn returnedOC84388_EXECSERVER_OK, Gateway loggedcodex sandbox exec-server started, and the mounted workspace proof file containedOC84388_EXECSERVER_OK.Observed result after fix: Both live AWS scenarios and both local manual TUI scenarios completed successfully. Default sandboxed Codex turns stayed inside OpenClaw-owned sandbox tools, while the feature-flagged Codex-native shell path wrote only through the sandbox-backed exec-server surface.
What was not tested: The feature-flagged exec-server path remains intentionally non-default because Codex exposes this app-server behavior behind an experimental flag in
@openai/[email protected]; production default behavior is the conservative fail-closed path.