Back to Blog
AI & Technology

Building a Secure Sandbox: Unlocking the Full Potential of Codex on Windows

Building a Secure Sandbox: Unlocking the Full Potential of Codex on Windows When OpenAI's Codex was first introduced to Windows, users faced a dilemma: they could either approve every command the ...

Building a Secure Sandbox: Unlocking the Full Potential of Codex on Windows
SG
Saksham Gupta
Founder & CEO
May 19, 2026
3 min read

Building a Secure Sandbox: Unlocking the Full Potential of Codex on Windows

When OpenAI's Codex was first introduced to Windows, users faced a dilemma: they could either approve every command the coding agent wanted to run, which was tedious, or enable Full Access mode, which was risky. This lack of a sandbox environment on Windows presented significant security challenges, given Codex's ability to execute commands with the same permissions as the user. A robust solution was needed to balance the power of Codex with the necessary safety protocols.

The Need for a Sandbox Environment

Codex functions by facilitating a seamless interaction between a developer and a cloud-based AI model. The challenge lies in ensuring that Codex, while powerful, operates within safe and controlled parameters. A sandbox environment provides such a framework by isolating the execution of commands and ensuring that any potentially harmful operations are contained and controlled.

Challenges with Existing Windows Tools

Windows offers several tools for process isolation, but none were suitable for Codex's requirements:

  • AppContainer: Although it offers strong isolation, it is designed for applications with predefined resource needs, unlike the dynamic and varied workflows Codex handles.
  • Windows Sandbox: This tool provides a strong isolation boundary but is impractical for Codex as it requires operating within a separate desktop environment.
  • Mandatory Integrity Control (MIC): While promising on paper, MIC's broad application of integrity labels posed risks by potentially altering the trust model of a developer's workspace.

Given these limitations, the Codex engineering team embarked on creating a custom sandbox solution specifically tailored for Windows.

Developing the "Unelevated Sandbox"

The initial solution, dubbed the "unelevated sandbox," aimed to provide robust security without requiring administrative privileges. This approach focused on two key aspects: limiting file writes and controlling network access.

Limiting File Writes

The unelevated sandbox used Security Identifiers (SIDs) and write-restricted tokens to control file access. By creating a synthetic SID unique to the Codex sandbox, the team was able to precisely define where Codex could modify the filesystem. This setup ensured that file operations were tightly controlled, maintaining the balance between security and functionality.

Controlling Network Access

Network access posed a significant challenge. The sandbox aimed to make network tools fail-closed, prompting user approval for any internet-facing operations. This was achieved through a series of environment overrides designed to redirect network requests to dead endpoints. However, this method relied on advisory controls that could be bypassed by more sophisticated processes.

Transitioning to the "Elevated Sandbox"

Recognizing the limitations of the unelevated sandbox, particularly in network suppression, the team developed an "elevated sandbox" that required administrative permissions during setup. This iteration introduced several enhancements:

  • User Creation: Two local users, CodexSandboxOffline and CodexSandboxOnline, were created to separate processes based on their network access requirements.
  • Firewall Implementation: By utilizing Windows Firewall, the elevated sandbox could enforce strict network rules, blocking all outbound traffic for the offline user.
  • Setup Enhancements: The setup process was expanded to include the creation of synthetic SIDs, user accounts, and firewall rules, ensuring a comprehensive security framework.

The Final Architecture

The elevated sandbox consists of multiple components working in tandem to ensure security:

  1. codex.exe: The primary executable managing user interactions.
  2. codex-windows-sandbox-setup.exe: Handles all elevated setup tasks.
  3. codex-command-runner.exe: Executes user commands under restricted tokens.
  4. Child Process: The actual execution environment for Codex commands.

This architecture provides a secure and efficient environment for Codex, allowing developers to leverage its capabilities without compromising their system's integrity.

Balancing Security and Usability

The journey to build a secure sandbox for Codex on Windows highlighted the importance of balancing security with usability. The final design not only addresses the initial security concerns but also ensures that Codex remains a powerful tool for developers. By integrating multiple Windows security features and custom solutions, the sandbox provides a safe yet effective environment for Codex operations.

In conclusion, the development of a secure sandbox for Codex on Windows represents a significant advancement in enabling safe AI-driven coding environments. It underscores the importance of tailored security solutions that address specific platform limitations while empowering users to fully harness the potential of AI in software development.

Share this article
SG

Saksham Gupta

Founder & CEO

Saksham Gupta is the Co-Founder and Technology lead at Edubild. With extensive experience in enterprise AI, LLM systems, and B2B integration, he writes about the practical side of building AI products that work in production. Connect with him on LinkedIn for more insights on AI engineering and enterprise technology.