Files
codex-security/README.md
T
ea617a4c09 fix(workbench): retain shared history across worktree changes (#456)
* fix(workbench): share scan history across linked worktrees

* fix(workbench): verify repository generation across platforms

* fix(workbench): harden and simplify worktree history

* fix(workbench): preserve recreated repository subdirectories

* fix(workbench): refresh the bundled history plugin

Advance the paired standalone plugin version so existing staged marketplaces load the linked-worktree history helpers. Leave the npm package release version unchanged.

* fix(workbench): verify saved history candidates

Use recorded checkout ownership before falling back to live repository identities. Preserve matching persisted identities for removed worktrees and retain verified same-origin comparisons.

* fix(workbench): unify verified repository history

* fix(workbench): preserve scan history ownership and replay

* fix(workbench): quarantine unproved prerelease identities

* fix(workbench): order automatic history comparisons

* fix(workbench): persist completion visibility order

* fix(workbench): preserve findings and Linux identities

* fix(workbench): preserve unbound legacy history

* Bind repository history to each scan generation

* Preserve archived scans across registration failures

* Bound repository identity maintenance to selected targets

* Repair legacy identity upgrades and precompute repository counts

* test(workbench): isolate directory metadata on Python 3.14

* fix(sdk): exclude internal helpers from public declarations

* test(workbench): send identity fixture through stdin

* fix(workbench): verify ownership before rejoining scans

* test(workbench): retain recreated fixture inodes

* test: align shared history fixtures with current schema

* test: include current migrations in repository identity upgrade checks

* Preserve owned legacy history and current rerun prompts

* Preserve repository history through validated saved matches

* Preserve timestamp and custom plugin history compatibility

* Preserve grouped history matching and mock output recovery

* Preserve grouped history matching and mock output recovery

* Preserve portable repository ownership and indexed history lookups

* Preserve legacy Git history and mixed filesystem comparisons

* Preserve legacy triage and registered linked-worktree comparison

* Keep legacy comparisons scoped and reuse repository history indexing

* Rank same-target feedback across legacy repository generations

* Keep legacy history local when matching current repository targets

* Preserve saved legacy aliases in linked comparison history

* Order combined feedback fixture imports

* Update completed findings fixture for combined migration history

* Align migration expectations and batch workflow condition fixtures

* Adapt archived-output callbacks to current observer helper

* Format archived-output observer callback

* Use the current historical migration fixture helper

* Preserve requested repository aliases through findings lookup

* Preserve local legacy decisions and requested scan aliases

* Support absolute paths in the Windows history fixture

* test: preserve Windows fixture identity and shell behavior

* fix(history): preserve accepted completion timestamp precision

* fix(workbench): replace reversed scan comparisons

* docs: make finding detail example explicitly synthetic

* test(workbench): follow shared scan allocation in identity fixture

* fix(workbench): preserve history across filesystem remounts

* test(workbench): align identity fixtures with migration semantics

* fix(workbench): preserve history across supported Python runtimes

* perf(workbench): paginate repository projections

* test(workbench): type repository page expectations

* fix(workbench): retain verified history after device changes

* test(workbench): supply archive defaults in lineage fixture

* fix(workbench): preserve composed remediation and writer fixtures

* Preserve caller scope and valid history during saved scan bootstrap

* Retain bound history after worktree paths are reused

* Use scan generations for history and live Git roots for interpreter protection

* Align schema and archive rollback fixtures with registration ordering

* Exclude saved checkouts from ambient Python discovery

* Isolate trusted Python from Git in history fixture

* Preserve base Python and packages in isolated history fixture

* test(findings): expect the requested repository alias

* fix(identity): avoid external stat and synchronous fixture timeouts

* fix(workbench): preserve historical target registration and migration

* fix(history): compare saved scan timestamps chronologically

* fix(sdk): trim saved scan timestamp fractions linearly

* Fix platform coverage in history migration fixtures

* fix(workbench): retain lexical roots during migration discovery

* test: preserve shared history across receipt migration

* test: align repository generation fixtures with merged migrations

* test(workbench): align identity migrations with issue receipts

* test(workbench): align history fixtures with current contracts

* test: run migration probes through Python runtime helpers

* Update generation migration fixtures for current schema

* test(workbench): align coordinator fixture with generation migration

* fix(workbench): keep Git discovery scoped across saved history

* fix(workbench): cover new and unavailable Git targets

* fix(workbench): expand incoming Git target paths

* docs: format shared scan history guidance

* fix(workbench): retain evidence of vanished Git targets

* test: exercise current repository generation migration

* fix: preserve Git discovery after incomplete workspace setup

* test: bind host Git in direct saved-history helpers

* fix(workbench): retain all scan feedback and register fixture targets

* fix(workbench): preserve saved checkout boundaries during tool discovery

* test(plugin): restore checkout root column in legacy migration fixture

* fix(plugin): require recorded checkout roots for legacy Git discovery

* fix(sdk): require saved checkout roots before tool discovery

* test(workbench): install the lifecycle view in the repository alias fixture

* fix(sdk): exclude rejected workspace paths from executable discovery

* fix(workbench): retain trusted Git for deleted bounded targets

* fix(workbench): disable ambient lookup for unanchored workspace paths

* fix(workbench): retain checkout boundaries for rejected workspaces

* test(workbench): use the complete schema in Python migration fixtures

* Retain rejected checkout exclusions after workspace correction

* Classify the quota error in the comparison stop test

* Update workbench identity fixtures with the object-store birth time

* Exercise repository generation upgrades and Windows owner rejection after renumbering

* Drop the stale retry assignment after archive acknowledgement

* Start the Windows archive attempt when the real patch write opens

* Exercise repository history with the current registration and schema

* Keep workbench identity test outputs in private temporary directories

* test: verify current and stale checkout ownership independently

* fix(history): validate native parent traversal before lookup

* Cover partially sequenced completion history on migration replay

---------

Co-authored-by: mldangelo-oai <269034524+mldangelo-oai@users.noreply.github.com>
Co-authored-by: Codex <codex@users.noreply.github.com>
2026-11-11 04:46:42 -08:00

9.6 KiB

Codex Security

Codex Security helps you find, investigate, and fix vulnerabilities in your code. Use its security workflows in Codex, or automate them with the @openai/codex-security CLI and TypeScript SDK.

Features

  • Scan repositories, selected paths, or Git changes. Deep scans repeat Standard scans and return their deduplicated findings.
  • Validate candidate findings, generate patches, and verify existing fixes.
  • Draft SECURITY.md policies and save threat models for later review.
  • Browse saved scans and findings, identify duplicates, assess severity against your own rubric, and suggest owners from source and Git history.
  • Preview third-party scanner findings, save them locally, or publish supported reports to Codex Security Cloud. Scanner import guides.
  • Track findings in Linear, Jira, or GitHub, publish completed scans, or export SARIF, JSON, and CSV. Integration workflows.
  • Automate scans across repositories or project components, including in CI and containers.

Use in Codex

Open your repository in a Codex session with the Codex Security plugin enabled, then ask:

Run a Codex Security scan on this repository, focusing on authentication and authorization. Return the saved report, source evidence, and coverage limits.

A completed scan saves a report and findings. Read the report for source evidence and exclusions, then request a patch or ask Codex to verify an existing fix. See the agent workflow guide for setup, task selection, and recovery.

Quick start

Requires Node.js 22.13.0+ within 22.x, or Node.js 24.x or 26.x, and Python 3.10+. Python 3.10 also requires tomli.

Install the CLI globally and sign in:

npm install --global @openai/codex-security
cs login

Run your first scan from the repository directory:

cs scan .

When the scan completes, open the Markdown file at the REPORT path in the terminal. Run cs scans show from the same repository to find its latest completed scan again. See scan scope and follow-up work for how to interpret exclusions in the report.

cs and codex-security run the same CLI. If the short name conflicts with another command, use codex-security. To skip the global install, or if npm reports an EEXIST conflict, use npx @openai/codex-security in place of cs for both login and scanning.

For CI, set OPENAI_API_KEY or CODEX_API_KEY in the scan process's environment. For a headless machine, see device or SSH login.

Scan options

Choose a scope and scan mode:

# Scan selected paths.
cs scan . --path src --path tests

# Scan committed changes from a base revision to HEAD.
cs scan . --diff origin/main

# Run a deep scan of the repository.
cs scan . --mode deep

Use cs scan . --max-time 15 for an advisory 15-minute Standard investigation allowance. See investigation time for timing semantics and Deep Scan limits.

Use cs --help to browse commands, or cs scan --help for scan options, cost limits, and patching after a scan.

For an application spread across repositories, see review one system across repositories. Use bulk scans for independent repository reviews in one resumable campaign.

Scans use existing root and component SECURITY.md guidance. To write or revise it, see Generate SECURITY.md.

Some cybersecurity requests and protected findings require Trusted Access for Cyber. For accounts with Daybreak access, see Daybreak opt-in for the Codex toggle and Cyber access programs to select a program explicitly.

TypeScript SDK

Install the package locally in your TypeScript project:

npm install @openai/codex-security

Then import it:

import { CodexSecurity } from "@openai/codex-security";

const security = new CodexSecurity();

try {
  const result = await security.run("/path/to/repository");
  console.log(result.reportPath);
} finally {
  await security.close();
}

The SDK guide includes deep-scan configuration, validation, severity classification, owner suggestions, and result handling.

Linked Git worktrees share scan history and saved findings when they use the same Codex Security state directory. Keep CODEX_SECURITY_STATE_DIR stable to retain that shared history and sign-in scope. See the scan history guide.

Read existing Cloud findings

When Codex Security Cloud is available to your account, the Security plugin's $cloud-findings skill can read findings, reports, recorded assignment and verification, and scan status in Codex desktop or the Codex CLI. Cloud is an optional connection; local scans work without it.

See Cloud connection setup and CLI reads for authentication requirements and a read-only example.

Generate SECURITY.md

Use policy to draft a new SECURITY.md or update an existing one. Use --path to select a component:

cs policy .
cs policy . --path services/api --knowledge-base architecture.md

The command saves its draft outside the repository and leaves existing files unchanged. Review the diff and notes, edit the draft, then copy only SECURITY.md to the displayed Policy target. Keep the saved architecture and threat-model documents outside the repository.

Scans already use root and component SECURITY.md files. Keep your current policy if it needs no changes. When updating it, preserve its vulnerability-reporting instructions. If the command says the policy is already up to date, no copy is needed.

Files at .github/SECURITY.md or docs/SECURITY.md often contain reporting instructions. Preserve them when drafting a policy; those locations do not automatically provide repository-wide scan guidance. See the policy guide for policy locations, unanswered questions, saved artifacts, and SDK usage.

Save and export threat models

Scans and policy generation save threat models with their results. Export a saved model without starting another analysis:

cs export --scan SCAN_ID --artifact threat-model --output threatmodel.md

Omit --scan to use the current repository's latest completed scan. The export guide also covers findings, SARIF output for CI, and the offline TypeScript API. For ServiceNow Application Vulnerability Response, see Export findings for ServiceNow.

GitHub Actions

To run a weekly repository scan on GitHub-hosted Ubuntu:

  1. Add an OpenAI API key as the repository secret CODEX_SECURITY_API_KEY.
  2. Copy the weekly workflow to .github/workflows/codex-security.yml. Replace REPLACE_WITH_REVIEWED_COMMIT with the reviewed distribution commit SHA from an Action release.
  3. To try the workflow before the next scheduled run, open Actions → Codex Security repository → Run workflow.

The example uses an estimated $5 limit per scan and reports findings without failing the job. Requests in progress can exceed the limit. For a severity threshold, pull request checks, or runner requirements, see the Action guide. For eligible accounts, see Daybreak access.

Containerized bulk scans

Scan a list of repositories with the included Docker Compose configuration, which keeps results and authentication between runs. See the container quick start. The workflow runner runs individual CLI stages in containers and can connect to a separately deployed findings service.

Findings storage and deduplication

The findings guide covers local storage, deduplication, and compatibility with independently operated endpoints through publish scan --to custom and explicit --findings-url. The local serve command and browser dashboard have been removed; existing databases and scan artifacts remain available.

Other providers

Scans support OpenAI, Amazon Bedrock, OpenRouter, Fireworks AI, and Cheaper Inference. Bedrock uses AWS credentials and does not require a separate OpenAI login. See Bedrock setup for AWS profiles, regions, and model access.

For OpenRouter, Fireworks AI, and Cheaper Inference, set the provider's API key and choose a supported model. See provider configuration for examples.

Documentation

To report a vulnerability privately, follow the security policy.