Playbooks · Coding tasks
Codex Security scans a repo and patches it
Written November 13, 2026
OpenAI's Codex Security finds vulnerabilities, validates them, writes patches and verifies the fix — from Codex, a CLI, an SDK, or Actions.
What it is
Codex Security is OpenAI's security scanner for code repositories, published as an open source project under the Apache-2.0 licence. The project README states its job in one line: it helps you find, investigate, and fix vulnerabilities in your code. The same scanning workflows run in four places — inside Codex itself, from a terminal CLI, through a TypeScript SDK, and as a GitHub Action — so a team can start interactively and move the same work into automation later.
The loop: scan, validate, patch, verify
Most scanners stop at a list of findings. This one is built as a loop with four steps:
- Scan. Point it at a whole repository, selected paths, or the changes in a Git diff. A deep scan repeats standard scans and returns their deduplicated findings.
- Validate. Candidate findings are validated before they are presented as real. A completed scan saves a report and findings, and the README tells you to read the report for source evidence and exclusions — what was looked at, and what the scan did not cover.
- Patch. For a finding that holds up, the tool generates a patch rather than leaving the fix as an exercise.
- Verify. It can verify an existing fix, so the same tool that raised the finding can confirm the change actually closes it.
Findings do not have to stay inside the tool. They can be tracked in Linear, Jira, or GitHub, and exported as SARIF, JSON, or CSV. The scanner can also draft a SECURITY.md policy and save threat models alongside scan results, and scans read existing SECURITY.md guidance when a repository already has one.
Install and first scan
The CLI needs Node.js 22.13.0 or later within the 22.x line, or Node.js 24.x or 26.x, plus Python 3.10 or later. Install it globally and sign in:
npm install --global @openai/codex-security
cs login
Then run a scan from the repository directory with cs scan . — the cs and codex-security commands are the same CLI, and npx @openai/codex-security works where a global install is not wanted. In CI, the scan process reads an OPENAI_API_KEY or CODEX_API_KEY from its environment. The repository's GitHub Actions material runs a weekly scan on GitHub-hosted Ubuntu, with the example workflow carrying an estimated $5 limit per scan and reporting findings without failing the job.
Ways to run a scan
The scan command takes a scope. cs scan . --path src --path tests scans selected paths. Adding --diff origin/main scans the committed changes from a base revision to HEAD, which is the shape a pull request review wants. --mode deep runs the deep scan, and --max-time 15 sets an advisory 15-minute allowance for a standard investigation. Inside Codex itself, the route is conversational: open the repository in a session with the Codex Security plugin enabled and ask for a scan — the README's example asks for one focused on authentication and authorization, returning the saved report, source evidence, and coverage limits.
For fleets rather than single repositories, the project ships a containerized bulk scan setup, driven by its included Docker Compose configuration, which keeps results and authentication between runs. Findings and threat models stay saved with each scan, and a saved threat model can be exported later without starting a new analysis.
Limits worth knowing
- Scans are not tied to OpenAI alone: the README lists Amazon Bedrock, OpenRouter, Fireworks AI, and Cheaper Inference as supported providers, with Bedrock using AWS credentials instead of an OpenAI login.
- Some cybersecurity requests and protected findings require Trusted Access for Cyber, OpenAI's access programme for this class of work. Not every account can run every scan.
- Reading Codex Security Cloud findings is an optional connection. Local scans work without it.
Related playbooks
- Codex Security 0.10.0: resume a scan, cap a batch
- OpenAI buys Pierre: Code Storage comes to Codex
- Foundry retires codex-mini on November 15
- ChatGPT and Codex share one token budget
Sources
Back to: Coding playbooks hub · Also: Codex Guardian v3: the evidence pipeline in 0.168 · Codex CLI 0.169: side-chat tabs in the terminal