Skip to content

Fall back to a private temp state root when the CSO default is read-only (CHE-10265) [squash] - #16

Merged
congvc-bot-x99[bot] merged 2 commits into
mainfrom
agent/x99-claude-sonnet-200k/che-10265-65d13b0d9b29
Nov 26, 2026
Merged

congvc-bot-x99[bot] merged 2 commits into
mainfrom
agent/x99-claude-sonnet-200k/che-10265-65d13b0d9b29

Conversation

@congvc-bot-x99

Copy link
Copy Markdown

Fixes CHE-10265 (parent incident CHE-9976). Head 4bdec7d3a7c0c8012805df5e67fdce40eb30f661.

Problem

In a Codex workspace-write sandbox (codex-cli 0.166.0) ~/.gstack is read-only, so gstack-cso-launcher start returned PERSISTENCE_FAILED (EROFS) and Codex reviewers could not run the security scan. ~/.gstack/security/cso already existed, so the failure was the chmod of an existing directory, not a mkdir.

Change

  • privateRoot(): if the default root cannot be written (EROFS/EACCES/EPERM) and no GSTACK_STATE_ROOT, GSTACK_HOME, GSTACK_STATE_DIR or CLAUDE_PLUGIN_DATA is set, retry once under /tmp/gstack-cso-<uid> (sticky /tmp, per-uid, 0700). Not on Windows.
  • Guard unchanged: the same ancestor/owner checks run on the fallback. A group/world-writable ancestor, or a leaf another user or mode pre-created, is rejected UNSAFE_PATH. An unsafe default root is not retried. An explicit state-root variable is never replaced. No bypass.
  • Existing-but-read-only directories are detected (chmod and access(W_OK) faults become PERSISTENCE_FAILED with the errno).
  • assertStateOutside also checks the fallback path.
  • Runs made in the sandbox live in /tmp/gstack-cso-<uid> and are not visible outside it.

Reproduce (before, installed build at b3ef735)

$ codex sandbox -c 'sandbox_mode="workspace-write"' -- gstack-cso-launcher start --repo <clean repo> --diff --base main --offline
{"ok":false,"error":{"code":"PERSISTENCE_FAILED","message":"The helper hit a filesystem error (EROFS)"}}

After (launcher built from this head)

start returns a run ("status": "running", runId 1795712655544-a1307daf42795438) in the sandbox; inspect and finish on that run also work in the sandbox. State dir: drwx------ /tmp/gstack-cso-1000/security/cso.

Tests

bun test test/cso-sandbox-state-root.test.ts test/cso-error-mapping.test.ts test/cso-state-userns.test.ts → 16 pass, 1 skip, 0 fail.
New cases: read-only default falls back (0700, owned by uid); writable default unchanged; explicit root never replaced; group/world-writable ancestor still rejected; group-writable pre-existing leaf rejected; unsafe default not retried; bwrap read-only user-namespace run with existing read-only state dirs succeeds.
bun run format:cso:check clean.

Wider CSO suite (test/cso*.test.ts minus docker/macos/windows/lifecycle, TMPDIR=/tmp): base main 766 pass / 23 fail; this branch 774 pass / 23 fail. The 23 failures are identical in count and exist on main on this host (not touched here). Note: with this host's default TMPDIR (group-writable ancestor) 240 more fail on both — same guard.

Not covered

Windows (fallback off). Reading in the sandbox a run created outside it (different root). Codex builds without a writable /tmp.

@congvc-bot-x99 congvc-bot-x99 Bot changed the title fix(cso): fall back to a private /tmp state root when ~/.gstack is read-only (CHE-10265) [squash] Fall back to a private temp state root when the CSO default is read-only (CHE-10265) [squash] Nov 26, 2026
@congvc-bot-x99
congvc-bot-x99 Bot marked this pull request as ready for review November 26, 2026 18:28
@congvc-bot-x99
congvc-bot-x99 Bot merged commit df3f77a into main Nov 26, 2026
53 of 54 checks passed
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.

0 participants