OpenAI Codex Security CLI in CI: the 2026 setup and the gated-engine catch

OpenAI's Codex Security CLI is open source but the engine is gated and metered. Setup, CI exit codes, and how it compares to Semgrep, CodeQL and Snyk in 2026.

Read time
12 min
Word count
1.9K
Sections
12
FAQs
7
Share
Editorial hero on OpenAI Codex Security CLI in CI for 2026
OpenAI's Codex Security CLI: an open client on a gated, metered engine.
On this page · 12 sections
  1. What OpenAI actually shipped
  2. Open wrapper, gated engine
  3. Install and run your first scan
  4. Wire it into CI
  5. How the scan works
  6. Codex Security vs Semgrep vs CodeQL vs Snyk
  7. The cost model is the real catch
  8. Where it fits
  9. India-specific considerations
  10. FAQ
  11. How eCorpIT can help
  12. References

Summary. OpenAI open-sourced the Codex Security CLI and TypeScript SDK on 29 July 2026 under an Apache-2.0 licence, as the public npm package @openai/codex-security. The tool scans a repository, validates each finding, and drafts a patch, and it slots into CI with proper exit codes and SARIF output. The catch is in the engine. The client is open, but it only runs by calling OpenAI's hosted models, defaulting to gpt-5.6-sol at extra-high reasoning, and access to the full managed scanner reportedly remains a limited beta for approved customers. The product began inside OpenAI as "Aardvark," shipped as a research preview in March 2026, and by April had helped fix more than 3,000 critical vulnerabilities on OpenAI's own figures. It needs Node.js 22 or later and Python 3.10 or later to scan. This guide covers what you can run today, how to wire it into a pipeline, and where it sits next to Semgrep at about $30 per contributor per month, CodeQL, and Snyk at about $25 per developer per month.

What OpenAI actually shipped

The release is a command-line tool and a TypeScript SDK, not a model. The README describes Codex Security as "an open-source CLI and TypeScript SDK for finding, validating, and reviewing security issues in code you own or have permission to assess." The package follows semantic versioning and warns that its public API may change before version 1.0.0, so treat it as early software.

The distribution is the real story. OpenAI dropped this into the same terminal where its Codex agent already runs, and Codex passed 5 million weekly users in June 2026. That points the tool straight at Snyk, Semgrep, and Veracode, at GitHub's own fix suggestions, and at Anthropic's Claude Security, which does a similar scan-and-patch job. When the default install path for a security scanner is one npm command inside an editor five million developers already open, distribution, not detection, is the competitive lever.

Open wrapper, gated engine

The "open source" label needs an asterisk, and it is the first thing to understand before you plan a rollout. The CLI and SDK code are public under Apache-2.0. The intelligence is not. Every scan calls OpenAI's hosted models, and the README is explicit that you must "sign in with your OpenAI account or provide an OpenAI API key before running a scan." As TheNextWeb's Ana Maria Constantin described it, the release is "open plumbing bolted to a gated engine." Per the same report, access to the underlying managed scanner remains a limited beta for approved customers, and any generated patch still needs a human to sign off.

For a buyer, that has three consequences. You cannot self-host the detection logic or run it air-gapped, because the analysis happens in OpenAI's cloud. Your source code, or the slices the agent reads, leaves your network on every scan. And your cost is metered per token rather than fixed per seat, which changes the budgeting model entirely. None of that makes the tool bad. It makes it a hosted service with an open client, and it should be evaluated as one.

Install and run your first scan

The install path is short. You need Node.js 22 or later on macOS, Linux, or Windows, and Python 3.10 or later for scanning and exporting findings. Python is not required just to install the package or print --help.


            npm install @openai/codex-security
npx codex-security login
npx codex-security scan /path/to/repo
          

On a headless box, authenticate with npx codex-security login --device-auth and open the printed verification URL. For unattended runs, set OPENAI_API_KEY or CODEX_API_KEY through your shell, CI secret, or secret manager. An environment key takes precedence over a stored sign-in.

The scan is report-only by default. Useful flags include --diff origin/main to scan only what changed, --path src to narrow the target, --json for machine-readable output, and --knowledge-base ./threat-models to feed the agent your architecture notes and threat models as Markdown, text, PDF, or Word files. Results must be written outside the repository with --output-dir, and on macOS or Linux that directory must be private to your user at chmod 700, because scan artifacts contain source excerpts and reproduction steps.

By default the CLI uses gpt-5.6-sol with extra-high reasoning effort. You can trade depth for cost with a lighter model:


            npx codex-security scan . --model gpt-5.6-terra --codex 'model_reasoning_effort="high"'
          

Wire it into CI

The CLI is built for pipelines. It exits 0 on a completed report-only scan or a passing policy, 1 on a completed policy violation, 2 on invalid input, incomplete coverage, or a runtime error, 130 on interruption, and 143 on termination. That exit-code contract is what lets you fail a build deterministically. The README's own CI pattern scans the pull-request diff, writes findings outside the checkout, and blocks on high severity:


            SCAN_ROOT="$(mktemp -d)"
npx codex-security scan . \
  --diff origin/main \
  --output-dir "$SCAN_ROOT/results" \
  --json \
  --fail-on-severity high > "$SCAN_ROOT/findings.json"
          

For GitHub Actions, store the key as a repository secret and reference it in the job, check out the code before the scan, and keep the output directory outside the working tree. Codex Security can emit SARIF with export --export-format sarif, written to <scan-dir>/exports/results.sarif, which uploads into GitHub code scanning like any other SARIF producer. A pre-commit path exists too: npx codex-security install-hook scans staged and unstaged changes before each commit and blocks high-severity findings, respecting core.hooksPath and leaving an existing hook in place.

For fleet-wide runs, bulk-scan discovers repositories pushed in the last 90 days through your GitHub CLI sign-in, or takes a CSV of id, repository, and immutable revision columns. A hardened Docker image runs those bulk scans noninteractively, dropping all Linux capabilities, setting no-new-privileges, running as a nonroot user, and applying a default-deny seccomp profile, with each scan in a separate unprivileged sandbox. Full-repository scans can take tens of minutes each at the default extra-high reasoning setting, so run large campaigns as asynchronous batch jobs.

How the scan works

OpenAI frames the workflow in three stages: identification, validation, and remediation. In identification, the agent reads the repository and explores realistic attack paths rather than matching fixed patterns. In validation, it attempts to reproduce each candidate issue to confirm it is real before reporting it, which is the step aimed at the false-positive problem that plagues traditional static analysis. In remediation, it drafts a concrete patch a team can review and raise into a pull request. The CLI surfaces its ranking, file-review, validation, and attack-path phases as it runs, and records false-positive feedback so repeat scans improve. Findings persist in a local workbench database, and scans compare labels each finding across two runs as new, persisting, reopened, or resolved, which is how you track drift over time.

Codex Security vs Semgrep vs CodeQL vs Snyk

The incumbents price by seat and mostly let you run the engine yourself. Codex Security prices by token and does not. That single difference drives most of the trade-off.

Vector Codex Security Semgrep CodeQL Snyk
Tool licence Apache-2.0 (CLI and SDK) LGPL CE plus commercial Free for open source; commercial via GitHub Advanced Security Commercial
Engine Gated OpenAI models, default gpt-5.6-sol Rules plus Pro Engine cross-file Semantic QL queries Proprietary Snyk Code
Cost model Metered API tokens Per contributor Per committer Per developer
Indicative 2026 price gpt-5.6-sol at $5 in and $30 out per 1M tokens ~$30 per contributor per month ~$30 per committer per month ~$25 per developer per month, 5 to 10 devs
Self-host the engine No Yes Yes No
CI integration GitHub Action, exit codes, SARIF Yes Yes Yes
Autofix AI patch with human sign-off Limited autofix Copilot Autofix Snyk fixes

On raw detection, the older engines are proven. On the OWASP Benchmark, CodeQL posts a higher F1 score than Semgrep, about 74.4% against 69.4%, with the caveat that the academic test used Semgrep's open-source edition rather than the commercial Pro Engine with cross-file analysis, so the real gap is narrower. Semgrep beats Snyk on SAST in independent testing, and for deep taint analysis dedicated engines like Semgrep or Checkmarx return more complete results. Codex Security has no comparable public benchmark yet, so its accuracy claim rests on OpenAI's own 3,000-vulnerability figure from the Aardvark preview, not third-party numbers.

The cost model is the real catch

A per-seat SAST licence is predictable: Semgrep at roughly $30 per contributor per month, or Semgrep's full stack of Code, Supply Chain, and Secrets at $30 plus $30 plus $15, which is $75 per contributor per month. Snyk's Team tier runs about $25 per contributing developer per month with a 5-developer minimum and a 10-developer cap, and moving past 10 developers raises the per-seat cost. You know the bill in advance.

Codex Security replaces that with token metering. The default gpt-5.6-sol model costs $5 per 1M input tokens and $30 per 1M output tokens, and a full-repository scan at extra-high reasoning takes tens of minutes and consumes a large, variable number of tokens per repository. For a monorepo scanned on every pull request, that is an open-ended line item, not a fixed one. The lever is the model flag: dropping to gpt-5.6-terra or a lower reasoning effort cuts cost per scan, and scanning the diff rather than the whole tree cuts it further. Budget this like inference spend on an AI agent, not like a software licence, and put a policy on which branches trigger a full scan.

Where it fits

Codex Security is strongest as a second pair of eyes on changed code, not as the system of record for every rule your auditors expect. Use it on pull-request diffs to catch logic-level flaws and to draft patches, keep a deterministic engine like Semgrep or CodeQL as the gate that must pass, and let the AI tool add validated findings and fix suggestions on top. It reads like the pattern for AI coding agent harnesses such as the Codex CLI: powerful inside a bounded, reviewed workflow, risky as an unattended autopilot. Treat every generated patch as a proposal that a human reviews, exactly as OpenAI requires, and apply the same guardrails you would for any AI agent security setup, because the scanner reads your source and runs untrusted analysis on it.

For teams standardising on GitHub-native scanning, our walkthrough of CodeQL AI code scanning setup pairs well with this as the deterministic baseline, and the broader picture of running these agents in production sits in our guide to enterprise AI agents in production. If your supply chain is the exposure, combine it with MCP server hardening.

India-specific considerations

The gated-engine design has a data-governance edge that matters more for Indian teams handling regulated data. Because the analysis runs in OpenAI's cloud, source code, or the portions the agent reads, leaves your network on every scan. Where that code embeds personal data, secrets tied to personal data, or regulated financial logic, the Digital Personal Data Protection Act 2023 (DPDP) obligations on cross-border processing and purpose limitation apply to that transfer, and a per-token security scan does not remove them. For a BFSI or health workload, a self-hostable engine like Semgrep or CodeQL keeps analysis inside your boundary, while Codex Security should be scoped to repositories where sending code to a third-party model is contractually cleared. Decide the boundary first, then choose the tool that respects it.

FAQ

How eCorpIT can help

eCorpIT wires AI and traditional code scanning into CI/CD pipelines that fail builds on real risk without drowning teams in noise. We set up the exit-code policies, SARIF uploads, and branch rules that make a tool like Codex Security useful, keep a deterministic engine as the gate, and scope where source code may leave your network so a scan does not breach a data agreement. Our senior engineering teams, certified to CMMI Level 5 and ISO 27001:2022, design secure AI-assisted development workflows aligned with DPDP requirements. To harden your pipeline, contact eCorpIT.

References

  1. OpenAI, codex-security repository and README (GitHub)
  1. TheNextWeb, OpenAI open-sources Codex Security but gates the scanner
  1. OpenAI developers, Codex Security overview
  1. npm, @openai/codex-security package
  1. OpenAI Developer Community, introducing the open-source Codex Security CLI
  1. gbhackers, OpenAI open-sources Codex Security CLI to find, validate, and fix vulnerabilities
  1. CyberSecurityNews, OpenAI open-sources Codex Security CLI
  1. Learn ChatGPT, Codex Security CLI quickstart
  1. Augment Code, 8 AI SAST tools for 2026 tested and compared
  1. Konvu, Semgrep vs CodeQL 2026 technical comparison
  1. AppSecSanta, Semgrep vs Snyk 2026
  1. Vendr, Semgrep software pricing and plans 2026
  1. aipricing.guru, GPT-5.6 pricing July 2026 (Sol, Terra, Luna)
  1. OpenAI, GPT-5.6

_Last updated: 1 August 2026._

Frequently asked

Quick answers.

01 Is the OpenAI Codex Security CLI really open source?
The CLI and TypeScript SDK are open source under Apache-2.0, published as @openai/codex-security. The engine is not. Every scan calls OpenAI's hosted models and needs an OpenAI account or API key, and access to the full managed scanner reportedly remains a limited beta. TheNextWeb called it open plumbing bolted to a gated engine.
02 What do I need to run a scan?
Node.js 22 or later on macOS, Linux, or Windows, plus Python 3.10 or later to scan and export findings. Python is not needed just to install the package or print help. You also need an OpenAI account or an OPENAI_API_KEY or CODEX_API_KEY, because the analysis runs on OpenAI's hosted models, not locally.
03 How does it fail a CI build?
Run the scan with --fail-on-severity high and it exits 1 when a completed scan contains a finding at or above that severity. Exit codes are 0 for a passing report-only scan, 1 for a policy violation, 2 for invalid input or incomplete coverage, 130 for interruption, and 143 for termination, so pipelines can branch deterministically.
04 How much does Codex Security cost to run?
There is no per-seat fee; you pay OpenAI API tokens. The default gpt-5.6-sol model costs $5 per 1M input and $30 per 1M output, and a full-repository scan at extra-high reasoning takes tens of minutes and a variable token count. Scan diffs and use a lighter model to control the bill.
05 How does it compare to Semgrep and CodeQL on accuracy?
Semgrep and CodeQL are proven, with CodeQL scoring about 74.4% F1 on the OWASP Benchmark versus Semgrep's 69.4%, though that test used Semgrep's open edition. Codex Security has no comparable third-party benchmark yet, so its case rests on OpenAI's own figure of 3,000-plus fixed vulnerabilities from the Aardvark preview.
06 Can I self-host it for regulated code?
No. The detection runs in OpenAI's cloud, so source code leaves your network on every scan. For workloads under DPDP or similar rules, a self-hostable engine such as Semgrep or CodeQL keeps analysis inside your boundary. Scope Codex Security to repositories where sending code to a third-party model is contractually cleared.
07 Should it replace my existing SAST tool?
Not as the system of record. Use a deterministic engine like Semgrep or CodeQL as the gate that must pass, and add Codex Security on pull-request diffs for validated findings and draft patches. Its validation step targets false positives, but every patch needs human review before it lands.

About the author

Manu Shukla

Founder & Director

Founder of eCorpIT. Hands-on engineer leading senior-only delivery for AI apps, custom software, and cloud systems for global clients.

Subscribe

One engineering note a week. No fluff, no spam.

Senior-architect playbooks on AI agents, mobile apps, cloud, security, data, and marketing — delivered every Wednesday.

Past the reading

Read enough. Let's build something.

A senior architect responds in 24 working hours with scope, indicative cost, and a timeline. NDA before any technical conversation.