@openai/codex-security is a CLI and TypeScript SDK for finding, validating, and
fixing security vulnerabilities in your code.
- Scan repositories, selected paths, or Git changes. Deep scans run parallel discovery workers on repositories and selected paths.
- Validate candidate findings, generate patches, and verify existing fixes.
- Draft
SECURITY.mdpolicies 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.
- Import GitHub code scanning alerts, export SARIF, JSON, or CSV, and publish findings to Linear or a findings service.
- Automate scans across repositories or project components, including in CI and containers.
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 logincs is a short alias for codex-security; both commands run the same CLI.
The installation creates both commands in npm's global executable directory,
which must be on your PATH. If cs already resolves to another tool, use
codex-security instead. If npm stops with an EEXIST error for cs, use
npx @openai/codex-security without a global installation.
From your repository directory, optionally draft security guidance before your first scan:
cs policy .The command saves a draft outside the checkout. Review the proposed diff and
notes, edit the draft as needed, then copy it to the displayed Policy target
so future scans use it. Generating the draft alone does not install it.
Skip this step to keep an existing policy or scan without one.
Run your scan from the repository directory:
cs scan .If you have Daybreak Blue access, add --cyber-access-program daybreak_blue
to the scan command. Otherwise, omit the flag or use
--cyber-access-program standard.
To run without a global installation, replace cs in these examples with
npx @openai/codex-security, for example:
npx @openai/codex-security scan .For CI, set OPENAI_API_KEY or CODEX_API_KEY in the scan process's environment.
On remote or headless machines, use login --device-auth if your workspace
allows it, or sign in over SSH.
Some cybersecurity requests and protected findings require Trusted Access for Cyber approval.
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 deepUse cs --help to browse commands, or cs scan --help
for scan options, cost limits, and patching after a scan.
Install the package locally in your TypeScript project:
npm install @openai/codex-securityThen 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.
Draft security guidance for a repository or one of its components:
cs policy .
cs policy . --path services/api --knowledge-base architecture.mdThe command saves a draft outside the checkout. Review it before installing it as guidance for future scans. See the policy guide for supporting documents and SDK usage.
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.mdOmit --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.
Run scheduled, manual, or pull request scans with the GitHub Action. For a weekly
repository scan, add an OpenAI API key as the repository secret
CODEX_SECURITY_API_KEY, then save this workflow in
.github/workflows/codex-security.yml. Replace REPLACE_WITH_REVIEWED_COMMIT
with the full SHA of an Action commit.
This workflow requests Daybreak Blue. Use an API key from a project with Blue
enabled; without Daybreak access, omit cyber-access-program or set it to
standard.
name: Codex Security
on:
workflow_dispatch:
schedule:
- cron: "23 7 * * 1" # Mondays at 07:23 UTC
permissions:
contents: read
jobs:
security:
runs-on: ubuntu-24.04
steps:
# Configure Bubblewrap and AppArmor so Codex Security can run safely in its sandbox.
- name: Set up the Ubuntu sandbox
run: |
sudo apt-get update
sudo apt-get install --yes bubblewrap apparmor-profiles
sudo apparmor_parser -r /usr/share/apparmor/extra-profiles/bwrap-userns-restrict
- uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
with:
persist-credentials: false
- uses: openai/codex-security@REPLACE_WITH_REVIEWED_COMMIT
with:
model: gpt-5.6-sol
effort: high
cyber-access-program: daybreak_blue
env:
OPENAI_API_KEY: ${{ secrets.CODEX_SECURITY_API_KEY }}Findings are report-only by default. Partial scans with valid results produce a warning; scanner and required reporting errors fail the job. Severity thresholds apply to complete scans. See the Action setup and input reference for PR scans, severity thresholds, and report uploads.
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.
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.
Scans support OpenAI, Amazon Bedrock, OpenRouter, and Fireworks AI. Bedrock uses AWS credentials and does not require a separate OpenAI login. See Bedrock setup for AWS profiles, regions, and model access.
For OpenRouter and Fireworks AI, set the provider's API key and choose a supported model. See provider configuration for examples.
To report a vulnerability privately, follow the security policy.