Skip to content

Hide host credential files from sandboxed harness shells - #67

Merged
LikC1606 merged 1 commit into
mainfrom
fix/harness-home-credentials
Nov 29, 2026
Merged

LikC1606 merged 1 commit into
mainfrom
fix/harness-home-credentials

Conversation

@LikC1606

Copy link
Copy Markdown
Collaborator

Problem

Harness shells can read /. The outer bwrap (Claude Code, OpenCode, generic cli, Lean health check, isolated Codex) uses --ro-bind / /, and the Codex math-worker permission profile grants / = read. Both masked only /run, /tmp and hidden roots. A model-run shell could therefore read host credential files such as ~/.codex/auth.json, ~/.config/*, ~/.claude, ~/.ssh and ~/.claude.json.

Change

  • HOST_CREDENTIAL_PATHS and hostCredentialRoots(keep, homes) in src/runtime/harnessProcess.ts:
    • Resolve a fixed list of credential stores under the user's home (os.homedir() and the passwd home) to their real paths.
    • Also mask the real targets of symlinked entries in a masked directory. Masking hides the link, not the target.
    • When a store holds a path the launch needs (workspace, profile, executable, Lean lock), mask it entry by entry around that path.
    • Never mask / or an ancestor of a home.
  • prepareHarnessProcess adds these roots to its bwrap masks.
  • mathWorkerPermissionConfig marks them none.
  • Codex keeps <CODEX_HOME>/tmp visible because its apply_patch arg0 helper lives there and is on the shell PATH. The solver's default CODEX_HOME is under ~/.config.
  • Toolchains under home stay readable: ~/.codex/packages, ~/.elan, ~/.local/node*, and ~/.cache except the HuggingFace token.

Verification

  • New tests:
    • Fixture homes cover symlinked stores, a workspace inside ~/.config, and toolchains that must stay visible.
    • bwrap shell children cannot read the masked stores.
    • The Codex permission map denies the stores by default.
  • Focused harness, Codex, Claude Code, OpenCode, cli, tactic-battery and proof-environment suites: 458 passed. tsc --noEmit and bun run build pass.
  • Probe on a real host home, checked with test -r and directory listing only:
    • 7 of 7 credential paths are blocked in both the outer bwrap and codex sandbox with the math-worker profile.
    • The same script on the host reads 7 of 7.
    • lean --version runs.
    • With CODEX_HOME inside ~/.config, apply_patch still resolves while the profile's auth.json is denied.
  • Full suite: 6 failures in formalizationReviewCli and putnamBench also fail on main e676474b. codexSessionFileWatch fails only under full-suite load and passes alone.

Not covered

Credentials stored outside the home, or under file names that are not in the list.

🤖 Generated with Claude Code

Harness shells read `/`: the outer bwrap ro-binds it and the Codex
math-worker profile grants `/`=read. Both masked only /run, /tmp and
hidden roots, so a model-run shell could read ~/.codex/auth.json,
~/.config, ~/.claude, ~/.ssh and similar stores.

hostCredentialRoots() resolves a fixed list of credential stores under
the user's home to real paths, also masks the real targets of symlinked
entries, masks a store entry by entry when it holds a path the launch
needs, and never masks an ancestor of a home. prepareHarnessProcess adds
these roots to its masks; mathWorkerPermissionConfig marks them `none`.
Codex keeps CODEX_HOME/tmp visible because its apply_patch helper lives
there and is on the shell PATH. Toolchains under home stay readable.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@LikC1606
LikC1606 merged commit aaa8545 into main Nov 29, 2026
4 checks passed
@LikC1606
LikC1606 deleted the fix/harness-home-credentials branch December 1, 2026 20:12
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