Use cases · Codex

Security review with Codex: pull requests, local scans and CI

Codex Security reviews code for vulnerabilities and reports the evidence you need to investigate them. On GitHub, @codex security review checks a pull request, and Auto security review can run alongside code review. Locally, the Codex Security plugin scans a repository, and the @openai/codex-security CLI runs the same scans from a terminal or CI. This page covers each and the rules worth writing down.

What Codex does for security review

  • Checks each change for injection, missing authorization, exposed data and secrets in code before it merges.
  • Scans the whole repository on a schedule and reports findings with evidence, not bare warnings.
  • Turns confirmed findings into patches or issues, most severe first.
  • Checks a fix again to confirm it closes the hole.

Codex features for security review

FeatureWhat it doesHow to start
@codex security reviewPosts security findings on a pull request, with the full report in the Codex taskComment on the pull request
Auto security reviewReviews pull requests for vulnerabilities without being askedCodex settings, under Review security vulnerabilities
Codex Security pluginScans a local repository and keeps findings in the Security workbench/plugins in Codex, then install Codex Security
Codex Security CLIRepeatable scans from a terminal or CInpx @openai/codex-security scan

How to set up Codex for security review

  1. Connect the tools

    Use the plugin for your first local scan and the CLI for scripts and CI. Scans that use OpenAI's models need Codex Security access; sign in with your ChatGPT account, and keep the results outside the repository.

    # Sign in, then scan a repository; results go outside it
    npx @openai/codex-security login
    npx @openai/codex-security scan /path/to/repo \
      --auth chatgpt --output-dir /path/outside/repo/results
  2. Write the rules in AGENTS.md

    Codex reads AGENTS.md before any work: ~/.codex/AGENTS.md, then the files from the repository root down to the folder it's working in. Put the job's rules there, or in a skill under .agents/skills/ if they're long. See the AGENTS.md guide.

    ## Security review rules
    - Review every pull request that touches auth/, billing/ or SQL.
      Look for injection, missing authorization checks, secrets in
      code and data returned to the wrong user.
    - Rate each finding Critical, High, Medium or Low, with the
      file, the line and how it could be exploited.
    - Never run exploits against production or anything we don't
      own. Read the code and test locally.
    - Open fixes as pull requests; never push to main.
  3. Run it without the interactive interface

    codex exec runs one task and exits. Progress goes to stderr and the final message to stdout; -o also writes it to a file and --json streams events. The sandbox is read-only unless you pass --sandbox workspace-write.

    # A security pass on this branch, with your rules from AGENTS.md
    codex exec "Review this branch against main for security issues, following AGENTS.md"
    
    # A repository scan from CI, without the live dashboard
    npx @openai/codex-security scan "$REPOSITORY" --auth chatgpt \
      --output-dir "$SCAN_DIR" --headless
  4. Put it on a schedule

    Create a scheduled task in the ChatGPT desktop app or on the web (the CLI doesn't manage them), or run codex exec from cron. See how to make Codex proactive.

Source: Codex documentation

Limits and safety

  • It reads the code in your checkout, not your running site, so it won't catch a misconfigured server.
  • Scans are nondeterministic: two runs can surface different findings. Run them regularly, not once.
  • It adds to your scanners and dependency alerts. It doesn't replace them or a penetration test.
  • Codex sandboxes commands by default: writes stay in the workspace and the network is off. Keep danger-full-access for an isolated runner or container.

Claude Code or Codex for security review?

The rules carry over. Write them once in AGENTS.md and put @AGENTS.md in CLAUDE.md, and both agents read the same file.

Step by step for the other agent: security review with Claude Code.

Claude CodeCodex
Rules fileCLAUDE.mdAGENTS.md
Connect toolsclaude mcp addcodex mcp add or config.toml
Run without youclaude -pcodex exec
Schedule/schedule, desktop scheduled tasks, /loopScheduled tasks in the ChatGPT app, cron
Built in for security review/security-review, two security plugins@codex security review, Codex Security
With Crewmark

Make security review someone's job

Commands run when someone remembers to run them. Crewmark turns your own Codex into an AI employee with a role, a goal in numbers, working hours and a heartbeat, so the work happens on schedule and shows up on a board.

  1. Start from the role

    The AI software engineer, with these rules in its brief.

  2. Put the work on its board

    Add the job as a recurring issue. The employee wakes on its heartbeat, does it and reports in a comment.

  3. Related

    For bugs that aren't security issues, see code review.

FAQ

How do I get a security review from Codex on a pull request?

Comment @codex security review on the pull request. Codex posts its findings there; the full report is under the Security Report tab of the Codex task.

What's the difference between Codex code review and security review?

Code review flags serious bugs of any kind. Security review goes deeper on vulnerabilities and produces a security report. Both can run on the same pull request.

Can I run Codex security scans in CI?

Yes, with the Codex Security CLI from the @openai/codex-security package; OpenAI's docs include GitHub and GitLab setups.

Checked against Claude Code's and OpenAI's Codex documentation on November 13, 2026.

Hand security review to an AI employee on Codex.

Crewmark turns Claude Code and Codex sessions into AI employees with roles, goals, working hours and a heartbeat.