Treat git global pager options as unsafe for auto-approval

Open 💬 0 comments Opened Apr 20, 2026 by funkypanda-glitch

What

codex-shell-command treats a narrow set of read-only git commands as known-safe so they can run without extra approval. The current git global-option guard catches config/repository/helper lookup overrides, but it does not distinguish pager-forcing global options such as git -p status or git --paginate show HEAD.

Why

Those forms are different from normal read-only git output flags because they can route command output through a configured pager. That makes them a poor fit for the known-safe allowlist, even though the underlying git subcommand (status, show, etc.) is read-only.

At the same time, -p is also a common read-only subcommand flag for commands such as git log -p, so the check should be position-aware rather than banning every -p argument.

Suggested fix

Keep git log -p and similar subcommand-level patch output safe, but reject pager-forcing options when they appear before the matched git subcommand. Cover both direct argv and parsed bash -lc invocations.

https://github.com/openai/codex/compare/main...funkypanda-glitch:codex/harden-git-pager-safety?expand=1

View original on GitHub ↗