Skip to content

Own sandbox M1: cua's seatbelt port and own host on macOS (#115) - #156

Merged
SSFSKIM merged 79 commits into
mainfrom
feat/115-own-sandbox-m1
Oct 18, 2026
Merged

SSFSKIM merged 79 commits into
mainfrom
feat/115-own-sandbox-m1

Conversation

@SSFSKIM

@SSFSKIM SSFSKIM commented Oct 17, 2026 •

Copy link
Copy Markdown
Owner

Part of #115: M1 of the own-sandbox spec (docs/doperpowers/specs/2026-10-17-own-sandbox-design.md). On macOS, cua's own REPL host now launches its kernel and trusted worker under cua's own seatbelt profiles, generated by src/sandbox/, a JavaScript port of openai/codex rust-v0.159.2's profile generation (Apache-2.0, with provenance headers, LICENSE and NOTICE). No Codex CLI process is involved on that path any more. The kernel is denied the secret store, ~/.config/cua and the cua home; runtimes/, node/ and its own run directory stay re-exposed. TMPDIR is per session. The vendor host and Linux keep the Codex CLI until M2 and M3.

The live mini acceptance ran at code f8019bf, and its evidence branch is merged here. reviewer-high returned correct after one fix round (f8019bf). A later harness-only fix (6ad675c) makes probe serve wrappers keep their exit status.

What changed

  • src/sandbox/: policy.mjs (roles, deny list, prepareDenyTargets), seatbelt.mjs (the port), env.mjs, index.mjs, the four .sbpl files as byte copies, LICENSE and NOTICE.
  • src/runtime/launch.mjs: the deny list and CUA_SANDBOX_DENY_READ ({deny, reexpose, metadataOnly, tiers}), the per-session sessionTmp, and src/sandbox/ added to the trusted code paths. The macOS own host no longer gets CODEX_CLI_PATH or CODEX_HOME. A disabled connection builds no list.
  • src/runtime/sandbox.mjs: overlapping deny targets are refused (sandbox_conflict), and only the launch's own run directory and session temp are excepted.
  • src/repl-host/supervisor.mjs and kernel-child.mjs: childLaunch by role, a launch key equal for both roles, and the kernel is Node itself under /usr/bin/sandbox-exec.
  • Doctor: the session write root and the deny list.
  • Harness: the oracles and own-sandbox acceptance item 11. Also:
    • the mini run rules as code (scripts/mini-rules.mjs);
    • the in-run CI pause (scripts/mini-pause.mjs, MAWS DL 58), with a Runner.Worker probe matched by executable;
    • sibling scratch HOME layouts;
    • repl-parity's declared kernel-exit-status difference, retired in M2.

Rulings and deviations (spec Decision Log)

  • The port's widening deviation. It grants file-read-metadata on exactly <cuahome> and <cuahome>/run, as literals at real paths. Without it, Node's ancestor lstat makes every import fail. The other deviations are all tighter or fixes: no Codex config, the numeric TIOCSTI, one more stripped env name, and a relative TMPDIR is refused.
  • Tier discovery fails closed for confined launches. Only ENOENT proceeds. An unreadable store or projects/ refuses with a sentence naming the remedy. A relaxation tried first was reversed after review, because the kernel could still read an external tier through its real path.
  • Deny targets are created on Linux only, within bounds. macOS denies the realish path and creates nothing.
  • Behaviour change for the README and release notes (M4). On macOS, a confined launch refuses with sandbox_conflict when the cua home, the store or its tiers, or ~/.config/cua lie inside one another. Remedy: move them apart, or run disabled.

Validation Evidence

  • HOME=$(mktemp -d) npm test at 7525181 (after merging main): # tests 2800, # pass 2629, # fail 2, # skipped 169.
    • create-hetzner.sh copies an upload whose local path has a space … is the known printf: write error: Broken pipe, which fails the same way at base.
    • macOS: a 192-byte socket path connects … is a flake under full-suite load on this shared MacBook, and passes alone. CI is the gate of record.
  • npm run test:mods: 133 tests across 6 files, 0 failed. claude plugin validate .: passed, with the known pre-existing warnings.
  • GCE Linux regression (own host, cells suite, still through the Codex CLI on Linux): 150/150, confinement and lifecycle included (docs/evidence/2026-10-17-own-sandbox/m1/gce-cua-cells/).
  • Mini, at code under test f8019bf. Every run is gated under the mini rules and the MAWS DL 58 pause; evidence is under docs/evidence/2026-10-17-own-sandbox/m1/, with earlier attempts kept as *-attempt-N/ and their causes:
    • tier-check against the real store proceeds (0 tiers);
    • oracles: every fingerprint judgement is ok, and the port matches the signed CLI's captured argv and profile in scoped and default;
    • own-sandbox (acceptance 1–5): 76/76, including store-root-missing-at-launch, which stays denied once created;
    • cfprefs, 90cbfe0's profile against f8019bf's: all four suites PASS (cells 150/150 and services 41/41 on each side). Neither side has a preferences denial, so the original's semantics are kept. The new logd/diagnosticd mach-lookup denials are noted, not granted;
    • repl-parity: vendor 479/479 and cua 479/479; diff --expected ok, with 0 undeclared differences;
    • accept-native: item 11 PASS 76/76, items 4–5 PASS, and the other items match main's own run at 94366c1 (residue branch). probe-secrets standalone at 6ad675c: 30 passed, 0 failed, including the refused launch for an unreadable store;
    • the TextEdit sitting ran with the owner present, during a runner hold that CI-opt and MAWS set up.

Unresolved Review Findings

  • docs/doperpowers/research/2026-10-17-own-sandbox/spike-helper/serve-spike.mjs:13: the archived research wrapper still exits only through an unreferenced timer, the pattern 6ad675c fixed in the maintained wrappers. Left as is: it is a research artefact that nothing runs.

  • test/sandbox/reexposed.test.mjs:143-152: waits 300 ms before creating the store, instead of a readiness handshake with the sandboxed child. Under heavy load the mid-session proof weakens. Left: the acceptance runner's own check uses a warm-cell handshake.

  • test/native-baseline/device.test.mjs:163,167 (from M0): a temp path is interpolated into sh -c source. Test-only.

Residue

  • Harness: a pause longer than the runtime's 15-minute idle stop changes a cell's output (a runtime-restart notice), not only its timing. The runs here avoided it, but the pause could keep the runtime warm or declare the notice.
  • accept-native should quit its own fixture TextEdit by causal ownership, as the vendor helper witness does. Today it leaves it frontmost.
  • Main's accept-native on the mini reports item 10's token-like strings (by file:line and rule, in the residue README) and two item-1 unit tests that fail only in its env -i environment. Not Independence 2: cua's own sandbox for node_repl cells; drop the Codex binary and app-server #115's scope.

…nal's policy files

src/sandbox/seatbelt.mjs ports the original codex sandbox's profile generation
at rust-v0.159.2 for cua's input set and matches the 20 golden fixtures byte
for byte (numeric TIOCSTI), on an in-memory macOS-shaped filesystem everywhere
and on the real one on a Mac. Recorded deviations: no Codex config, the numeric
TIOCSTI line, one more stripped name, a relative TMPDIR refused, and a metadata
grant on the denied directories above re-exposed paths (without it Node cannot
resolve a module under a re-exposed directory: lstat of the denied ancestor
fails with EPERM).
… asks for

src/sandbox/policy.mjs renders one permission profile per role from a call's
sandbox state (the CLI's key order, through sandboxPolicy's validation), adds
the kernel's deny list (the secret store with the real targets of symlinked
tiers, ~/.config/cua, the whole cua home on macOS with runtimes/, node/ and the
session re-exposed; Linux's per-directory shape from M0c), creates missing deny
targets 0700 before rendering, and keeps one launch key for both roles.
src/sandbox/index.mjs turns a role and state into the sandbox-exec launch.
…ua's sandbox

buildLaunch gives every launch its session's own TMPDIR (run/<id>/tmp, both
hosts), resolves the kernel's deny list once into CUA_SANDBOX_DENY_READ,
trusts src/sandbox on both hosts, and on macOS gives cua's own host
CUA_REPL_SANDBOX_EXEC instead of CODEX_CLI_PATH and CODEX_HOME (Linux keeps
the Codex CLI until M3). The supervisor launches each child by role through
src/sandbox under sandbox-exec, which execs Node, keeps one launch key for both
roles and refuses with a sentence when the deny list is missing or malformed,
a deny target cannot be created or a state cannot be rendered. The scoped
preflight and doctor protect the deny list except the launch's own run
directory and session temp. The tz probe's cua launcher and the oracle's
fingerprint under cua's launcher and port-vs-capture are wired.
…er its own sandbox

scripts/accept/own-sandbox.mjs opens real own-host connections (browser surface
only: no helper, no GUI) on an installed home and checks, per mode, every
deny-list location (store, symlinked tier target, ~/.config/cua, state/, an
enrolled device under remote/, chrome/, another session's run directory), the
module tree, writes, a hard link and a clone of a denied file, TCP and AF_UNIX
connects, the kernel's process and the absence of codex. Synthetic sentinels
only, removed after; the report carries labels and codes.
…e's run/ is the run's

Since M1 buildLaunch gives every launch its session's own TMPDIR, so the native
helper a run opens carries <home>/run/<session>/tmp rather than the run's own
TMPDIR. During the run the approved home's run/ is the run's (moved aside, the
admission keeps everyone else out, and preparation refuses while the helper
runs), so that value is as causal a witness; the run's own TMPDIR stays
accepted for pre-M1 runs (M0c's obligation before M2's native runs).
… rules

mini-rules gains `gated -- <command>` (the gate, the command, the frontmost
check) for any mini run beyond M0's items. scripts/sandbox-probe/m1-mini.sh
carries M1's: the oracles (fingerprint under cua's launcher, port against the
argv captures), the own-host confinement check, and the cfprefsd measurement
(cells and services under log stream before and after, reduced by
denials.mjs so no account path leaves the mini). accept-native gains item 11,
the own-host confinement check.
…s the boundary launch's TMPDIR; the overlap preflight stages a run directory resolving into the modules
…ystem prompt always stops, and Terminal is required once the runner is idle
… own host at 96104bc (150/150, confinement and lifecycle included)
…l=9) by Node itself against the vendor's exited(code=137) on macOS child-exit-settles only (#115 M1, retired in M2)
…ome and its run/, literal and metadata only, real paths, never the store, ~/.config/cua or another session); the kernel fingerprint pins it too
…targets refused in scoped and default; the run directory's exception only for its own home; the port grants metadata only within the launch's metadataOnly
…exit 1; fingerprint comparisons judged against declared deviations; port-vs-capture fails beyond its deviations
…r discovers the deny list; confined launches keep strict discovery, and a list-less host refuses every confined call
…kernel exit facts on child-exit-settles; the rest of that row compares
…e parity comparator's own field set (ok, error, proof included)
… an unread CI observation waits and reads again, an unreadable frontmost app still stops
…IR witness), the own-host browser triple, and tz under the real HOME (0 of 160 hung)
…d port-vs-capture, every judgement ok), gated under load < 5
…ate (the file did not parse, so accept-native crashed on load); every acceptance script is now syntax-checked and accept-native's imports loaded by the unit suite
…s PASS, 0 FAIL (the 107c291 attempt stopped on own-sandbox.mjs's parse error)
…nthetic key): FAIL (npm test 2 of 2586 and its cascade; item 10's clean clone of a detached checkout), items 4-5 PASS; the run left its TextEdit in front (stop at 15:25:44Z)
…TextEdit stop, per-item results, item 1's two failing tests, item 10's matches by file:line and rule)
…1 PASS (71/71); live probe-secrets' store-unreadable phase meets M1's launch refusal; the README with the 107c291/c55ba01 split
…ceeds with the store denied (only a searchable, unlistable one refuses); three M0/M1 tests hold under accept-native's env -i item-1 environment
…me entry symlinked out of it (but runtimes/ and node/); a host read path inside a deny target, outside the re-exposures, refuses the kernel launch; the worker probe runs under sh whatever the login shell; m1-mini accepts only hex commit ids; the launcher double quotes its paths
…it timer: a refused launch exited 0 by natural exit before the timer fired (cua serve itself exits 1); a child-process test for both against an unreadable store
…-1 (oracles at 107c291; own-sandbox and accept-native at c55ba01; the cfprefs attempt whose after side failed at connect while the harness checkout moved), ahead of the single-SHA rerun
…4bfece proceeds (projects/ absent; 0 tiers), kept as attempt 2 ahead of the rerun at the new final SHA
…al store; oracles every judgement ok; own-sandbox 76/76 PASS, the store root missing at launch kept denied (plain and through a symlinked ~/.config)
… before 150/150 and 41/41 PASS; after refused at connect, sandbox_conflict (the parity harness's prepared HOME lies inside its CUA_HOME, which M1's macOS whole-home deny refuses)
…, oracles, own-sandbox 76/76; cfprefs attempt 2's sandbox_conflict in the parity layout)
…against 5d9bf70) invalid: the runner watch ended it at 18:14:11Z on a Runner.Worker during the before side; its own leftovers cleaned
…ended it at 18:34:34Z on two Runner.Workers, 37 s into the before side; its own leftovers cleaned
…the controller at 18:48Z for the worker-probe fix; its own tree ended, leftovers cleaned
… the hook paused it correctly at 19:02:06Z on a real CI job, and the controller-side watch wrongly ended it at 19:03:39Z (its long-cell test missed a pause line logged before the watch first saw the pause)
…dle throughout): before 150/150 and 41/41 PASS; after side still sandbox_conflict, since the after side's remote serve-cells capability home is 5d9bf70's own, which nests HOME
…stopped at 20:07:11Z by a SecurityAgent dialog during the after side's services; before 150/150 and 41/41 and after cells 150/150 PASS; cleanup on the mini held
…e securityd crash correlation (1 of 5 crashes overlaps a run of ours; one stack in all)
…sandbox kept as attempts ahead of the rerun at f8019bf
…every judgement ok; own-sandbox 76/76 PASS
…ites PASS, no preferences denial; new diagnosticd/logd mach-lookup denials on the after side; the cells judge's one difference is the 34-minute pause outlasting the runtime's idle stop
…agnosticd stay denied, noted; the suspend-resume difference is a pause artefact)
…ASS; the cua side's attempt 1 ended at the controller's ruling during a 34-job CI burst (kept, invalid)
…I-opt's hold (queue exception), diff ok with no undeclared difference; suspend-resume closed
… with item 11 (76/76 PASS) against main's items; parity's README section; one live finding (a refused launch exits 0)
…dbox 76/76 PASS; probe-secrets standalone PASS, the refused launch now fails closed with a failing exit
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.

1 participant