Skip to content

Fix CrossVendorAudit codex invocation: non-git PAI dirs and OpenAI env overrides#1346

Open
lmbagley wants to merge 1 commit into
danielmiessler:mainfrom
lmbagley:fix/crossvendoraudit-nongit-cwd-env-scrub
Open

Fix CrossVendorAudit codex invocation: non-git PAI dirs and OpenAI env overrides#1346
lmbagley wants to merge 1 commit into
danielmiessler:mainfrom
lmbagley:fix/crossvendoraudit-nongit-cwd-env-scrub

Conversation

@lmbagley

@lmbagley lmbagley commented Jun 12, 2026

Copy link
Copy Markdown

Problem

CrossVendorAudit.ts (the Cato cross-vendor audit harness) has two failure modes in invokeCodex():

  1. Audit always skips on non-git PAI installs. codex exec refuses to run when the working directory is not a git repository (Not inside a trusted directory), so on installs that persist the PAI directory by means other than git, every audit returns skipped: codex exit 1 and the cross-vendor audit never actually fires.

  2. Silent auth flip. The spawned codex process inherits the parent environment, and codex's auth precedence puts OPENAI_API_KEY / OPENAI_BASE_URL above ~/.codex/auth.json and config.toml. A stray key in the parent shell silently moves the audit from the user's configured codex auth (e.g. ChatGPT subscription) to direct API billing, with no signal that it happened.

Fix

  • Pass --skip-git-repo-check to codex exec (the read-only sandbox is still enforced by --sandbox read-only).
  • Copy the env and delete OPENAI_API_KEY / OPENAI_BASE_URL before spawn — only when ~/.codex/auth.json exists, so users who authenticate codex solely via the env var keep working unchanged; users with configured auth stop being silently overridden by stray shell keys.

Testing

Verified live on a non-git PAI install: the audit runs end-to-end and persists a structured verdict to cato-findings.jsonl where it previously logged skipped: codex exit 1. bun build passes on the patched file.

Note for maintainers

The change targets Releases/v5.0.0/ because a tree-wide search shows it is the only place this file ships — happy to retarget if release snapshots are frozen and there's a development home for it.

…v overrides

Two failure modes in invokeCodex():

1. codex exec refuses to run when the working directory is not a git
   repository ('Not inside a trusted directory'), so the cross-vendor
   audit always returns skipped on installs that persist the PAI
   directory by means other than git. Pass --skip-git-repo-check.

2. The spawned codex process inherits the parent environment, and
   codex's auth precedence puts OPENAI_API_KEY / OPENAI_BASE_URL above
   ~/.codex/auth.json and config.toml. A stray key in the parent shell
   silently flips the audit from the user's configured codex auth
   (e.g. ChatGPT subscription) to direct API billing. Scrub both vars
   from the child env.

Verified live on a non-git PAI install: audit runs end-to-end and
persists a structured verdict where it previously logged
'skipped: codex exit 1'.
@lmbagley lmbagley force-pushed the fix/crossvendoraudit-nongit-cwd-env-scrub branch from 02b005e to 17edbd4 Compare June 12, 2026 15:04
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