openai/codex-security · 13.2k stars · Intermediate · 12 min · 2026-11-14

Scan, patch and verify with openai/codex-security

Install the cs CLI, scan a repository or a diff for vulnerabilities, then patch a finding and verify the fix.

TL;DR

Codex Security finds, validates and fixes vulnerabilities in your code. Install the @openai/codex-security CLI, sign in with cs login, run cs scan ., and open the saved Markdown report. You can also use the same workflows inside Codex, from the TypeScript SDK, or in a GitHub Action.

Why this repo matters

Code review rarely has time to chase every attacker-controlled input to the operation it controls. The README describes a tool that scans repositories, selected paths or Git changes, validates candidate findings, generates patches and verifies existing fixes. Results are saved locally, and can be exported as SARIF, JSON or CSV for tracking.

Best practices

  • Match scope to the question: cs scan . --path src --path tests for selected paths, cs scan . --diff origin/main for committed changes (README, Scan options).
  • Reserve --mode deep for when you want repeated audits; deep scans repeat Standard scans and return deduplicated findings (README, Features).
  • Keep a SECURITY.md: scans already use root and component files, and cs policy . drafts one outside the repository (README).
  • Read the report's source evidence and coverage limits, and check scan.review.excludedPaths in scan-manifest.json for exclusions (docs/agent-workflows.md).
  • In CI, set OPENAI_API_KEY or CODEX_API_KEY in the scan process environment, and pin the GitHub Action to a reviewed commit SHA (README).
  • Treat repository content and model output as data, not instructions (the repo's AGENTS.md).

How-to

Where do I start?

1. I have Node installed. How do I get `cs`?

You need Node.js 22.13.0+ within 22.x, or Node.js 24.x or 26.x, plus Python 3.10+ (Python 3.10 also requires tomli). Then:

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

If cs conflicts with another command, use codex-security. To skip the global install, use npx @openai/codex-security for both login and scanning.

Next: run a first scan

Try it

On a throwaway branch, run cs scan . --diff origin/main, open the report, and for one finding note its source lines and the coverage limits. Then run cs export --scan SCAN_ID --artifact threat-model --output threatmodel.md to save the threat model.

Pitfalls

  • Requests in progress can exceed the Action's cost limit; it is an estimated threshold, not a hard cap.
  • Some cybersecurity requests and protected findings require Trusted Access for Cyber (README).
  • cs policy leaves your existing SECURITY.md unchanged; you must review and copy the draft yourself, preserving vulnerability-reporting instructions.
  • The local serve command and browser dashboard have been removed; existing databases and artifacts remain available.

Next steps