Skip to content

Accept the managed-worktree identity include and name filesystem faults in the CSO launcher [squash] - #15

Merged
congvc-bot-x99[bot] merged 5 commits into
mainfrom
agent/x99-claude-sonnet-200k/che-9982-b6fbff4cf7fb
Nov 26, 2026
Merged

congvc-bot-x99[bot] merged 5 commits into
mainfrom
agent/x99-claude-sonnet-200k/che-9982-b6fbff4cf7fb

Conversation

@congvc-bot-x99

@congvc-bot-x99 congvc-bot-x99 Bot commented Nov 25, 2026 •

Copy link
Copy Markdown

The CSO launcher refused every Multica managed worktree with UNSAFE_PATH, and reported an unwritable state directory as INVALID_SCHEMA. Both left the security review NOT-RUN on three SA004 pull requests. This change accepts the managed-worktree identity include and names filesystem faults correctly.

Reproduction (before)

Installed launcher at 1e52e4aff, PR tevo-studio/sa004-vpn#421 head 2d6abfb50909bfa87634b70c48cc813adaae8fb8.

UNSAFE_PATH — managed worktree (multica repo checkout), gstack-cso-launcher start --repo . --diff --base origin/release/1.0.60 --offline:

{"ok":false,"error":{"code":"UNSAFE_PATH","message":"Repository Git config includes are not allowed during a security snapshot"}}

Cause: Multica writes <gitdir>/worktrees/<name>/config.worktree containing [include] path = multica-identity.config (identity defaults). The guard rejected every [include].

INVALID_SCHEMA — same command from a clean clone, with an unwritable $HOME (env -i HOME=/nonexistent):

{"ok":false,"error":{"code":"INVALID_SCHEMA","message":"The helper rejected an unexpected or unsafe input"}}

Cause: ensureDirectory (lib/cso/state.ts) let a raw EACCES from mkdirSync escape; the top-level catch in cli.ts relabels every non-CsoError as INVALID_SCHEMA. No field is rejected; the schema is not involved. The launcher output has no run ID, so this is the same string Luna-2 and Sol saw. I could reproduce that exact error text and path; I cannot prove their sandbox had an unwritable state root (they posted no helper report).

Fix

  • lib/cso/process.ts: accept an [include] only if every include directive is a plain [include] section with path = <plain relative name>, the target resolves (no symlinks, no ..) to a regular file directly inside the Git directory that holds the config, and the target includes nothing itself. The target is bounded and identity-checked like the config. Rejected as before: includeIf, subsections, quoting, other keys, absolute or .. paths, symlinks, missing files, nested includes, and any file in the working tree (attacker-controlled repo content). This is not a bypass.
  • lib/cso/state.ts: an mkdir failure is PERSISTENCE_FAILED with the errno and a GSTACK_HOME hint (the launcher passes GSTACK_HOME, not GSTACK_STATE_ROOT).
  • lib/cso/cli.ts: unexpectedFailure() maps errno-coded exceptions to PERSISTENCE_FAILED; unknown exceptions keep the old label.

Tests

New: test/cso-git-hardening.test.ts (managed worktree: accepted; outside, .., ~, includeIf, subsection, quoted, keyed, symlink, missing, nested, working-tree: rejected; included file changed mid-operation: SNAPSHOT_RACE; snapshot capture in a managed worktree) and test/cso-error-mapping.test.ts. The three accept-path tests fail on 1e52e4aff; the reject-path tests pass on both (guard not weakened).

$ TMPDIR=/tmp/che9982-tmp bun test --timeout 120000 test/cso-error-mapping.test.ts test/cso-git-hardening.test.ts
 21 pass
 0 fail
$ bunx prettier --check lib/cso/*.ts
All matched files use Prettier code style!

Wider run (test/cso-*.test.ts minus docker, integration, windows, macos, registry): 79 failures before and 79 after, identical list (compiled-binary tests; no built core in a fresh checkout). 702 pass. Note: the host TMPDIR parent (/mnt/ssd2/multica-tmp, mode 775) trips the group-writable-ancestor guard in capture tests; I used a /tmp TMPDIR.

Proof on the PR 421 head (fixed launcher built from this branch with scripts/build-cso.sh)

Managed worktree at 2d6abfb:

old: {"ok":false,"error":{"code":"UNSAFE_PATH", ...includes are not allowed...}}
new: exit 0; schemaVersion 3, runId 1795633959212-fb66e11e269500d3, status running, completeness partial, base origin/release/1.0.60

Unwritable $HOME:

old: INVALID_SCHEMA "The helper rejected an unexpected or unsafe input"
new: PERSISTENCE_FAILED "Private state directory could not be created (EACCES); set GSTACK_HOME to a writable directory"
new + GSTACK_HOME=<writable>: starts (schemaVersion 3, status running)

Risk

  • The installed launcher (~/.claude/skills/gstack) stays on the old build until setup rebuilds it from this branch after merge.
  • Cross-lab PASS needed (AC 5): author is Anthropic lab.

Tracker: CHE-9982, parent incident CHE-9976 (R5).

Round 4 (terra P1 on 72fe7d9): the root is fixed at build time, not taken from the caller

  • lib/cso/launcher.c: MULTICA_TASK_WORKSPACES_ROOT is no longer forwarded from the caller's environment. The launcher sets it from the compile-time GSTACK_CSO_MANAGED_ROOT (empty when unset, so every include is rejected: fail closed).
  • scripts/build-cso.sh: passes -DGSTACK_CSO_MANAGED_ROOT from the installer's GSTACK_CSO_MANAGED_ROOT, else its MULTICA_TASK_WORKSPACES_ROOT. A non-plain or relative path stops the build (exit 64).
  • test/cso-cli.test.ts: compiled-launcher test with three launchers built in the test. (1) Managed worktree under the baked root: accepted, with the caller's variable unset or wrong. (2) Unmanaged linked worktree outside the baked root, caller sets its own parent, the parent of that, or /: UNSAFE_PATH. (3) Launcher built without a root: both worktrees rejected even when the caller names the managed root. It fails on the old launcher source.
$ umask 022; TMPDIR=/tmp bun test --timeout 30000 test/cso-cli.test.ts   -> 32 pass, 0 fail
$ TMPDIR=/tmp bun test test/cso-git-hardening.test.ts                    -> 21 pass, 0 fail
cso-launcher-generation 5 pass; cso-windows-launcher 2 pass; cso-macos-launcher 1 pass; cso-error-mapping 3 pass

(A shell with umask 0002 or a group-writable TMPDIR parent trips "group- or world-writable ancestor" in the fixtures; unrelated to this change.)

AC 4 on this head: launcher built with GSTACK_CSO_MANAGED_ROOT=/mnt/ssd2/multica_workspaces bash scripts/build-cso.sh, run from the author worktree on the PR 421 head 2d6abfb:

  • caller env without the variable: start --offline returns runId 1795682806860-4ccb1408d346ffb0, status running.
  • caller env MULTICA_TASK_WORKSPACES_ROOT=/nonexistent: runId 1795682888594-35c13493bfdc3310, status running.
  • unmanaged linked worktree in /tmp, caller env MULTICA_TASK_WORKSPACES_ROOT=/tmp: UNSAFE_PATH.

Setup must build the launcher with the root (it inherits the daemon's MULTICA_TASK_WORKSPACES_ROOT); a launcher built without it rejects managed includes.

AC 1-2 evidence: original INVALID_SCHEMA, Sol's exact invocation in the Codex sandbox (head 49f88b6, no code change)

Run on X99, 26 Nov 2026, codex-cli 0.166.0. Source: CHE-9982 comment 01a217c1 (the issue's coordinating agent ran these; I repeated the tiny-repo variant of step 1 and 3 earlier and got the same result).

Setup: fresh clone of tevo-studio/sa004-vpn, detached at Sol's signed head 2d6abfb5; local release/1.0.60 at Sol's base a59cb1d9 (the remote branch is gone, both commits fetched by SHA). No repo Git config include, so this is not the UNSAFE_PATH case. Command from Sol's report, only the path differs:
gstack-cso-launcher start --repo <clone> --diff --base release/1.0.60

  1. Installed (old) launcher, sandbox workspace-write: exit 1, no run ID, byte-identical to Sol's output.
{"ok":false,"error":{"code":"INVALID_SCHEMA","message":"The helper rejected an unexpected or unsafe input"}}
  1. Same installed launcher, same args, no sandbox: starts a run (status: running, completeness: partial). The input and repo are valid; only the sandbox changes the result.
  2. This PR's launcher (built from 49f88b6e with scripts/build-cso.sh), same args, sandbox: exit 1, PERSISTENCE_FAILED, "The helper hit a filesystem error (EROFS)". EROFS is the failing operation: the state-root write on a read-only file system. In that sandbox touch ~/.gstack/probe gives Read-only file system.

Result: same input, same sandbox, same message as Sol. INVALID_SCHEMA is a catch-all, so the text alone proves nothing. The new build names the operation (EROFS) on the identical call. No schema field is rejected. The producer was the catch-all in cli.ts relabelling a raw filesystem fault from ensureDirectory; this head maps it to PERSISTENCE_FAILED with a GSTACK_HOME hint.

Limits: I cannot replay Sol's own session (strace is blocked in the sandbox). Luna-2's command was not recorded beyond "INVALID_SCHEMA three times"; Luna-2 is also a Codex agent under the same sandbox.

Not claimed: after this fix a Codex sandbox agent still cannot run the launcher, because its state root must be writable and private. That is CHE-10265, a separate fix.

…aults (CHE-9982)

- process.ts: accept a plain relative [include] path that resolves to a regular
  file directly inside the config's own Git directory (no nested includes);
  bind it in the config identity; everything else still UNSAFE_PATH.
- state.ts/cli.ts: mkdir/errno faults report PERSISTENCE_FAILED with the errno
  instead of INVALID_SCHEMA.
@congvc-bot-x99 congvc-bot-x99 Bot changed the title fix(cso): managed-worktree identity include + name filesystem faults (CHE-9982) [squash] Accept the managed-worktree identity include and name filesystem faults in the CSO launcher [squash] Nov 25, 2026
@congvc-bot-x99
congvc-bot-x99 Bot marked this pull request as ready for review November 26, 2026 15:38
@congvc-bot-x99
congvc-bot-x99 Bot merged commit b3ef735 into main Nov 26, 2026
61 of 62 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