NewApp Monitoring is liveSign up free
AgentbeamBeta
AI agent vulnerability · Codex CLI

CVE-2025-59532: Codex has sandbox bypass due to bug in path configuration logic

highCVSS 4.0 8.6GHSA-w5fx-fh39-j5rw

Codex CLI could accept a model-generated `cwd` as the root of its writable sandbox, including folders outside where the user started the session. A model steered by a prompt injection could then write files and run commands wherever the Codex process has rights. Versions 0.2.0 through 0.38.0 of `@openai/codex` are affected. Upgrade to 0.39.0.

Published Sep 19, 2025 · Updated Sep 22, 2025 · Analysis Nov 1, 2026

What an attacker can do

Codex CLI limits file writes to a workspace folder, the one where you start the session. A bug in the sandbox configuration logic let the working directory supplied by the model define that writable root. The model could name any directory as cwd, so the boundary moved to wherever it pointed.

The advisory says this allows arbitrary file writes and command execution anywhere the Codex process has permissions. The network-disabled restriction was not affected, so outbound access stayed blocked in that mode.

The model's output is the trigger. A hostile repository, web page or issue text can hold instructions that make the model choose a cwd such as the home directory. From there it can modify shell startup files, SSH config or other projects, and run commands. The CVSS 4.0 vector sets low privileges and passive user interaction, which fits a user who runs the agent on untrusted content. The result is code execution as the developer, outside the folder the user trusted.

Who is affected

Affected: @openai/codex from 0.2.0 up to and including 0.38.0. The Codex IDE extension is also affected below 0.4.12. The risk is highest when you run Codex on code or text from sources you do not control.

Check your version:

codex --version
npm ls -g @openai/codex

@openai/codex

Ecosystem
npm
Affected
>= 0.2.0, <= 0.38.0
Fixed in
0.39.0
Check
npm ls @openai/codex

How to fix it

Upgrade the CLI to 0.39.0 or later:

npm install -g @openai/codex@latest

The patch canonicalizes the path and checks that the boundary for the sandbox policy comes from where the user started the session, not from the model. If you use the Codex IDE extension, update it to 0.4.12. The advisory lists no workaround, so until you update, avoid running Codex on untrusted repositories.

How to tell if you were hit

Review Codex session records and shell history for commands whose working directory is outside the folder where you started the session. Check for unexpected changes to files outside the project, such as shell profiles, ~/.ssh and other repositories, made around agent runs. Beam records agent shell commands and file access, so writes outside the session's workspace stand out in its record.

Original advisory

From the GitHub Advisory Database (CC BY 4.0).

Due to a bug in the sandbox configuration logic, Codex CLI could treat a model-generated cwd as the sandbox’s writable root, including paths outside of the folder where the user started their session.

This logic bypassed the intended workspace boundary and enables arbitrary file writes and command execution where the Codex process has permissions - this did not impact the network-disabled sandbox restriction.

Remediation We released a patch in Codex CLI 0.39.0 that canonicalizes and validates that the boundary used for sandbox policy is based on where the user started the session, and not the one generated by the model. Users running 0.38.0 or earlier should update immediately via their package manager or by reinstalling the latest Codex CLI to ensure sandbox boundaries are enforced.

If using the Codex IDE extension, users should immediately update to 0.4.12 for a fix of the sandbox issue.

Thank you to Tzanko Matev (Codetracer) for reporting the issue!

Questions

Is Codex CLI 0.38.0 affected by CVE-2025-59532?

Yes. The vulnerable range is 0.2.0 through 0.38.0. Version 0.39.0 fixes it.

Does this open network access?

No. The advisory states the network-disabled sandbox restriction was not impacted. The bypass is about where the agent can write files and run commands.

Does the IDE extension need an update too?

Yes. The advisory tells IDE extension users to update to 0.4.12 for the sandbox fix.

References

How this page is made: the data panel comes from the GitHub Advisory Database, CISA’s KEV catalog, the NVD and FIRST EPSS, and updates twice a day. The analysis is written by an AI model from the sources listed above and checked by automated rules before it is published. Check versions against the vendor's advisory before you act. Methodology

More Codex CLI vulnerabilities

All Codex CLI entries