@openai/codex-security
Scan a repository, selected paths, or Git changes for vulnerabilities. The CLI and TypeScript SDK can validate findings, generate patches, verify fixes, and export results as SARIF, JSON, or CSV. The package includes the Codex runtime and security plugin.
Install
Use Node.js 22.x (22.13.0 or later), 24.x, or 26.x on macOS, Linux, or Windows.
Scans also require Python 3.10 or later. On Python 3.10, install tomli.
Install the CLI
npm install --global @openai/codex-security
The CLI runs as cs or codex-security. To skip the global install, use
npx @openai/codex-security in place of cs in the examples below.
Install the TypeScript SDK
Install the package in your project directory.
npm install @openai/codex-security
Before 1.0, minor releases may change the public API.
Authentication
Run cs login to sign in with ChatGPT. With a local SDK installation, run
npx @openai/codex-security login from your project. In CI, set
OPENAI_API_KEY or CODEX_API_KEY in the scan environment.
Some requests require Trusted Access for Cyber.
CLI
Run a scan from the repository you want to review.
cs scan .
To scan only committed changes from origin/main to HEAD, run
cs scan . --diff origin/main. A completed scan exits with code 0 by default,
even when it finds vulnerabilities. Add --fail-on-severity high to exit with
code 1 for high or critical findings.
Assess dependencies
Install OSV-Scanner separately on PATH, then run:
cs scan dependencies . --max-cost 5
cs scan dependencies /path/to/repository --json
cs scan dependencies . --verbose
Omit the repository to assess the current directory. The command saves scanner
evidence, all advisory matches, static assessments, and a Markdown report outside
the repository. Completed runs return 0, including runs with advisory matches;
partial or failed runs return 2. Assessments never remove advisory matches.
Interactive terminals show the current phase, work counts, elapsed time, time
since the last observed event, and the current input or Codex activity. Use
--verbose for timestamped milestones in redirected logs, and --show-cost
for estimated model cost. Progress goes to stderr; JSON stays on stdout.
The SDK provides scanDependencies(). See the
dependency assessment guide for
supported inputs, settings, artifacts, and limitations. dependencies is now a
reserved scan command; use cs scan ./dependencies for a source scan of a
directory with that name.
Run a scan from TypeScript
Run this ES module from the repository you want to scan.
import { CodexSecurity } from "@openai/codex-security";
const security = new CodexSecurity();
try {
const result = await security.run(".");
console.log(result.reportPath);
console.log(`${result.findings.findings.length} findings`);
} finally {
await security.close();
}
Read results
By default, results are saved in the private Codex Security state directory.
Open the Markdown report at the CLI’s REPORT path or the SDK’s
result.reportPath. Reports and logs can contain source code, credentials, and
vulnerability details. Review them before sharing.
Local security model
Scans run with your operating-system permissions. Start them with only the credentials they need because subprocesses can inherit your environment.
Documentation and security
- CLI reference for scan options, authentication, and exports.
- SDK guide for configuration, progress events, and the full set of examples.
- Security policy for reporting vulnerabilities in this package privately.