Skip to content

Send node_repl the disabled sandbox state on every runtime call (CUA_SHIM_SANDBOX) - #22

Merged
SSFSKIM merged 2 commits into
mainfrom
feat/sandbox-meta
Oct 5, 2026
Merged

SSFSKIM merged 2 commits into
mainfrom
feat/sandbox-meta

Conversation

@SSFSKIM

@SSFSKIM SSFSKIM commented Oct 5, 2026 •

Copy link
Copy Markdown
Owner

What

cua serve now sends node_repl's per-call sandbox state, _meta["codex/sandbox-state-meta"], on every call it makes to the runtime: js, js_reset and the private turn_ended. The bounded listing launch behind cua profiles list/bind and profiles_list sends it too. That launch does go through a node_repl tools/call (js with the liveness/list cell).

  • New setting CUA_SHIM_SANDBOX (parsed in settingsFrom; the listing launch reads the same variable):
    • disabled (default) sends {"permissionProfile":{"type":"disabled"},"sandboxCwd":"<file URI of the launch's working directory>"}.
    • default sends nothing (the previous behaviour).
    • Anything else fails as invalid_setting.
  • A client's own _meta["codex/sandbox-state-meta"] never reaches the runtime. It is replaced under disabled and dropped under default.
  • Shared logic is in src/runtime/sandbox.mjs.
  • README: a configuration row, a paragraph on what the default means, and corrected statements about the vendor profile label.
  • Spec: a Decision Log entry (2026-10-05, issue cua serve sends no sandbox metadata, so node_repl denies all writes (temp dirs included): decide the sandbox profile #20) with the owner's decision and the rejected alternatives, plus one sentence in the MCP/task lifecycle section.

Deviation from the ticket's literal payload

node_repl rejects {"permissionProfile":{"type":"disabled"}} on its own: -32602 js: codex/sandbox-state-meta: missing field 'sandboxCwd'. It requires an absolute file: URI there. Spike #8's working payload also carried sandboxCwd. cua therefore sends the launch's own working directory as a URI (pathToFileURL, percent-encoded; accepted live). useLegacyLandlock has a default and is omitted.

Measured beyond the decision's wording

The disabled profile also lifts node_repl's network denial:

no sandbox state disabled
TCP connect EPERM attempted (timed out on this Mac)
DNS ENOTFOUND attempted (timed out on this Mac)

Reachability was not established. This is recorded in the README and the Decision Log.

Tests (written first)

  • test/mcp-sandbox.test.mjs covers:
    • setting parsing: default, default, rejected values;
    • the state's shape, with an encoded file URI;
    • js/js_reset/turn_ended carry the state, and carry nothing under default;
    • a client's own sandbox entry is overridden or dropped, and its other _meta is kept.
  • test/profiles-inventory.test.mjs: the listing cell carries the given state, or none.
  • test/serve-cli.test.mjs, end to end through bin/cua.mjs serve with the fake runtime:
    • the default sends the state with sandboxCwd equal to the session directory on js and turn_ended;
    • each profiles_list listing launch sends it for its own directory;
    • CUA_SHIM_SANDBOX=default sends none on js/js_reset/turn_ended;
    • an invalid value fails classified before any launch;
    • cua profiles list (plain and --json) and bind exit nonzero with invalid_setting on an invalid value, before any listing launch.
  • npm test: 414/414 pass.

Review

doperpowers:reviewer-medium returned one P2 finding and found no P0 or P1 issues. The finding: cua profiles list validated CUA_SHIM_SANDBOX inside the listing callback. profileReadiness folds a failure there into listingError, so an invalid value produced ok: true. Fixed in 88ba2bc: the CLI now validates the setting for list and bind first. A regression test covers it.

Live results (this Mac, default CUA_HOME, read-only, nothing bound or picked)

  • node bin/cua.mjs profiles list --json from the worktree reported personal and school ready and work with extension_not_installed, the same as before.
  • Labels: the same listLiveBackends call profiles list makes, printing only whether a label was present (never the label itself):
    • default: all 3 live Chrome backends labelled;
    • CUA_SHIM_SANDBOX=default: none labelled.
    • Teardown was confirmed, no elicitations came up, and no codex* temp leftovers were found.
  • CUA_SHIM_SURFACES=computer node verify.mjs: green (problems: [], task ended, repeat end a no-op, next task differs, exit 0).
  • Write through cua serve: a driver ran one connection with a cell that writes a file in os.tmpdir() and reads it back, then js_reset, end_task and EOF. No app was bound and no elicitations came up.
    • default: WRITE ok. js_reset ok, end_task ended, serve exit 0. The temp file was removed.
    • CUA_SHIM_SANDBOX=default: WRITE failed: EPERM. js_reset ok, end_task ended, serve exit 0.

Not covered

Milestone probe scripts under scripts/probe* and scripts/probe/chrome/ launch the runtime directly and still send no sandbox state. They are historical spikes, not product launches. Downloads (the issue's suggested second check) were not exercised.

Closes #20

…SHIM_SANDBOX)

cua serve now attaches _meta["codex/sandbox-state-meta"] = {permissionProfile: {type: disabled}, sandboxCwd: <file
URI of the launch directory>} to js, js_reset and the private turn_ended, and the bounded listing launch behind
cua profiles list/bind and profiles_list sends the same. A client's own entry under that key is replaced or dropped.
CUA_SHIM_SANDBOX=default sends nothing (node_repl's write-denying default). node_repl rejects the field without
sandboxCwd, so it is always sent with the launch's working directory.

README configuration row and paragraph; spec Decision Log entry with the owner's decision and live results.
…diness

Review finding: the setting was validated inside the listing callback, which profileReadiness folds into a
listingError, so profiles list reported ok with an invalid setting. The CLI now validates it for list and bind first.
@SSFSKIM
SSFSKIM merged commit 858c75d into main Oct 5, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

cua serve sends no sandbox metadata, so node_repl denies all writes (temp dirs included): decide the sandbox profile

1 participant