Skip to content

feat(vetted-ops): let the ~ spelling reach Codex rules safely - #1670

Merged
potiuk merged 1 commit into
apache:mainfrom
potiuk:fix/codex-vetted-ops-tilde
Oct 16, 2026
Merged

potiuk merged 1 commit into
apache:mainfrom
potiuk:fix/codex-vetted-ops-tilde

Conversation

@potiuk

@potiuk potiuk commented Oct 16, 2026

Copy link
Copy Markdown
Member

Skills invoke the dispatcher as uv run --project ~/.claude/magpie/vetted-ops vetted-op-read …, which the Codex rules added in #1649 never match, so every read-only vetted operation prompts under Codex. Allowing ~ in the rules would not be a fix:

  • Codex's plain-command parser rejects any word containing ~ (codex-rs/shell-command/src/bash.rs), so a shell-string command with ~ never reaches a prefix rule at all.
  • ~ in an argv-form command would be worse: uv does not expand it and treats ~/… as a relative directory, so an agent-created ./~/.claude/magpie/vetted-ops would run with an allow and a sandbox bypass. In shell form, ~ follows HOME, which an earlier command can reassign.

So the rules stay absolute-only, and the ~ is resolved before they run:

  • vetted-ops-codex-rules --hook prints a Codex-only PreToolUse hook registration with the same absolute stable path the rules name (--stable-path, fixed at render time). It goes in the user's ~/.codex/config.toml, after review, like the rules.
  • The hook rewrites one case only: a command that is exactly one vetted-op-read call in the ~ spelling, with plain or simply quoted arguments. Write entry points (vetted-op, vetted-op-tracker) and anything chained, redirected, substituted or multi-line are left untouched.
  • It grants nothing. In Codex 0.163 the hook's allow only carries updatedInput: a hook result is either continue (with an optional rewrite) or blocked, and the rewritten command then goes through the native rules and approval. Even if allow were read as an approval, the hook could only let through the lone read the rules already allow.
  • Codex only. Claude Code reads the same allow as a permission grant, so the hook is registered in Codex config only, and as a backstop stays silent unless the event carries Codex's turn_id and model fields.

Tests cover the rewrite, 24 inputs it must leave alone (writes, ;/&&/pipes, redirection, $(…), backticks, heredocs, quoted/escaped/lookalike paths), the HOME-independent fallback, the output contract (including a Claude-style event that must stay silent), and a round trip through the real codex execpolicy check: the skill's ~ command matches nothing, and its rewrite matches the absolute allow rule.

Not verified end to end in a live Codex session (that needs a model run); the hook/approval interaction is from the 0.163.0 source.


Second read: roborev (claude-code), iterated until it passed; a background security review shaped the lone-read restriction.

Generated-by: Claude Opus 5

🤖 Generated with Claude Code

Skills invoke the dispatcher as uv run --project ~/.claude/magpie/vetted-ops,
which Codex execpolicy never matches: its plain-command parser rejects any word
containing ~. A ~ rule would be unsafe rather than a fix, because the shell
resolves ~ from a reassignable HOME and uv treats a literal ~ as a relative
directory the agent can create, so every read-only vetted op prompted instead.

A Codex-only PreToolUse hook now rewrites a command that is exactly one
vetted-op-read call in that spelling to the absolute stable path fixed at
render time, the same path the rules name, before the rules run. Write entry
points and anything chained, redirected or substituted are never rewritten,
so the hook can at most let through the lone read the rules already allow.

Generated-by: Claude Opus 5
@github-actions github-actions Bot added family:tools tools/* family:docs Docs, MISSION.md, READMEs substrate:sandbox Tool substrate: agent isolation, egress control, settings audit labels Oct 16, 2026
@potiuk
potiuk merged commit 622bfbc into apache:main Oct 16, 2026
11 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

family:docs Docs, MISSION.md, READMEs family:tools tools/* substrate:sandbox Tool substrate: agent isolation, egress control, settings audit

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant