codex - 💡(How to fix) Fix Treat git global pager options as unsafe for auto-approval

Official PRs (…)
ON THIS PAGE

Recommended Tools

×6

Utilities matched from this issue’s tags and category — try them while you read without losing context.

GitHub issue graph ai analysis

Paste a GitHub issue URL. We fetch that issue, discover linked issues from bodies/comments/timeline, collect linked pull requests, and produce a structured English report.

The report is written in English Markdown for sharing and archival.

Helpful · Quick feedback

Loading…

Root Cause

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.

Fix Action

Fix / Workaround

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.

RAW_BUFFERClick to expand / collapse

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

extent analysis

TL;DR

Reject pager-forcing options when they appear before the matched git subcommand to maintain the security of read-only git commands.

Guidance

  • Update the codex-shell-command to distinguish between pager-forcing global options and normal read-only git output flags.
  • Implement a position-aware check to allow -p as a subcommand flag (e.g., git log -p) while rejecting it as a global option (e.g., git -p status).
  • Ensure the check covers both direct argv and parsed bash -lc invocations to handle different command formats.
  • Review the suggested fix in the provided GitHub comparison to understand the proposed changes.

Example

No code snippet is provided as the issue does not contain explicit code, but the suggested fix link offers a comparison of the proposed changes.

Notes

The current implementation may not cover all edge cases, and the suggested fix aims to address the specific vulnerability related to pager-forcing options. Further testing and review may be necessary to ensure the updated codex-shell-command handles all possible command formats and options correctly.

Recommendation

Apply the workaround by implementing the position-aware check for pager-forcing options, as it directly addresses the identified security concern and allows for the continued safe use of read-only git commands with specific flags like -p in subcommands.

Vote matrix · Quick signals

Works
Did the solution work? Tap to confirm.
Easy Fix
Was it a quick fix?
Time Saver
Did it save you time?
Blocking
Was it severely blocking?
Common Issue
Are others likely hitting this too?
Flaky / Intermittent
Is it intermittent?
Verified / Reproducible
Can you reproduce it reliably?
Loading…

Still need to ship something?

×6

Another batch ranked right after the header list — different links, same matching logic.

Back to top recommendations

TRENDING