Researchers break out of OpenAI Codex sandbox with two exploits, one enabling remote code execution

Heapjack technique turns a repository query into unsandboxed command execution; fixes deployed within eight days of report

edit
By LineZotpaper
Published
Read Time2 min
Security researchers have discovered two ways to escape the OpenAI Codex sandbox, the more severe of which — dubbed Heapjack — allows an attacker to execute arbitrary commands on a developer's machine from the sandbox's strictest read-only mode, with no approval prompt. Both vulnerabilities were reported to OpenAI on August 12 and fixed by August 20.

The findings, detailed by Accomplish AI researcher Oren Yomtov, target OpenAI's Codex coding agent, available as a command-line tool and a desktop app. Codex runs model actions inside a sandbox to prevent untrusted code from affecting the wider system, but both exploits defeat that boundary from within.

Heapjack targets a component called node_repl, which Codex Desktop writes into the global config file at install time with no opt-in. The component runs a single Node.js process holding two JavaScript execution contexts: one trusted (OpenAI's code) and one untrusted (agent code). Because both share one memory heap, a random token meant to authenticate the trusted context is accessible to the untrusted side. The exploit snapshots the heap to find the token, then uses it to write requests onto the same pipe the trusted context uses to communicate with an unsandboxed parent process. The parent executes the commands, enabling actions such as launching external applications, reaching Unix sockets (including a Docker daemon socket), or editing global configuration — all while Codex is in read-only mode.

The second flaw, Overpatch, exists in the open-source Codex CLI. In workspace-write mode the agent is restricted to the project folder, but the researchers found that Codex's apply_patch tool could write outside that boundary. By naming '/tmp' in a patch, the tool grants write access to the root directory, allowing arbitrary file modification.

OpenAI addressed both issues within eight days. The researchers note that Heapjack is particularly concerning because it can be triggered simply by opening a malicious repository and asking Codex a question about the code; the repository author gains unsandboxed command execution on the developer's machine.

§

Analysis

Why This Matters

  • Codex users who open repositories from untrusted sources risk immediate remote code execution with no warning.
  • The sandbox escape undermines a core security guarantee: that AI coding agents cannot harm the host system.
  • Shared memory sandbox designs may require rethinking, as multiple execution contexts within a single process leak sensitive tokens.

Background

AI coding assistants like Codex, GitHub Copilot, and others rely on sandboxing to isolate generated or suggested code. Sandbox escapes of varying severity have been reported in similar tools, often involving parser logic or permissions handling. The Heapjack technique is notable for working in the most restrictive mode, exploiting architectural separation rather than a simple bug.

Key Perspectives

Security researchers: Responsible disclosure is essential; the eight-day fix shows that the issue was taken seriously. They highlight that the config injection in node_repl lacks user opt-in and was inherited by CLI users without consent. OpenAI: Responded quickly with patches. The company has not commented publicly on whether it will redesign the sandbox or add opt-in mechanisms. Developers and enterprise users: Should be cautious when opening unknown repositories with Codex. The lack of a visible prompt or approval step in Heapjack makes it an attractive vector for supply-chain attacks.

What to Watch

  • Whether similar shared-memory sandbox patterns exist in other AI coding agents (e.g., Cursor, Copilot) and if researchers uncover analogous escapes.
  • OpenAI's public post-mortem or security advisory detailing the fixes and any architectural changes.
  • Adoption of sandbox escapes as a standard audit target for AI agent security evaluations.

Sources

newspaper

Zotpaper

Articles published under the Zotpaper byline are synthesized from multiple source publications by our AI editor and reviewed by our editorial process. Each story combines reporting from credible outlets to give readers a balanced, comprehensive view.