openai / openai/codex-security

scans rerun ignores --json/--format and can block on the interactive credential prompt

Open Beginner friendly
#39 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

area:auth area:cli bug priority:p2
Dominant language
TypeScript
Stars
10.8k
Forks
801
Avg merge
1d 8h
Merged PRs (30d)
257

Description

Summary

scans rerun calls runScan without forwarding the output format, so it always runs with interactive = true. With --json or --format jsonl it can therefore block on the interactive credential-selection prompt that the scan command explicitly suppresses in the same situation.

The rerun path omits the fourth argument, taking the interactive = true default:

https://github.com/openai/codex-security/blob/f22d4a36f26d16287bcdfd707b369116e02a08c3/sdk/typescript/src/cli.ts#L730

while scan computes it from the requested format:

https://github.com/openai/codex-security/blob/f22d4a36f26d16287bcdfd707b369116e02a08c3/sdk/typescript/src/cli.ts#L989

interactive is what gates the account-selection prompt and the TTY progress rendering.

Affected version and environment

  • Released package: @openai/codex-security@0.1.1
  • Confirmed on current main at f22d4a36f26d16287bcdfd707b369116e02a08c3
  • macOS 26.5.2 (build 25F84)
  • Node.js v24.5.0
  • Bun 1.3.14

Steps to reproduce

Preconditions matching the prompt's guard: stderr is a TTY, an environment API key is set, a stored ChatGPT sign-in exists, and no explicit --auth was passed.

Driving the real main() with the existing tests-ts/cli-fixtures.ts harness and an injected scanAuthenticationPrompt that records whether it was called:

const deps = {
  ...dependencies({ environment: { OPENAI_API_KEY: "SYNTHETIC_NOT_A_REAL_KEY" }, onWorkbench: () => ({ recipe }) }),
  hasStoredChatGPTSignIn: async () => true,
  scanAuthenticationPrompt: {
    isInteractive: () => true,
    select: async () => { prompted = true; return "chatgpt"; },
  },
};

await main(["scan", ".", "--json"], out, errTTY, deps);
await main(["scans", "rerun", "scan-original", "--json"], out, errTTY, deps);

Observed result:

$ codex-security scan . --json
   interactive credential prompt shown: false

$ codex-security scans rerun scan-original --json
   interactive credential prompt shown: true
   stderr contained: Both a ChatGPT sign-in and an API key from OPENAI_API_KEY are available.

Expected behavior

scans rerun should honour the same rule as scan: JSON and JSONL output never prompt. tests-ts/cli-authentication.test.ts already pins this for scan ("never prompts during automation"); the equivalent guarantee is missing for rerun.

Actual behavior

scans rerun <id> --json prompts for a credential choice and writes the prompt banner to stderr. In an automated context that keeps a pty attached, the command blocks waiting for input that will never arrive.

Impact

scans rerun is the documented way to re-check a fixed vulnerability, which makes it a natural fit for automation. A wrapper that runs it with --json and a pty can hang indefinitely rather than failing fast.

Related

The same missing plumbing means scans rerun <id> --format md is accepted, while scan --format md is rejected up front as unsupported. Forwarding the format to runScan would address both.

Suggested direction

Pass the computed interactivity through from the rerun command, mirroring the scan call site.

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start in sdk/typescript/src/cli.ts at the scans rerun call site and compare it with the scan path that computes interactivity from the requested format. Read tests-ts/cli-authentication.test.ts, then run the relevant CLI tests. Done means rerun with JSON and JSONL does not prompt, and its format handling matches scan.

Written by the indexing model from the issue text.

Assessment

Tech stack
node.js, typescript
Domain
authentication, cli, testing-qa
Issue type
Bug
Difficulty
2/5
Estimated time
1-3 hours
Activity status
Quiet
Clarity
Clearly specified
Newbie friendliness
84/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.