Repository navigation
fix(cli): a sandbox that denies chmod no longer breaks reading Orca's state files - #33662
Merged
Merged
Conversation
Contributor
|
Warning Review limit reachedYou've used all free OSS reviews for now. Wait for the free limit to reset to keep reviewing this public repository. Next included review available in 8 minutes. View limit details
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
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.
ELI5
If you let an agent's sandbox reach Orca's socket,
orca statussaid "ready" butorca worktree liststill failed, sayingorca-environments.jsonwas "invalid". The file was fine. Before reading it, the CLI tries to tighten its permissions withchmod, and the sandbox blocks that write. Now a blocked chmod no longer fails the read.Root cause
readEnvironmentStoreRecords, the environment sidecar, the WSL/ephemeral-VM stores) callhardenExistingSecureFilefirst. On POSIX that callschmodSyncon userData and on the file. The read path wraps it in the sametryas the parse, so anEPERMfrom chmod comes out asruntime_error: Could not read Orca environments at …; the file is invalid.@anthropic-ai/sandbox-runtime. On macOS it only allowsfile-write*(which includes chmod'sfile-write-mode) insideallowWrite(dist/sandbox/macos-sandbox-utils.js:705-733, v0.0.81). It blocks unix sockets unless the path is inallowUnixSockets(:969-979). So once a user allows Orca's socket, status works but every command that reads environments fails.0700/0600, so the chmod is a no-op attempt. Windows readers were already best-effort (hardenExistingWindowsFilereturns a boolean instead of throwing). Only POSIX failed the read.What changed
hardenExistingSecureFile(called only by readers) now ignoresEPERM/EACCES/EROFSfrom hardening. Other errors still throw. Writers (writeSecureFile) are unchanged and still harden and report.EIOstill throws.How verified
Real CLI built from this branch (
out/cli), run undersrt0.0.81 on macOS against a live Orca, with only the runtime socket inallowUnixSocketsand writes limited to a temp dir:origin/mainorca status --jsonreadyreadyorca worktree list --jsonruntime_error"orca-environments.json … the file is invalid"orca repo list --json,orca terminal list --jsonWith the socket not allowed, both builds return
runtime_access_deniedfrom status and from every other command (the behavior from #22341). File modes stayed0600after the runs.Windows (awin, Orca 1.4.237, Codex 0.159.2
[windows] sandbox = "elevated"), for the related #13539: from insidecodex sandbox, the runtime pipe connect returnsEPERM.orca status --json,orca worktree list --jsonand plainorca worktree listall returnruntime_access_deniedwith the "don't restart" next steps. So the "status saysstartingforever" half of #13539 is already fixed on main by #22341. The pipe DACL half is not addressed here; see below.pnpm tc,pnpm test src/shared/secure-file*.test.ts src/shared/runtime-environment* src/cli/runtime/environments.test.ts,pnpm run check:code-quality:changedall pass.Risk
Low. Only reader-side, opportunistic hardening changes. A file with loose permissions that a sandboxed reader can't chmod is read as-is and gets hardened on the next unsandboxed read or write.
Not in this PR
#13539 Defect 1 (sandbox users can't connect to the Windows runtime pipe) needs a product/security decision. Fixing it means creating the pipe with a native security descriptor that grants
CodexSandboxUsersconnect rights. That would let sandboxed commands drive Orca, and Orca can spawn arbitrary terminals, so it is effectively a sandbox escape the user opted out of.Fixes #20937