Skip to content

Spike: does the vendor sandbox schema offer a writable-roots profile that keeps cua's trusted code roots read-only? #33

Closed

Description

@SSFSKIM

Question

Does node_repl's codex/sandbox-state-meta permissionProfile schema offer a profile that permits writes only under chosen roots (e.g. temp directories and cua's run directory) while keeping cua's trusted code roots read-only? If so, cua could default to it instead of disabled and keep the "cells cannot plant trusted code" guarantee without losing the vendor's temp-directory features (#8, #20).

Method

Static: read node_repl / the vendor runtime's handling of codex/sandbox-state-meta in the installed release (~/Library/Application Support/cua/runtimes/26.928.40906-darwin-arm64/, cua_node/bin/node_repl is a binary; the JS side and the readable source ~/codex-app-src/readable/chatgpt-26.928.40906/ if present) for the accepted permissionProfile.type values and their fields (Codex-style policies such as read-only / workspace-write with writable roots / network flags are the likely shape). Live, read-only: for each candidate profile, one cua serve connection with a cell that writes to a temp file, to a path under a declared writable root, and to a path under src/secrets (a scratch CUA_HOME copy, never the real one), recording which succeed; plus one network attempt. Nothing persistent; no app bound.

Deliverable

Findings comment: the schema, a recommended default profile (or "none fits"), and the exact payload. If a fit exists, a follow-up enhancement to switch the default and update #20's decision.

Activity

  1. added
    status:ready-for-implementer
    priority:P2
    spike
    status:in-progress
    and removed
    status:ready-for-implementer
    on Oct 5, 2026
  2. SSFSKIM commented on Oct 5, 2026

    @SSFSKIM
    OwnerAuthor

    [board] in-progress: Spike started: static read of node_repl's sandbox-state-meta permissionProfile schema, then a live matrix from a worktree at /tmp/cua-33 (spike/sandbox-schema) with an experimental CUA_SHIM_SANDBOX_JSON escape hatch.

  3. SSFSKIM commented on Oct 5, 2026

    @SSFSKIM
    OwnerAuthor

    Spike #33 findings: yes, one profile fits. It keeps the trusted roots read-only, and it costs the kernel its network access.

    The fit. A managed profile with a restricted file system gives:

    • read access everywhere;
    • writes only under $TMPDIR (which is nodeRepl.tmpDir), cua's run directory (project_roots, i.e. sandboxCwd) and any explicitly listed path;
    • a refused write (EPERM) to src/secrets and src/services.

    The vendor's profile labels work under it (2 of 2 live Chrome backends labelled), and verify.mjs passes.

    The cost. Under any managed profile, node_repl 26.928.40906 denies every network connection from the kernel. That includes "network":"enabled", which is parsed and then not honoured. Only disabled opens the network. So the default moves from disabled only if the owner accepts that cells and trusted services lose network access.

    A built-in guard I did not expect. Under a managed profile, node_repl refuses to start a kernel when any trusted code path is writable, and fails closed:
    node_repl kernel unhandled rejection: Trusted RPC dependency must resolve within a configured trusted code path: …
    "Cells cannot plant trusted code" is therefore enforced by node_repl itself, not only by how cua picks the roots.

    Schema (what node_repl accepts under _meta["codex/sandbox-state-meta"])

    node_repl is closed source. Its accepted shape comes from the binary cua_node/bin/node_repl (26.928.40906, sha256 aa594b78af268218…). The citations below are byte offsets from strings -t d. The same types, with their documentation, are open source in openai/codex at the pinned codex-cli 0.159.2 (tag rust-v0.159.2).

    • SandboxState: {permissionProfile, sandboxCwd, useLegacyLandlock} (node_repl @9917572).
      • sandboxCwd must be an absolute file: URI (node_repl @9917324, @10840581).
      • Codex's own struct also has codexLinuxSandboxExe (codex-rs/codex-mcp/src/runtime.rs:785-793). node_repl does not name that field.
    • PermissionProfile, tagged by type (codex-rs/protocol/src/models.rs:418-436; node_repl @9917884, @9918064 managed|disabled|external):
      • {"type":"managed","file_system":ManagedFileSystemPermissions,"network":NetworkSandboxPolicy}
      • {"type":"disabled"}
      • {"type":"external","network":…}
    • ManagedFileSystemPermissions, tagged by type (models.rs:296-314):
      • {"type":"restricted","entries":[FileSystemSandboxEntry…],"glob_scan_max_depth"?}
      • {"type":"unrestricted"}
    • FileSystemSandboxEntry: {path, access} (node_repl @9907630: "struct FileSystemSandboxEntry with 2 elements"). The missing_path_behavior field from 0.159.2 (permissions.rs:186-198) is not in this node_repl.
    • access: read | write | deny, with none accepted as an alias of deny (permissions.rs:120-128).
      • Codex documents the precedence: the more specific path wins; between equally specific entries, deny beats write, which beats read.
    • FileSystemPath, tagged by type (permissions.rs:463-483):
      • {"type":"path","path":"/abs"}
      • {"type":"glob_pattern","pattern":…} (deny only)
      • {"type":"special","value":{"kind":…}}
      • node_repl also knows generated_default_path and generated_default_special (@9918064). They are not in 0.159.2's public types, and I did not test them.
    • FileSystemSpecialPath, tagged by kind (permissions.rs:141-166): root, minimal, project_roots (with an optional subpath; it resolves against sandboxCwd), tmpdir, slash_tmp, unknown.
    • network: "restricted" or "enabled" (permissions.rs:86-90). "bogus" gets -32602 … unknown variant 'bogus', expected 'restricted' or 'enabled'. A path tagged with kind instead of type gets -32602 … missing field 'type'.
    • The legacy SandboxPolicy vocabulary is not accepted. writableRoots, workspace-write, danger-full-access and networkAccess have 0 hits in the binary.
    • Codex's own workspace-write profile is entries root:read, project_roots:write, slash_tmp:write, tmpdir:write and the writable roots, plus read-only .git/.codex/.agents/.aws under the project roots (permissions.rs:819-874).
    • The readable desktop source has no node_repl schema; the app-server sends this metadata from Rust. The desktop does use the profile ids :read-only, :workspace and :danger-full-access (readable/chatgpt-26.928.40906/main-process/src-ghAWefM3.js:1302-1326).

    Measured matrix

    Setup on this Mac:

    • One cua serve connection per payload, run from a throwaway worktree /tmp/cua-33 (realpath /private/tmp/cua-33) with CUA_HOME at its default.
    • The payload was sent through an experimental CUA_SHIM_SANDBOX_JSON escape hatch on branch spike/sandbox-schema (b4d92ff, not for main; driver scripts/probe/sandbox-schema.mjs).
    • One JS cell wrote and then removed a file at each target and tried a TCP connect to a port the driver listened on. Elicitations were declined (none came up), and every connection ended with end_task and EOF.
    • $TMPDIR = os.tmpdir() = nodeRepl.tmpDir = /var/folders/…/T. The run directory is ~/Library/Application Support/cua/run/<session>.

    Column key:

    • tmpdir = $TMPDIR
    • /tmp = /private/tmp
    • declared = the declared root /tmp/cua33-wr
    • secrets / services = the worktree's src/secrets and src/services (cua's trusted code roots)
    • run dir = cua's run directory
    • home = ~
    • net = loopback connect / 1.1.1.1:443 connect / DNS lookup
    payload (permissionProfile) tmpdir /tmp declared secrets services run dir home net
    none (CUA_SHIM_SANDBOX=default) EPERM EPERM EPERM EPERM EPERM EPERM EPERM EPERM / – / ENOTFOUND
    disabled (today's default) ok ok ok ok ok ok ok connected / connected / ok
    M1 managed restricted [root:read, project_roots:write, tmpdir:write, path /tmp/cua33-wr:write], network restricted ok EPERM ok EPERM EPERM ok EPERM EPERM / EPERM / ENOTFOUND
    M4 = M1 with network enabled ok EPERM ok EPERM EPERM ok EPERM EPERM / EPERM / ENOTFOUND
    managed unrestricted, network restricted ok ok ok ok ok ok ok EPERM / – / ENOTFOUND
    managed unrestricted, network enabled ok ok ok ok ok ok ok EPERM / EPERM / ENOTFOUND
    external, network restricted or enabled EPERM EPERM EPERM EPERM EPERM EPERM EPERM EPERM / EPERM / ENOTFOUND (the same as none)

    The trusted code is readable under every payload (src/secrets: 6 entries).

    When a write root covers a trusted root, the kernel refuses to start. The js call returns isError: "node_repl kernel exited unexpectedly". The refusal names the file:

    payload refused at
    M1 + slash_tmp:write file:///private/tmp/cua-33/src/services/sky.mjs
    M1 + path /private/tmp/cua-33:write …/src/services/sky.mjs
    M1 + path /private/tmp/cua-33/src/secrets:write ../secrets/reference.mjs
    M1 + slash_tmp:write + read carve-outs at /tmp/cua-33/src/{services,secrets} (not realpaths) sky.mjs
    the same with the carve-outs at the /private/tmp/… realpaths, in either order sky.mjs loads, then ../secrets/reference.mjs is refused
    the same with one read carve-out at /private/tmp/cua-33/src ../secrets/reference.mjs

    So a read carve-out inside a write root does not reliably restore trust. A profile has to keep the trusted roots outside every write root.

    Beyond the cell.

    • The readiness listing (listLiveBackends, tabCounts:false) labelled 0 of 2 live Chrome backends with no state, 2 of 2 under M1 and 2 of 2 under disabled. Teardown was confirmed and no elicitations came up.
    • node verify.mjs under M1 passed in all three runs: computer with secrets off, computer,browser with secrets off (profiles_list ok), and computer with secrets on (broker present, secrets_list ok, native helper reached through nativePipe).
    • Nothing was left behind: no leftover files at any target, and cua/run/ was empty before and after.

    Recommendation

    The default payload I recommend, called scoped here:

    {"permissionProfile":{"type":"managed","file_system":{"type":"restricted","entries":[
      {"path":{"type":"special","value":{"kind":"root"}},"access":"read"},
      {"path":{"type":"special","value":{"kind":"project_roots"}},"access":"write"},
      {"path":{"type":"special","value":{"kind":"tmpdir"}},"access":"write"}]},
     "network":"restricted"},
     "sandboxCwd":"<file URI of run/<session>>"}

    Why this shape:

    • Writes go to the run directory and $TMPDIR only. That is a strict superset of the old write-denying default, and it covers the vendor's scratch-space path (nodeRepl.tmpDir).
    • slash_tmp is deliberately left out. With it, the guard would refuse any checkout or runtime under /tmp. accept-native's documented mktemp -d /tmp/cua-accept.XXXXXX home is one such case, and so is this spike's worktree.
    • The network setting is honest. Network is denied whatever the field says, so it says restricted.

    What it costs compared with disabled:

    • cells cannot write ~, ~/Downloads or /tmp;
    • cells cannot reach the network (fetch, sockets, DNS).

    Measured: the listing, the native helper and the secrets broker do not need the kernel's network, because they go through node_repl's pipes. Not measured: a live Chrome tab round trip (accept-chrome --live) and other vendor features under scoped.

    Owner decision needed. #20's decision chose disabled partly because it lifts the network denial. Making scoped the default supersedes that, so the owner has to accept losing cell network access. If cells need network, disabled stays the only option in this release: no managed profile opens the network.

    Follow-up (implementation ticket, if the owner agrees)

    1. Add a CUA_SHIM_SANDBOX=scoped mode to src/runtime/sandbox.mjs with the payload above. Make it the default, keep disabled and default, and update the README configuration table and its paragraph. Add a spec Decision Log entry superseding cua serve sends no sandbox metadata, so node_repl denies all writes (temp dirs included): decide the sandbox profile #20's default, and a Surprises entry for two facts: managed profiles ignore "network":"enabled", and the kernel refuses writable trusted code paths.
    2. Live gates under scoped: verify.mjs, the readiness listing labels, and accept-chrome --live, which covers tab driving through the extension (not measured here). Also accept-native with its /tmp scratch home.
    3. Check that no workflow puts CUA_HOME or the checkout under $TMPDIR or under the run directory. Under scoped, that fails closed with the "Trusted RPC dependency" refusal. This is inferred from the rows above, not measured for $TMPDIR specifically.
    4. Optional, only if a need appears: extra writable roots through a setting (the measured {"type":"path"} entry works). The guard keeps this safe by refusing any root that covers trusted code.
    5. Do not merge the spike branch spike/sandbox-schema. The escape hatch exists only for this measurement.
  4. removed
    status:in-progress
    on Oct 5, 2026
  5. SSFSKIM commented on Oct 5, 2026

    @SSFSKIM
    OwnerAuthor

    [board] done: Findings posted: managed/restricted profile fits (temp + run dir writes, trusted roots read-only, labels work); any managed profile denies cell network; node_repl refuses to start if a write root covers trusted code. Follow-up registered.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    priority:P2spike

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions