Researchers escaped the OpenAI Codex sandbox twice — Heapjack and Overpatch, now patched
Oren Yomtov of Accomplish AI reported both on 12 August; OpenAI fixed them in about eight days. Heapjack worked in read-only Desktop. Update: Desktop ≥ 26.818.21641, CLI ≥ 0.149.0.
Deep dive3 minIn-depth
James Okonkwo3 min read
- OpenAI
- Codex
- Security
- Sandbox
- Agents

Photo: Luis Gomes / PexelsPexels License
Security researchers found two ways out of the OpenAI Codex sandbox, Ax Sharma reported for BleepingComputer on Sunday. One of them, they say, ran commands on a developer’s machine from Codex’s most locked-down mode, with no approval prompt and nothing shown on screen. Oren Yomtov of Accomplish AI reported both flaws to OpenAI on August 12. The company fixed them within about eight days, he said. The more serious path, which the researchers call Heapjack, turns a routine action into host execution: open someone else’s repository in Codex, ask a question about the code, and the person who wrote that repository gets unsandboxed commands on your computer. BleepingComputer asked OpenAI for comment before publishing.
Codex is OpenAI’s coding agent, as a command-line tool and a desktop app. Like rival agents, it is supposed to keep model actions inside a sandbox so untrusted code cannot touch the rest of the system. Both bugs, in Yomtov’s account, defeated that boundary from the inside.
Heapjack: a token in the same heap
Heapjack, Sharma wrote, targets a component called node_repl that Codex Desktop writes into the global Codex config at install. There is no opt-in and no setting to turn it off. Because the entry lives in the shared config, plain CLI users inherit the same tool without being asked. node_repl runs one Node.js process with two JavaScript contexts: a trusted side that holds OpenAI’s code, and an untrusted side that runs the agent. The trusted side proves itself with a random token minted each run. Both contexts share one memory heap, so that token is a string the untrusted side can read.
The untrusted code, in the write-up, snapshots the heap and looks for UUID-shaped strings, then uses a valid token to send work to a native, unsandboxed parent. The parent checks the token, sees a good one, and does the work. The researchers’ demonstration launched an application outside Codex’s process tree. The same access, they said, reaches Unix sockets — a Docker daemon being the obvious example — and a tool that edits the global config. All of that ran in read-only mode, the strictest setting, where the agent is not supposed to write anything. A commenter on Yomtov’s post put the design error in one line, which Sharma quoted: V8 contexts isolate globals, not memory, “so the sandbox was really a promise the heap never agreed to.”
Overpatch: the tool that granted its own rights
The second flaw sits in the open-source Codex CLI. In workspace-write mode the agent may only write inside the project folder; a shell command aimed at the home directory is refused. The researchers got Codex’s own patch tool, apply_patch, to write elsewhere anyway. The tool, Sharma reported, grants write access to the parent of each path named in a patch. Name a path whose parent is the root of the disk, and the grant widens that far. Their working demonstration combined that widened grant with a symlink into a shell startup file. Remove the first change and the write is refused. With it, the next terminal the developer opens runs the attacker’s line unsandboxed.
Both bugs share a shape: the enforcement lived inside the thing it was enforcing. apply_patch derived permissions from attacker-supplied paths. node_repl kept the secret that separated trusted from untrusted code in the same memory as the untrusted code. In July, Pillar Security showed a related class across Cursor, Codex, Gemini CLI and Google’s Antigravity: an agent that stays inside its sandbox writes a file a trusted tool outside the sandbox later runs. OpenAI fixed Heapjack in Codex Desktop build 26.818.21641 and Overpatch in Codex CLI 0.149.0, Accomplish said. Users should be on those versions or later. Eight days from report to patch is fast by disclosure standards. The class of mistake — a sandbox that takes the inmate’s word for the lock — is not new, and it is not unique to one vendor.


