The vulnerability in Codex CLI was a sandbox bypass caused by improper handling of the current working directory (cwd). The core issue was that the cwd provided by a language model could be used to define the root of the sandbox's writable area. This allowed a malicious model output to specify a cwd outside of the user's intended workspace, effectively bypassing the sandbox and enabling arbitrary file writes and command execution on the user's machine.
The patch addresses this by separating the concept of the command's working directory from the sandbox's policy boundary. The key changes were made in the functions responsible for spawning sandboxed processes (spawn_command_under_seatbelt for macOS and spawn_command_under_linux_sandbox for Linux) and the functions that call them.
The analysis of the commit 8595237505a1e0faabc2af3db805b66ce3ae182d reveals that these functions were modified to accept two separate path arguments: command_cwd and sandbox_policy_cwd. The command_cwd is the working directory for the executed command (which can be specified by the model), while the sandbox_policy_cwd is a trusted path based on the user's session, used to enforce the sandbox's security policy. By doing this, the sandbox's boundary is no longer determined by potentially malicious model input.
The identified vulnerable functions are the ones that were part of this flawed logic. During an exploit, these functions would be present in the call stack, with run_command_under_sandbox and process_exec_tool_call initiating the process and the spawn_command_under_* functions directly creating the misconfigured sandbox.