Skip to main content
A blacksmith's anvil in side profile with a long tapered horn, drawn in dots

Using OpenAI Codex for security work: detections, investigations, and limits

How to use OpenAI Codex for security: Codex Security code scans, detection work over MCP, Daybreak, sandbox settings, and where a session stops.

Guide
Updated 14 min read

Summary

OpenAI Codex handles security work in two forms: Codex Security, a research-preview agent that scans code, validates suspected vulnerabilities, and proposes patches, and the Codex coding agent, which engineers point at detection repositories and, over MCP, at security tools. Both suit one-off work a person starts, such as patching a vulnerability or authorized red teaming under Daybreak Red. A SOC also needs agents that pick up every alert and ticket, grade each run, feed verdicts back into detections, and watch threat intel continuously; agent-native platforms such as Cotool do this, and Codex can connect to Cotool's MCP server.

Key takeaways

  1. Use Codex Security and the Codex agent for one-off work: patching a vulnerability, changing a detection, or authorized red teaming under Daybreak Red.
  2. Plan separately for the work nobody starts by hand: every alert and ticket, grading each run, tuning detections from verdicts, and watching threat intel. That's agent-platform work, the job Cotool's agents do.
  3. Gate MCP tools with an enabled_tools list and the writes approval mode. Codex's command network proxy doesn't filter MCP connections, so tool settings are the control that applies.
  4. Put house rules in AGENTS.md and repeatable procedures in skills, so every engineer's Codex session follows the same query, naming, and testing conventions.
  5. Backtest every detection Codex writes against past data, and keep publishing gated on the true positives your team has already labeled.

The short version

"Codex for security" means two different OpenAI products. Both fit one-off work that a person starts and watches; the always-on work of a SOC needs something that runs without them.

  1. Run Codex Security on code you own, including the scripts and parsers your SOC writes, to find and patch vulnerabilities.
  2. Use the Codex agent for detection changes, investigations, and authorized red teaming: start it read-only, write your rules into AGENTS.md, and package runbooks as skills.
  3. Connect security tools as MCP servers with an allow list and approval on writes, since the network proxy doesn't cover MCP traffic.
  4. Backtest every detection Codex writes on past data before it can fire.
  5. Turn on Daybreak per request if refusals block defensive work, and send Codex's own telemetry to your SIEM.
  6. Plan the always-on work separately: triage of every alert and ticket, grading of each run, tuning from verdicts, and threat intel monitoring. That's agent-platform work, such as Cotool's, and Codex can connect to Cotool over MCP.

Codex Security and the Codex agent do different jobs

Codex Security looks for vulnerabilities in source code. The Codex agent is a general coding agent that reads files, runs commands, and calls tools you connect. The differences decide where each fits in a security team, as of November 2026.

Codex SecurityCodex agent
Works onSource code in GitHub or local repositoriesFiles, shell commands, and MCP-connected tools
Runs inCodex Security Cloud, the cs CLI, a GitHub ActionChatGPT desktop app, Codex CLI, IDE extension
ProducesValidated findings, a threat model, proposed patchesCode, queries, answers, file changes
PermissionsCLI runs with your OS permissions, no approval pausesOS sandbox plus an approval policy
Status and billingResearch preview; Cloud uses token-based billingShares ChatGPT plan usage and credits

Neither product watches production systems. Codex Security reads code; the Codex agent works when a person or a script starts it.

What Codex covers, and what a SOC still needs

Codex fits work someone starts and reviews: scanning a repository, patching a vulnerability, changing a detection, or an authorized red-team exercise under Daybreak Red. Most SOC work arrives on its own, at any hour, and has to be closed, measured, and learned from. Four needs sit outside a Codex session.

  • Agents that pick up every alert and ticket. Alerts land overnight and tickets arrive from other teams, so something has to start work without a person. Codex starts when someone types or a pipeline calls codex exec, so per-alert triage means building the intake, the calls, and the credential handling yourself. In Cotool's AI SOC, alerts arrive from native integrations, webhooks, email, Jira, Linear, or the API, and a triage agent picks up each one as it lands, in its own isolated Linux sandbox with outbound traffic restricted per agent, then closes or escalates it with the evidence attached. Read-only tool calls run on their own; state-changing actions wait for approval in the app or Slack.
  • Observability into every run. An agent that closes alerts needs its verdicts measured, or a broken integration can go unnoticed. Codex can export telemetry about its own tool calls (step 8), but nothing in it checks whether a verdict was right. Cotool's AI judge grades every run against your acceptance criteria and flags a broken integration when it fails, and every verdict shows the evidence and reasoning behind it.
  • Feedback from verdicts into the detection. A false positive closed today will fire again tomorrow unless the rule changes. A Codex session ends when its change merges. In Cotool, each false-positive or benign disposition feeds autotuning, which tests a change against the current version before applying it or sending it for review, so the detection that fired learns from the alert it produced.
  • Continuous threat intel monitoring. New exploits and campaigns keep appearing, and each has to be checked against what you actually run. Codex Security finds bugs in code you own; it doesn't tell you when new intel affects software you run. Cotool's hunt agents combine Cotool's curated feeds with your own sources, such as STIX/TAXII feeds, OpenCTI, Recorded Future, or a blog, check each item for relevance and exposure in your environment, and turn real exposure into tuned detections and next steps. When a hypothesis-driven hunt returns findings, the agent backtests and ships a new detection.

The steps below set Codex up for the one-off work, with Cotool as the worked example where Codex needs a platform behind it.

Scanning your own code with Codex Security

OpenAI released Codex Security as a research preview on March 6, 2026, after a private beta under the name Aardvark. A scan builds an editable threat model of the repository (entry points, trust boundaries, sensitive data), searches for vulnerabilities against it, tries to reproduce each one in an isolated environment, and proposes a patch. It doesn't modify code on its own; a proposed patch can be turned into a pull request for your normal review. OpenAI reports that over the beta, false positive rates fell by more than 50% across repositories, as measured on its own scans.

For a SOC, the obvious targets are the repositories that hold credentials to your security tools: enrichment scripts, log parsers, and response automation. The standalone CLI is the quickest start:

npm install --global @openai/codex-security
cs login
cs scan . --diff origin/main   # only changes since main
cs scan . --mode deep          # repeated standard scans, deduplicated

Three behaviors catch people out. The CLI runs with your operating-system permissions, doesn't pause for approval, and can inherit your shell environment, so remove unrelated credentials before a scan. Results include source excerpts, so write them to a private directory outside the repository. And a completed scan exits 0 unless findings meet a severity threshold you configured; OpenAI notes that exit 0 doesn't establish that every file was reviewed. The GitHub Action example sets an estimated $5 limit per scan and reports findings without failing the job. Findings export as SARIF, JSON, or CSV, and can be tracked in Linear, Jira, or GitHub.

A scan is a point-in-time answer about code you control. It doesn't watch for a new vulnerability in a product you deploy, which is the exposure matching described in the previous section.

Step by step: set up the Codex agent for detection and investigation work

1. Start read-only in a Git repository

Codex runs commands in an OS-enforced sandbox with network access off. In a version-controlled folder it recommends the Auto preset, which edits and runs commands in the workspace on its own and asks before touching the network or files outside it. For investigation work, start narrower:

codex --sandbox read-only --ask-for-approval on-request

Keep your detection rules in Git and git status clean before handing work to Codex, so each change is easy to review and revert.

2. Write the team's rules into AGENTS.md

Codex reads AGENTS.md before doing any work: a global file in ~/.codex, then one per directory from the repository root down to where you started, with closer files taking precedence. The combined instructions stop at 32 KiB by default. A detection repository's file might read:

# AGENTS.md
## Detection rules
- Every new rule needs a test with a true-positive sample and a benign sample.
- Tag each rule with the MITRE ATT&CK technique it covers.
- Start log queries on a narrow time window and widen only when asked.
- Never call a tool that changes state in a production system. Ask the analyst.

AGENTS.md holds what people write down. Cotool keeps the other half for its agents as global memory: facts agents learn about your environment over many runs, such as which service account runs a nightly backup, kept in shared files that every agent reads and you can inspect.

3. Turn repeatable procedures into skills

A skill is a folder with a SKILL.md (a name, a description, and instructions) plus optional scripts and references. Codex loads repository skills from .agents/skills and picks one when a task matches its description, so a description like "Triage an Okta sign-in alert: pull 30 days of sign-ins for the user and compare locations" does the routing. Use $skill-creator to draft one. Cotool's agents use skills of the same shape: a SKILL.md with scripts and references, versioned and available to every agent that works alerts.

4. Connect security tools over MCP, with writes gated

Codex connects to local MCP servers started as a process and to remote servers at a URL, with OAuth or a bearer token. The configuration lives in ~/.codex/config.toml and is shared by the desktop app, CLI, and IDE extension. Our survey of security MCP servers shows how uneven the vendor servers are: many run only as local processes or expose a few read-only calls.

Settle three things for every server. First, an enabled_tools allow list. Second, default_tools_approval_mode = "writes", which prompts for any tool the server doesn't mark read-only. Third, a longer tool_timeout_sec for log searches, since the default is 60 seconds. Remember too that Codex's network_proxy domain rules filter commands in the sandbox, not MCP server connections, so these tool settings are what constrain MCP traffic.

Cotool's MCP server shows the hosted pattern. Its documentation gives the Codex setup directly:

codex mcp add cotool --url https://app.cotool.ai/api/mcp
codex mcp login cotool

Then gate it in config.toml:

[mcp_servers.cotool]
url = "https://app.cotool.ai/api/mcp"
default_tools_approval_mode = "writes"
tool_timeout_sec = 180

Sign-in uses your Cotool login, with no API key to create, and Codex then acts with your Cotool role: it can search and read alerts and their timelines, run log queries, and work on detections, but it can't delete anything. Integration secrets go through a link to Cotool's connect form rather than the chat, and every call is logged in Cotool's audit log as user.calledMcpTool. Alerts and logs are full of attacker-written text, so read our guide to MCP security risks before connecting servers that can write.

5. Enable Daybreak when refusals block the work

OpenAI's standard safeguards support application security and general blue teaming, but can refuse malware analysis or incident response. Daybreak Blue, the defensive tier of OpenAI's Trusted Access for Cyber program, reduces refusals for detection engineering, incident response, and malware analysis on GPT-6 Sol and GPT-6 Luna. In the Codex CLI (version 0.163.0 or later), turn it on with /daybreak in a session or daybreak=true in headless runs; every request uses standard safeguards until you do. GPT-6.2 Astra and GPT-6.2 Sol get reduced refusals only with Daybreak Red, which needs separate approval and covers authorized penetration testing, red teaming, and exploit validation, with cyber-specialized models such as GPT-5.6 Cyber. Daybreak doesn't include zero data retention. GPT-6 Astra also runs safety monitoring that can pause a task, and in the Codex CLI a paused task ends rather than resuming. Our page on ChatGPT for security analysts covers the application requirements.

Daybreak is an exception OpenAI grants for its own models. An agent that works alerts unattended can't wait for someone to rephrase a refused request, so Cotool handles refusals at the routing layer: Cotool Router moves a refused or failed task to another provider or an open-weight model without stopping the agent.

6. Write and backtest a detection

A detection Codex writes in a local repository can pass its unit tests and still flood the queue, because nothing has run it against your data. Connected to a platform that can backtest, Codex closes that gap.

Cotool's documentation describes this flow for coding agents, Codex included. Cotool detections are Python notebooks that can query any connected tool's read-only actions or Cotool Logs. Codex sends draft code to Cotool, which runs it over a past time window and returns what it would have flagged, how that differs from the published version, and how it compares with alerts your team has labeled; test runs create no hits or alerts. When Codex publishes, Cotool runs the code again. It rejects code that errors or returns results without an entity type. Code that still catches every alert labeled a true positive becomes a new version. Anything else becomes a tuning proposal for a person to review. A new detection is published turned off, admins decide whether apps can publish at all, and each version records the app's explanation so it can be reverted. After that, false-positive and benign dispositions feed Cotool's autotuning, which tests a change against the current version before applying it. Our guide to AI detection engineering covers the authoring loop in more depth.

7. Run reviews headless with codex exec

codex exec runs Codex from scripts and CI, in a read-only sandbox by default. Piped input becomes context for the prompt, and --output-schema forces the final answer into a JSON shape a pipeline can check. A pull request review for a rules repository might look like this:

git diff origin/main...HEAD -- rules/ \
  | codex exec --output-schema ./review-schema.json -o review.json \
    "Review these detection rule changes. For each rule, give the ATT&CK technique, likely false-positive sources, and missing test cases."

In GitHub Actions, use openai/codex-action rather than exporting OPENAI_API_KEY for the whole job, since build scripts and tests in the same job can read job-level variables. Project-scoped MCP servers load only for trusted projects, and OpenAI warns that they can run commands outside the sandbox.

The same command can be called once per alert. The intake, retries, credentials, and checks on each verdict then become code you maintain, which is the first of the four needs above.

8. Send Codex's own activity to your SIEM

Codex can export OpenTelemetry events, off by default, including codex.tool_decision (approved or denied, and whether by configuration or a person) and codex.tool_result. Prompt text is redacted unless you set log_user_prompt = true.

[otel]
environment = "prod"
exporter = { otlp-http = { endpoint = "https://otel.example.com/v1/logs", protocol = "binary" } }
log_user_prompt = false

With network access off, the export can't reach your collector, so allow that one endpoint. These events record what Codex did, not whether its answer was right.

Where Codex fits next to an agent platform

Codex keeps its place once agents run the queue: engineers use it for code, one-off patches, and red-team work, and reach the same alerts, logs, and detections through the MCP connection in step 4. The difference is where configuration lives. A Codex setup sits on each engineer's machine or in each project, while Cotool's agents and skills sync from GitHub as YAML with pull-request review and rollback, so one reviewed change applies to every agent.

Common mistakes

  • Reading exit 0 as a clean scan. Codex Security exits 0 whenever findings stay below your severity threshold, and that doesn't mean every file was reviewed. Read the report's scope and exclusions.
  • Scanning from a shell full of credentials. The Codex Security CLI runs with your permissions and inherits your environment without asking.
  • Assuming the domain allow list covers MCP. It filters sandboxed commands only; MCP servers need their own tool lists and approval modes.
  • Leaving the 60-second tool timeout. A long log search can time out mid-investigation and leave the agent reasoning from partial results.
  • Trusting a cloned repository's config. Project-defined MCP servers can run commands outside the sandbox, so trust only projects you control.
  • Assuming Daybreak is on. Approval changes nothing until it's enabled for the request, and GPT-6.2 models stay on standard safeguards under Daybreak Blue.
  • Treating a Codex session as a SOC. A session ends when the person stops; alerts that land overnight, verdicts nobody grades, and new intel nobody checks need agents that run on their own.
  • Using full access on a laptop. --dangerously-bypass-approvals-and-sandbox removes both the sandbox and approvals; keep it to isolated CI runners or containers.

Checklist

  • Codex Security scans your SOC's own automation repositories, with results stored outside the repository.
  • Codex starts read-only for investigation work, in a Git repository with a clean working tree.
  • AGENTS.md states the team's rule, testing, and tool-use conventions.
  • Repeatable runbooks live in .agents/skills with specific descriptions.
  • Every MCP server has an enabled_tools list, the writes approval mode, and a timeout sized for log searches.
  • New detections are backtested on past data, and publishing is gated on labeled true positives.
  • Daybreak is approved, enabled per request, and paired with a model it covers.
  • CI uses openai/codex-action or an inline CODEX_API_KEY, never a job-level API key.
  • Codex's OpenTelemetry events reach your SIEM, with prompt logging off.
  • Every alert and ticket goes to agents that pick it up on their own, with each run graded and verdicts feeding detection tuning.
  • New threat intel is checked against your environment continuously, not only when someone thinks to ask.

FAQ

What is OpenAI Codex Security?
OpenAI Codex Security is an application security agent, formerly called Aardvark, that builds a threat model of a repository, searches it for vulnerabilities, tries to validate them in an isolated environment, and proposes patches for human review. It is in research preview for ChatGPT Pro, Business, Enterprise, and Edu, and runs in Codex Security Cloud, the cs command-line tool, or a GitHub Action. Codex Security scans code; it doesn't watch production systems or triage alerts.
Can OpenAI Codex connect to a SIEM or EDR?
OpenAI Codex can connect to a SIEM or EDR through an MCP server, either a local process started with codex mcp add or a remote server added by URL with OAuth or a bearer token. The configuration is shared by the ChatGPT desktop app, the Codex CLI, and the IDE extension. Set an enabled_tools list and the writes approval mode for each server, because many security vendors' MCP servers are local-only or read-only.
Can OpenAI Codex triage security alerts automatically?
OpenAI Codex triages security alerts automatically only inside a pipeline you build, for example by calling codex exec for each alert with a JSON schema for the verdict. You supply the alert intake, the tool connections, the credentials, and any check on whether verdicts were right. Agent platforms built for the SOC, such as Cotool, pick up alerts from their sources and grade every run.
How do I use Daybreak in the Codex CLI?
To use Daybreak in the Codex CLI, get Daybreak approval for your workspace or account, upgrade the CLI to 0.163.0, and enable it with /daybreak in an interactive session or daybreak=true in headless commands or configuration. Daybreak is off for each request until you turn it on. Daybreak Blue reduces refusals on GPT-6 Sol and GPT-6 Luna, while GPT-6.2 Astra and GPT-6.2 Sol need Daybreak Red.

Sources

  1. Codex Security: now in research preview (OpenAI) · accessed November 30, 2026
  2. Codex Security (OpenAI Help Center) · accessed November 30, 2026
  3. openai/codex-security (GitHub) · accessed November 30, 2026
  4. CLI quickstart - Codex Security · accessed November 30, 2026
  5. Model Context Protocol - Codex · accessed November 30, 2026
  6. Agent approvals and security - Codex · accessed November 30, 2026
  7. Non-interactive mode - Codex · accessed November 30, 2026
  8. Custom instructions with AGENTS.md - Codex · accessed November 30, 2026
  9. Build skills - Codex · accessed November 30, 2026
  10. Codex pricing · accessed November 30, 2026
  11. OpenAI Daybreak - Trusted Access for Cyber overview · accessed November 30, 2026
  12. MCP Server - Cotool Documentation · accessed November 30, 2026
  13. Connect an App - Cotool Documentation · accessed November 30, 2026
  14. Detections Platform - Cotool Documentation · accessed November 30, 2026
  15. AI Detection Engineering with Python Detections (Cotool) · accessed November 30, 2026
  16. AI SOC Without the Black Box (Cotool) · accessed November 30, 2026
  17. AI Threat Hunting and Actionable Threat Intel (Cotool) · accessed November 30, 2026
  18. Introducing Cotool Router · accessed November 30, 2026

Keep reading

Attackers are scaling with tokens

Cotool helps defenders operate at machine speed. See how security teams are scaling Detection & Response.

Book a demo