7[CLI quickstart](https://learn.chatgpt.com/docs/security/cli).7[CLI quickstart](https://learn.chatgpt.com/docs/security/cli).
8 8
9The `@openai/codex-security` package is public. Running scans requires Codex9The `@openai/codex-security` package is public. Running scans requires Codex
10 Security access.10 Security access. Scans use your local permissions and don't pause for
11 approval. Before you start, review [Local scan
12 permissions](#local-scan-permissions).
11 13
12Run the CLI with `npx @openai/codex-security`.14Run the CLI with `npx @openai/codex-security`.
13 15
113 [--post-scan-prompt-file FILE]115 [--post-scan-prompt-file FILE]
114 [--mode {standard,deep}] [--workers N]116 [--mode {standard,deep}] [--workers N]
115 [--subagents N] [--stop-after-no-new N]117 [--subagents N] [--stop-after-no-new N]
116 [--max-discovery-runs N] [--model MODEL]118 [--max-discovery-runs N] [--max-time-hours HOURS]
119 [--model MODEL]
117 [--effort {minimal,low,medium,high,xhigh}]120 [--effort {minimal,low,medium,high,xhigh}]
118 [--output-dir DIR]121 [--output-dir DIR]
119 [--archive-existing]122 [--archive-existing]
249| `--subagents N` | Subagents available to each discovery worker. Defaults to `3`. |252| `--subagents N` | Subagents available to each discovery worker. Defaults to `3`. |
250| `--stop-after-no-new N` | Stop after `N` consecutive runs find no new issues. Defaults to `6`. |253| `--stop-after-no-new N` | Stop after `N` consecutive runs find no new issues. Defaults to `6`. |
251| `--max-discovery-runs N` | Limit on total discovery runs. Defaults to `60`. |254| `--max-discovery-runs N` | Limit on total discovery runs. Defaults to `60`. |
255| `--max-time-hours HOURS` | Discovery time limit in hours. Defaults to `96`; accepts fractions. |
252 256
253`--subagents` accepts zero or a positive integer. The other options require a257`--subagents` accepts zero or a positive integer. `--max-time-hours` accepts a
254positive integer. These options aren't available for standard scans.258positive number no greater than `96`. The remaining options require a positive
259integer. These options aren't available for standard scans.
255 260
256For example, limit a deep scan to two discovery workers and ten total runs:261For example, use two discovery workers, allow up to ten runs, and stop
262discovery after 1.5 hours:
257 263
258```bash264```bash
259npx @openai/codex-security scan . \265npx @openai/codex-security scan . \
261 --workers 2 \267 --workers 2 \
262 --subagents 0 \268 --subagents 0 \
263 --stop-after-no-new 3 \269 --stop-after-no-new 3 \
264 --max-discovery-runs 10270 --max-discovery-runs 10 \
271 --max-time-hours 1.5
265```272```
266 273
274The time limit applies only to discovery. When it expires, the scan stops
275unfinished discovery, keeps completed discovery results, and continues with
276validation and reporting. If no source review finishes, the scan records
277partial coverage and returns exit code `2`.
278
267Set persistent defaults in `~/.codex/codex-security/config.toml`, or in279Set persistent defaults in `~/.codex/codex-security/config.toml`, or in
268`$CODEX_HOME/codex-security/config.toml` when you set `CODEX_HOME`:280`$CODEX_HOME/codex-security/config.toml` when you set `CODEX_HOME`:
269 281
273subagents = 0285subagents = 0
274stop_after_no_new = 3286stop_after_no_new = 3
275max_discovery_runs = 10287max_discovery_runs = 10
288max_time_hours = 1.5
276```289```
277 290
278Command-line options override these defaults. `scan --workers` controls291Command-line options override these defaults. `scan --workers` controls
279discovery workers within one scan; `bulk-scan --workers` controls concurrent292discovery workers within one scan; `bulk-scan --workers` controls concurrent
280repository scans.293repository scans. Set `stop_after_consecutive_errors` only in the TOML file;
294its default is `3`.
281 295
282### Add security context296### Add security context
283 297
310 324
311For example, use the scan prompt to focus on authorization boundaries and ask325For example, use the scan prompt to focus on authorization boundaries and ask
312the follow-up to write a new `post-scan-summary.md` in the scan directory.326the follow-up to write a new `post-scan-summary.md` in the scan directory.
327If the follow-up fails, the CLI reports a warning and keeps the completed scan.
313The follow-up doesn't run after cancellation or when the scan reaches its cost328The follow-up doesn't run after cancellation or when the scan reaches its cost
314limit.329limit.
315 330
332| `--full-output` | Print the complete result using the default structured output format. |347| `--full-output` | Print the complete result using the default structured output format. |
333 348
334The cost limit is an estimate, not a hard spending cap. Requests already in349The cost limit is an estimate, not a hard spending cap. Requests already in
335progress can finish slightly above the limit. If a scan aborts due to the cost350progress can finish slightly above the limit. If a deep scan reaches the limit
336limit, partial scan results remain available on disk.351after discovery finishes, the CLI seals the available results, marks coverage
352as `partial`, and returns exit code `2`. Otherwise, it returns `2` and leaves
353any available partial output on disk.
337 354
338When you omit `--output-dir`, results persist under355When you omit `--output-dir`, results persist under
339`$CODEX_HOME/state/plugins/codex-security/scans/<repository>`. `CODEX_HOME`356`$CODEX_HOME/state/plugins/codex-security/scans/<repository>`. `CODEX_HOME`
530npx @openai/codex-security scans rerun SCAN_ID547npx @openai/codex-security scans rerun SCAN_ID
531```548```
532 549
550The rerun requires the plugin version recorded by the original scan. If the
551installed version differs, the command stops instead of running with a
552different plugin.
553
533### Inspect saved scan logs554### Inspect saved scan logs
534 555
535Read the complete saved session events for a scan and its workers:556Read the complete saved session events for a scan and its workers. These logs
557aren't redacted and can contain source code or credentials, so review them
558before sharing:
536 559
537```bash560```bash
538npx @openai/codex-security scans logs SCAN_ID561npx @openai/codex-security scans logs SCAN_ID
889write the available results to stdout. The CLI prints the location of any912write the available results to stdout. The CLI prints the location of any
890partial output after an interruption or runtime error.913partial output after an interruption or runtime error.
891 914
915## Local scan permissions
916
917CLI and SDK scans run with your local operating-system permissions. Every scan
918uses the `codex_security_scan` filesystem profile and sets `approvalPolicy` to
919`"never"`. The profile permits reading the local filesystem and writing to
920workspace roots and the selected scan state directory. Scans don't stop to
921request interactive approval.
922
923Settings supplied through CLI `--codex` or SDK `codexOverrides`, including
924`approval_policy`, `sandbox_mode`, and filesystem permissions, can't replace
925or restrict these scan controls. Host and network restrictions still apply.
926
927Scan and workbench processes can inherit your environment, including unrelated
928API tokens and cloud credentials. Scan only repositories you trust and have
929permission to assess, and provide only the credentials the scan requires.
930
892## Authentication and prerequisites931## Authentication and prerequisites
893 932
894Set `OPENAI_API_KEY` or `CODEX_API_KEY`, sign in with933Set `OPENAI_API_KEY` or `CODEX_API_KEY`, sign in with
902 941
903For CI, keep the API key scoped to the scan step and use a trusted workflow.942For CI, keep the API key scoped to the scan step and use a trusted workflow.
904 943
905The CLI requires Node.js 22.13.0 or later. Running a scan or exporting findings944The CLI requires Node.js 22 (22.13.0 or later), 24, or 26. Scans, bulk scans,
906also requires Python 3.10 or later. Python 3.10 also requires `tomli`. Use945exports, scan history, and saved findings also require Python 3.10 or later.
907`--python` or `PYTHON` to select an interpreter when automatic discovery is946Python 3.10 also requires `tomli`. Use `--python` with `scan`, `bulk-scan`, or
908unsuitable.947`export`, or set `PYTHON` for any Python-backed command.
909 948
910Continue with the [CLI quickstart](https://learn.chatgpt.com/docs/security/cli), [bulk-scan949Continue with the [CLI quickstart](https://learn.chatgpt.com/docs/security/cli), [bulk-scan
911guide](https://learn.chatgpt.com/docs/security/cli/bulk-scans), [CLI FAQ](https://learn.chatgpt.com/docs/security/cli/faq), [CI950guide](https://learn.chatgpt.com/docs/security/cli/bulk-scans), [CLI FAQ](https://learn.chatgpt.com/docs/security/cli/faq), [CI