OpenAI Codex prompt injection risk and controls

How prompt injection reaches OpenAI Codex through web content, repositories and config files, and which settings limit what an injected instruction can do.

On this page

Can OpenAI Codex be controlled against prompt injection?

Codex ships with built-in controls that limit what an injected instruction can do: network access is turned off by default, web search uses cached results unless live search is enabled, and approval modes decide when the agent must ask before acting. These controls reduce the risk, but they do not remove it. A security or engineering lead approving Codex for developers who read web pages, third-party repositories and issue text should treat prompt injection as a standing risk to govern, not a problem the vendor has closed. The settings that matter most depend on the edition and plan in use, so the Codex cloud and Enterprise configuration are the parts to confirm for each edition before rollout.

This section covers how untrusted text can reach Codex through web content, repository files and configuration files, and which default settings and team choices narrow the damage an injected instruction can cause. It treats the vendor's agent approvals and security guidance as the baseline and flags where a reviewer should ask for more detail. Start by reading the Codex agent approvals and security page, which warns that prompt injection can lead the agent to fetch and follow untrusted instructions. Then record, for each team, whether network access, live search and auto-approval are on, because a change to any one of them widens what a single malicious page or file can do.

The rest of this page is organized around decisions rather than features. Each control is checked against the question it answers: what can the agent read, what can it send out, and what runs without a person reviewing it. Where a reviewer needs a version-specific answer, such as whether a configuration file in a cloned repository can launch commands, the relevant published advisory is the reference point. Confirm the current defaults in your own environment and with OpenAI before you approve a rollout, because settings and documentation change between releases.

Which injection controls are built in, paid only or outside components

This table sorts the injection controls relevant to Codex into three groups: settings that ship in the product, access that depends on the ChatGPT plan or workspace setting, and controls you must supply outside Codex. Read each row as a question to confirm for your deployment, not as proof that a control stops a given attack. The main takeaway is that the strongest limits on an injected instruction sit partly outside the agent itself.

ControlWhat it does for injection riskWhere it applies or what to confirm
Network access off by defaultLimits what an injected instruction can fetch or send out during a local run, because the agent starts without network access.Built in. Confirm whether your team enables network access in any profile or config, since that removes this default.
Cloud agent phase offline by defaultRuns the cloud agent phase without internet access unless it is turned on, which narrows exfiltration paths for cloud tasks.Built in for Codex cloud. Confirm the internet access setting for each cloud environment your staff can create.
Cached web search by defaultServes web search from cached results, so a page edited after indexing is less likely to deliver fresh injected text.Built in. Cached results are not free of risk, so confirm whether reviewers accept web-sourced content in prompts.
Live web search with --yoloFetches live results when the agent runs in the YOLO mode, which increases exposure to attacker-controlled pages.Built in but opt-in through the flag. Confirm that policy blocks this flag for staff who handle sensitive repositories.
Approval prompts in the CLIAsks a person to approve commands before they run, which can stop an injected command from executing silently.Built in. Approval depth depends on the chosen approval policy, so confirm which mode each group uses.
Codex included across ChatGPT plansMakes the CLI and IDE extension available on every ChatGPT plan, so the same controls must be checked on Free and Go accounts too.Plan access, not a control. Confirm which plan each user holds before assuming that managed settings apply.
Codex cloud on eligible Plus, Pro, Business, Enterprise, Healthcare and Education accountsGives cloud tasks a separate execution environment, with its own network and approval settings.Plan-gated. Confirm eligibility per account type with OpenAI's plan help article before enabling cloud tasks.
Enterprise cloud access off until enabledKeeps cloud tasks disabled in an Enterprise workspace until an admin turns them on.Admin setting. Confirm who can enable it and whether the decision is recorded in your change process.
Network egress proxyRestricts which hosts the agent can reach, even if an injected instruction asks for another destination.Outside component. Your team must build or buy it. Confirm it covers the processes Codex starts, not only the browser.
Repository review before openingChecks .codex/config.toml and other project files for MCP commands or unexpected settings before anyone runs Codex in a cloned repository.Outside component. Confirm the review covers configuration files that the advisory GHSA-xrxf-jgv3-qmrm describes.
MCP server allowlistingLimits which MCP servers a session can start, so a configuration file cannot add an unapproved tool.Outside component. Confirm how your managed configuration restricts MCP entries for each team.

How prompt injection reaches Codex through web content and repositories

Prompt injection reaches Codex through any text the agent reads while it works. Three entry points matter for a review. The first is fetched web pages and search results, which the agent may open while researching a library, an API or an error message. The second is the repository being worked on, including its README, code comments, issue templates and dependency manifests such as package.json or requirements.txt, where a planted sentence can look like a maintainer's note. The third is configuration, and the most concrete case is .codex/config.toml, which can define MCP commands. Codex's agent approvals and security guidance warns that prompt injection can cause the agent to fetch and follow untrusted instructions, so the reader should treat any content the agent can see as potentially hostile input.

The danger comes from how an instruction blends in with a task. A comment that says a build step must be run before tests, or a README that asks the agent to install a helper script, reads like ordinary project work. The agent may then run a shell command, edit a file or pass data to a tool without a human noticing that the instruction came from the content rather than from the person who assigned the job. Whether that step runs depends on the sandbox mode, network setting and approval policy in force. The advisory covering code execution from a malicious repository's .codex/config.toml shows that repository configuration alone can be enough to run code, so a reviewer should check that opening an untrusted repository does not bypass approvals.

Before approving a rollout, the reader should decide which sources an engineer may point Codex at, and which repositories are trusted enough to open. Ask the vendor and the team to confirm what the agent does with a repository's .codex/ directory on first open, and whether that behavior differs by version. Keep the current Codex CLI version on a tracked list, since the advisory in the GitHub Advisory Database names a specific affected range. Finally, record which settings are locked for the team, because the controls in the sections that follow only limit injected instructions if the team cannot switch them off.

Where an injected instruction can be stopped

The flow starts with untrusted content: a web page the agent fetches, a file in a cloned repository, or a .codex/config.toml that ships with it. That content reaches the Codex agent, which OpenAI's approvals and security page says can fetch and follow injected instructions. Three controls sit between the agent and the host: the network setting, which is off by default, the cached search default, and the approval prompt. The sandbox boundary is the last stop before the host and network. Confirm with your own tests how each control behaves in your Codex version and sandbox mode.

Untrusted input reaches the agent, and each control sits before the host and network.

Which Codex settings limit what an injected instruction can do

Network access is the control that decides whether an injected instruction can send data out or pull in new code. OpenAI's agent approvals and security page states that the agent runs with network access turned off by default, and that the Codex cloud agent phase runs offline unless internet access is enabled. Without network access, a poisoned README or web page can still change the code the agent writes, but it has a harder time exfiltrating secrets or downloading a payload at run time.

  • If the control fails: an injected instruction could push repository contents, environment values or tokens to an external host, or fetch a package or script that was never reviewed.
  • Cloud tasks: confirm whether internet access is enabled for each Codex cloud environment, since the default is offline.
  • Package installs: dependency installs usually need network access, so teams may enable it temporarily, which widens the window for injected commands.
  • Productivity trade-off: offline runs cannot read current documentation or fetch dependencies, so developers may hand-paste context or request exceptions.
  • Confirm: ask whether network access is set at the sandbox level, the workspace level or both, and who can change it.

Check that the network default is documented in your rollout standard and that exceptions are tied to named projects.

Where the Codex controls stop and what covers the gap

Codex settings reduce what an injected instruction can do, but they do not decide whether the content the agent reads is trustworthy. Each card below names a gap that remains after the built-in controls are set, the outside control that usually covers it, and what to confirm with OpenAI before approving a rollout.

Untrusted content still reaches the agent

Codex reads files, web pages and tool output as part of its work, and OpenAI's agent approvals and security page warns that prompt injection can cause the agent to fetch and follow untrusted instructions. Network-off defaults and approvals limit the damage, but they do not stop the agent from reading a hostile instruction. Teams usually cover this with a content intake rule: review third-party issues, pull request text, dependency READMEs and fetched pages before pointing Codex at them. Ask OpenAI which parts of the context Codex treats as instructions and which it treats as data.

Agent approvals and security

Full-auto runs remove approval friction

The --yolo option is the most permissive way to run Codex, and the approvals page is the document that defines what it changes. Once a developer runs with it, an injected instruction has fewer checkpoints between reading it and acting on it. Approval discipline is usually enforced by policy and training: no --yolo on shared machines, no unattended runs on repositories the team has not reviewed, and a written exception for any exceptions. Confirm with OpenAI whether managed configuration can block this flag for members.

Cached search can surface poisoned pages

By default Codex web search returns cached results, and live results are used only when Codex runs with --yolo. Cached content is still third-party content that an attacker may have planted or that a page may have changed after indexing, so the cache limits freshness rather than trust. Teams that allow web search usually route agent traffic through an egress proxy with an allowlist of documentation domains, and log the requests. Confirm with OpenAI how the cache is populated and whether administrators can restrict search sources.

The sandbox does not judge the repository

A sandbox limits what a process can read, write and reach, but it cannot tell whether the repository being opened is safe. A cloned project can carry instructions, scripts or configuration that look routine to the agent. The usual outside control is a repository trust review: owners approve repositories before Codex is pointed at them, protected paths such as CI workflows and agent configuration require code owner sign-off, and build scripts are read before the first run. Confirm with OpenAI which configuration files Codex loads automatically from a working directory.

Repository-defined MCP commands can run code

GHSA-xrxf-jgv3-qmrm (CVE-2025-61260) describes code execution when Codex CLI 0.23.0 or earlier is run inside a malicious repository whose .codex/config.toml defines MCP commands. The lesson is that a configuration file in a repository can start processes, so a trusted sandbox setting is not enough. Teams usually keep MCP server definitions in a central, reviewed location, allow only approved servers, and check the installed CLI version against the advisory before use. Confirm with OpenAI which versions fix the issue and whether managed configuration can restrict MCP servers.

GHSA-xrxf-jgv3-qmrm

What CVE-2025-61260 shows about repository configuration

The published advisory GHSA-xrxf-jgv3-qmrm (CVE-2025-61260) shows that a repository can carry instructions into Codex before any developer types a prompt. Per the advisory, Codex CLI 0.23.0 or earlier can execute code when it runs inside a malicious repository whose .codex/config.toml defines MCP commands. The lesson for reviewers is that a project file a developer clones, opens or trusts can change what the agent launches on the workstation, so repository content is part of the attack surface, not just the code under review.

The first control is version discipline. Ask engineering to confirm which Codex CLI versions are installed across developer laptops, CI runners and IDE-bundled tooling, and flag anything at 0.23.0 or earlier for upgrade. Inventory should cover every place the CLI is installed, because a single unmanaged copy is enough to reopen the exposure. Confirm the fixed version range against the advisory itself and against OpenAI's security advisories for the openai/codex repository before setting the patch baseline.

The second control is behavioral. Treat cloning and opening an unfamiliar repository as an untrusted action, and do not run Codex in it with elevated approval or in full-access mode until a reviewer has read its .codex/config.toml and any other agent configuration. A patching policy should require: a minimum CLI version enforced by the package manager or endpoint tooling, a review step for MCP server definitions added or changed in cloned code, and a rule that approval relaxations are never inherited from a repository file. Ask whether your Codex managed configuration can enforce these defaults for members.

Order of work before developers use Codex on sensitive code

This sequence sets the trust boundaries, plan and access state, network and search defaults, and approval modes before any developer points Codex at sensitive code. Each step ends with a written decision or check that a reviewer can sign off.

  1. Set trusted repository and web source policy

    The security lead and the engineering owner agree in writing which repositories Codex may open, and which external sources (documentation sites, issue trackers, package registries, web pages) the agent may read. Repositories that contain sensitive code should be treated separately from public or third-party code, because prompt injection can arrive through web content, files in a repository, and configuration files such as .codex/config.toml. Done when the policy names the approved repositories, the approved sources, and the owner who can add to either list.

  2. Confirm the Codex edition and cloud access state

    The IT administrator records which ChatGPT plan or workspace each group uses, and whether Codex cloud is enabled. OpenAI's help article states that Codex is included across all ChatGPT plans, while Codex cloud is available to eligible Plus, Pro, Business, Enterprise, Healthcare and Education accounts, and that cloud access is off by default for Enterprise workspaces that have not enabled it. Ask the workspace owner to confirm the current state in the admin console. Done when a written inventory lists each group, its plan, and whether cloud tasks are on, and the security reviewer has accepted it.

  3. Set network and web search defaults

    The security engineer sets the defaults that govern what an injected instruction can reach. OpenAI's agent approvals and security page states that the agent runs with network access turned off by default, that the Codex cloud agent phase runs offline unless internet access is enabled, and that web search uses cached results by default, with live results when Codex runs with --yolo. Confirm these defaults against the version in use, and record any group that is granted network access or live search with a named justification. Done when the network and search settings for each group are documented and signed off by the security lead.

  4. Decide approval modes for each team

    The engineering manager and security lead choose an approval mode for each team based on the sensitivity of its code. Teams working on sensitive repositories should keep the default approval behavior and avoid --yolo, since that mode also switches web search to live results. Teams with low-sensitivity, disposable work may be given broader modes only after the choice is written down. Confirm the exact mode names and their effects in the current Codex documentation before writing the decision. Done when each team has a named mode, an approver, and a record of who may change it.

  5. Verify the CLI version against advisories

    The platform engineer checks the installed Codex CLI version on every workstation and CI runner against the published security advisories. GitHub advisory GHSA-xrxf-jgv3-qmrm (CVE-2025-61260) describes code execution when Codex CLI 0.23.0 or earlier is run inside a malicious repository whose .codex/config.toml defines MCP commands. Any build at or below that version should be upgraded before use, and the patching owner should confirm the fixed release in the advisory. Done when an inventory shows every installed version, none falls in the affected range, and the check is scheduled to repeat.

  6. Test injection cases in a non-production repository

    The security team builds a test repository that contains planted instructions in a README, a code comment, a fetched web page, and a .codex/config.toml file, then runs Codex against it with the intended settings. The goal is to confirm that the agent does not follow untrusted instructions to read secrets, reach the network, or run unapproved commands. Record each case, the settings used, the observed behavior, and any prompt that the approval step caught. Illustrative case: a comment asks the agent to send a file to an external address, and the test passes only if network access stays off and the approval prompt appears. Done when the test log is signed off by the security lead and failing cases have a remediation owner.

  7. Monitor activity and review settings regularly

    The security operations owner reviews Codex activity and confirms that settings still match the signed-off policy. Where the organization has a Compliance API or other logging for its plan, the reviewer confirms which Codex usage is recorded, including cloud-delegated usage, and checks that the logs can be queried. The team also re-runs the injection test set and the version check after each Codex upgrade, and when the trusted source list changes. Done when a named owner holds a review schedule, the logs have been checked against the approved settings at least once, and any drift has a recorded decision.

What a security reviewer asks to see for prompt injection controls

This table lists the evidence a security reviewer should request for each Codex prompt injection control, and where that evidence usually lives. Read each row as a question to put to the engineering team, with the source named so the answer can be checked. The main takeaway is that a stated setting is not enough on its own; the reviewer should see the effective configuration, the installed CLI version and the test results behind it.

Reviewer requestEvidence to ask forWhere to check it
Network access settingConfirmation that network access is off by default and that any enabled exception is recorded with an owner and a reasonCodex agent approvals and security page, plus the effective configuration on each developer machine
Web search modeProof that web search runs in cached mode, and a list of any teams where live results are usedCodex agent approvals and security page; confirm the mode in each profile, since live results apply under the --yolo flag
Approval policyThe approval mode in force for each team, and a statement of which actions still require a person to confirmCodex agent approvals and security page and the managed configuration set by the admin
CLI version inventoryA current list of installed Codex CLI versions across laptops, CI runners and build images, with a check against the fixed release in each advisoryLocal package inventory and the openai/codex releases in the GitHub repository
Advisory trackingA dated record of Codex security advisories reviewed, the affected versions, and the patch date for eachCodex security advisories in the openai/codex GitHub repository and the GitHub advisory for CVE-2025-61260
Repository trust rulesA written rule for whether Codex may open untrusted repositories, and who approves a repository's .codex configuration before it runsCodex agent approvals and security page; the advisory for CVE-2025-61260 shows why MCP commands in .codex/config.toml matter
Injection test resultsRecords from scenarios where web pages, issues, README files or dependency docs contain instructions, showing whether the agent followed them and what it was able to reachInternal test reports from the security team; ask for the scenarios, the Codex version tested and the approval mode used
Protected paths and secretsEvidence that credentials, CI secrets and production configuration sit outside what the agent can read or write under the chosen sandbox modeSandbox and approval settings in the managed configuration, confirmed with the engineering team

Questions buyers ask about Codex prompt injection

Is Codex protected against prompt injection by default?

No. Codex reduces what an injected instruction can do, but it does not stop an injected instruction from being read. OpenAI's agent approvals and security page warns that prompt injection can cause the agent to fetch and follow untrusted instructions. Defaults that help include network access turned off for the agent and web search using cached results. Those defaults change with the run mode, so a reviewer should confirm the sandbox mode, approval policy and search mode actually in force on each developer machine and in Codex cloud tasks, rather than assuming the out-of-the-box state is the approved state.

What does the enterprise plan add for prompt injection controls?

The plan adds administrative control over Codex behavior, not a separate injection filter. OpenAI's admin rollout guide and managed configuration pages describe how administrators set policy for members, which the Compliance API can then record for Codex usage, including cloud-delegated usage. Enterprise workspaces also have Codex cloud access off by default until enabled. Confirm with OpenAI which settings are enforced by managed configuration, which members can still change, and whether a given setting applies to the CLI, the IDE extension and cloud tasks alike.

Does turning network access off stop all prompt injection?

No. Network access off limits what an injected instruction can send out or fetch, which reduces data exfiltration and remote payload download. It does not stop an injected instruction from changing files in the repository, altering a test or build script, or influencing the code the developer later reviews and merges. Local configuration can also run commands before a developer reviews them, as the GHSA-xrxf-jgv3-qmrm advisory shows for the Codex CLI 0.23.0 and earlier when a repository defines MCP commands in .codex/config.toml. Treat network controls as one layer alongside protected paths, approval prompts, review of configuration files and patching the CLI to a fixed version.

How do repository count and developer count change the cost and effort?

Effort grows with the number of repositories and the number of distinct ways developers run Codex. Each repository may carry its own AGENTS.md instructions, MCP definitions and .codex/config.toml files, and each one is a trust decision. Each developer machine or IDE setup needs the same settings checked, and cloud tasks need their own review. Cost drivers include how many repositories hold sensitive code, how many contain external MCP or script configuration, how many teams need different approval rules, and how much evidence the organization must keep. Ask any provider for a quote that lists repositories, environments, configuration reviews and the testing included, since that list sets the work.

What can our own security and engineering teams do without outside help?

Most of the baseline is within reach of an internal team. Useful steps include:

  • Set the sandbox mode and approval policy in managed configuration and confirm members cannot weaken them without review.
  • Keep network access off for the agent unless a specific task needs it, and review the cached versus live web search setting.
  • Require review of changes to .codex/config.toml, AGENTS.md and MCP definitions before merging.
  • Subscribe to the security advisories in the openai/codex repository and set a patch window for the CLI and IDE extension.
  • Export Compliance API records and retain them under your own policy.

An outside team adds value when you need an adversarial test of your own repositories and workflows, which is a separate, fixed-scope engagement.

Can DeployOpen test how Codex handles prompt injection in our environment?

Yes. DeployOpen runs security testing that includes AI systems and agents and red teaming, so a prompt injection assessment of Codex can be scoped to your repositories, configuration files, MCP connections and approval settings. Engagements are fixed-scope, with scope, deliverables and timelines agreed in writing before work starts, and the test is run against systems in your own environment. DeployOpen does not publish a price list, so a quote follows from the written scope. Testing shows what an injected instruction could do in your setup. It does not guarantee that no injection will succeed, and it does not replace the organization's own review and patching decisions.

Which Codex versions should we check against the advisories?

Start with GHSA-xrxf-jgv3-qmrm, tracked as CVE-2025-61260, which describes code execution when Codex CLI 0.23.0 or earlier runs inside a malicious repository whose .codex/config.toml defines MCP commands. Any installed CLI at or below that version should be upgraded, and developers who clone unfamiliar repositories should be told to review that file first. Confirm the fixed release with OpenAI and the advisory before setting a deadline, and check the openai/codex security advisories section for later entries, since new advisories may affect different components.

How DeployOpen tests Codex against prompt injection in your environment

DeployOpen plans, implements, tests and documents the controls around Codex inside your own infrastructure, so prompt injection risk is assessed against your repositories, configuration files and network paths rather than a generic setup. Engagements are fixed-scope, with the scope agreed in writing before work starts.

How we scope

  • We agree in writing which Codex surfaces, repositories and environments are in scope before testing starts.
  • We map the untrusted inputs Codex reads, such as web pages, dependencies, issue text and .codex configuration files.
  • We record which sandbox mode, approval policy, network setting and web search mode each team currently uses.

How we build

  • We configure a test environment inside your infrastructure that mirrors the Codex settings your teams will use.
  • We run prompt injection test cases through repositories and web content and record what the agent attempts to do.
  • We test whether network access off, cached web search and protected paths actually block the actions they are meant to block.

How we hand over

  • You receive a written report of findings, the settings tested and the evidence behind each result.
  • You receive a recommended baseline of managed settings and approval rules, with the reasoning for each setting.
  • Your team receives a patching and advisory review checklist tied to the Codex versions in use in your environment.

How we support

  • Ongoing support, upgrades and continuous testing are available as a retainer after the initial engagement.
  • A retainer can re-run the prompt injection test cases when Codex versions, settings or repositories change.
  • Your reviewers can confirm plan, identity and compliance questions directly with OpenAI and your independent auditors.

Sources and further reading

Talk to our team.

Tell us what you're working on, whether it's a deployment, an audit, a security test or a cyber range. You'll speak with an engineer who can help you scope it.

  • 30-minute call: free, with no obligation.
  • NDA on request: we can sign before you share details.
  • Clear next steps: a scope and plan after the call.