Skip to content

pull --apply does not refuse .codex/: a pulled patch can plant an MCP server that runs on the laptop #592

Closed

Description

@mrsabath

pull --apply's refuse-list (push.ts:158-169) covers .claude/, .opencode/, .husky/, .mcp.json, opencode.json(c), .envrc and two .vscode/ files. It does not cover .codex/, and .codex/config.toml can declare an MCP server with an arbitrary command and args that Codex CLI launches on the laptop.

The list's own comment states the invariant it exists to hold:

each makes this machine run a command or start a program the next time an agent, an editor, git or direnv starts here, outside the sandbox

.codex/config.toml meets that description exactly, so this looks like a gap rather than a deliberate omission — Codex is not wired by sbx up today, so it was presumably just never in scope.

Measured

isAgentConfigPath logic from push.ts (AGENT_DIRS / AGENT_FILES / folds / segments), run against the paths in question:

false  .codex/config.toml
false  .codex
false  .codex/AGENTS.md
false  .CODEX/CONFIG.TOML
true   .claude/settings.json
true   .mcp.json
true   opencode.json
true   .envrc

Every existing entry refuses correctly; the .codex paths pass through. (Replicated from source rather than imported — the package's workspace deps are not installed in the environment I checked from, so this is the matcher's logic, not a call into the built module. Worth confirming with a case added to the 'matches the agent-config and hook paths, and not their neighbours' test in sbx-push.test.ts:1035.)

Why it matters

A patch from the sandbox that creates .codex/config.toml is applied into the working tree today. The file is typically untracked, so git diff after pull --apply would not show it, and the next codex run in that repository starts the named command locally — the same escape the refuse-list blocks for .mcp.json and opencode.json.

Reachability is the normal pull --apply threat model: whatever can write to the sandbox workspace can propose the patch. No Codex configuration by sbx up is required for this — only that the developer has Codex installed, which is increasingly likely and is the premise of the companion request to support it (#TBD).

Per docs/sbx/user-guide.md §3 the refusal is also what tells a user to inspect such a patch by hand (pull -o FILE), so the omission costs the warning as well as the block.

Suggested fix

One entry in AGENT_DIRS:

const AGENT_DIRS: Record<string, string> = {
  '.claude': 'Claude Code settings, hooks and commands',
  '.opencode': 'OpenCode configuration and plugins',
  '.codex': 'Codex CLI configuration, which can start MCP servers',
  '.husky': 'git hooks',
};

A directory entry already matches at any depth and under the existing case/Unicode folding, so this covers .codex/config.toml, .CODEX/... and a bare .codex file-or-link where the directory goes — consistent with how .claude is handled.

Two things worth a maintainer's judgement:

  • AGENTS.override.md. Codex reads it in preference to AGENTS.md, and PROMPT_FILES currently lists only claude.md and agents.md. Prompt files are warned about rather than refused ("they are text, not executables"), so the same reasoning applies — but a reader of the warning would not learn that an override file had appeared. Adding agents.override.md to PROMPT_FILES keeps the warning honest.
  • ~/.codex/config.toml. Out of scope here: a patch cannot write outside the working tree. Noting it only so the global/project distinction is explicit in any follow-up.

Relationship to the Codex support request

Independent of it. This should hold whether or not sbx up ever writes Codex configuration, and it is the smaller and more urgent of the two: the support request is a feature decision, this is a hole in an invariant the code already claims. Filing separately so it can land on its own.

Activity

  1. added
    ready-for-ai-review
    on Oct 23, 2026
  2. added a commit that references this issue on Oct 23, 2026
    066f58e
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    ready-for-ai-review

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions