P0 linux-sandbox: isolate Codex translation behind the helper process - #54
Merged
Merged
Conversation
Move PermissionProfile and Codex argv construction into a binary-only helper via prepare/run and an opaque plan, so runner depends only on the serde protocol crate. Co-authored-by: Cursor <cursoragent@cursor.com>
REQUIRE is a CI assertion knob, empty plan arguments are legal argv, and the helper now uses a random 0700 directory that is removed after run. Co-authored-by: Cursor <cursoragent@cursor.com>
codespace-fs Rama guards must appear in crates/codex-runtime/Cargo.lock so --locked CI can run, and prepare must timeout stdin writes and cap stdout while reading. Co-authored-by: Cursor <cursoragent@cursor.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
PermissionProfile/ sandbox-argv translation behind a binary-onlycodespace-linux-sandboxhelper. The runner talksprobe/prepare/run --planover serde JSON (SANDBOX_HELPER_PROTOCOL=1); Codex argv never leaves the helper (opaque 0600 plan in a random 0700 directory, thenexecof the same PID).codespace-runnerdrops the helper library path dep and depends only oncrates/linux-sandbox-protocol.#53spawn/advertisement semantics stay: probe false → direct argv +none; probe true →linux-sandbox/ Restrictedenforced; no unsandboxed fallback. Prepare / protocol / helper OS-spawn failure isPROCESS_SPAWN_FAILED. After a managed helper spawn succeeds,run --planload, self-exec, or inner sandbox failure is a managed process exit.WIRE_PROTOCOLremains3. NetworkEnabled/ proxy is not in this PR.#53follow-ups onmain: helper Read in the Minimal profile, Clippycfgbranches, parallel CI (userns + isolation scoped to--test isolation), and refresh the isolated runtime lock so it no longer carries the helper library. Rama0.3.0-alpha.4leaf guards stay on the helper lock and are also pinned oncrates/file-system(and the isolatedcrates/codex-runtimelock) because root still sees that graph throughcodespace-fs.preparenow writes stdin, reads stdout/stderr, and waits for exit inside one timeout. Output size is capped while reading; timeout kills and reaps the prepare child.Test plan
cargo fmt(root +crates/linux-sandbox)./scripts/check-no-model-deps.shpython3 -B scripts/check_docs.pycargo tree -p codespace-runnerhas nocodespace-linux-sandbox/codex-linux-sandboxcargo metadata --locked --offline --manifest-path crates/codex-runtime/Cargo.tomloutput too large--bins --test cli;CODESPACE_REQUIRE_LINUX_SANDBOX=1isolation; workspace tests withCODESPACE_LINUX_SANDBOX_BINcargo treeafter root clippy/tmp, AF_INET denied / AF_UNIX allowed, PTY isatty + stdin, terminate reaps the treePROCESS_SPAWN_FAILEDwhen probe is falseWIRE_PROTOCOL=3"") survives opaque plan roundtrip; leftovercodespace-linux-sandbox-*plan dirs are removed afterrun