Sandbox modes
Codex supports three sandbox modes with increasing levels of access:- read-only
- workspace-write
- danger-full-access
Read-only mode permits:
- Reading files anywhere on the filesystem
- No write operations
- Network access (if enabled)
Platform-specific implementation
Codex uses different sandboxing technologies depending on your operating system:Linux: Landlock + seccomp
On Linux, Codex uses Landlock (kernel-level access control) combined with seccomp (system call filtering):-
Landlock enforces filesystem access rules
- Available on kernel 5.13+ (full support on 5.19+)
- Hierarchical path-based access control
- Restricts file read/write at the syscall level
-
seccomp restricts system calls
- Blocks network operations when network access is disabled
- Prevents privilege escalation
- Filters dangerous syscalls
- Namespace isolation (PID, network, mount)
- Read-only root filesystem with selective bind mounts
- Protected paths (
.git,.codex) re-bound as read-only - Managed network proxy for restricted network access
macOS: Seatbelt (App Sandbox)
On macOS, Codex uses Seatbelt, Apple’s sandbox profile system:- Enforces filesystem access rules via sandbox profiles
- Restricts network access when disabled
- Integrates with macOS security frameworks
- Uses
sandbox-execto apply profiles
- Sandbox mode (
read-only,workspace-write, etc.) - Writable roots (
cwdand--add-dirpaths) - Protected paths (
.git,.codex, etc.) - Network access settings
Windows: Restricted tokens + job objects
On Windows, Codex uses restricted tokens and job objects:- Restricted tokens limit privileges
- Removes admin rights
- Restricts access to sensitive resources
- Job objects enforce resource limits
- Process isolation
- Resource quotas
- Network policy enforcement
windowsSandbox/setupStart via the app-server API to configure.
Protected paths
Even inworkspace-write mode, certain paths are always read-only:
.git/- Git repository data.codex/- Codex configuration and datagitdir:symlinks - Git worktree references
Protected paths are enforced recursively. For example,
.git/hooks/ is also read-only.Network access
Network access is controlled independently of filesystem sandboxing:Network proxy (Linux Bubblewrap)
When using Bubblewrap with restricted network:- Network namespace is isolated via
--unshare-net - A managed proxy routes allowed traffic
- TCP connections are bridged through Unix domain sockets
- seccomp blocks new socket creation after setup
Additional writable directories
Extend the writable scope beyondcwd:
- Must be absolute paths
- Are added to the sandbox’s writable roots
- Still respect protected path rules
Sandbox escalation
When a command needs to escape the sandbox (e.g., to install packages, access/usr/local, or make network requests), the agent can request escalation.
How escalation works
Agent detects restriction
The command fails due to sandbox constraints (e.g., permission denied, network unreachable)
Approval integration
Sandbox escalation integrates with the approval system:- never - Auto-approve escalation (no sandbox)
- on-request - Prompt for escalation approval
- unless-trusted - Always prompt unless covered by policy
- on-failure - Only prompt after sandbox failures
Debugging sandbox issues
If commands fail unexpectedly in the sandbox:Check sandbox status
Enable full access temporarily
Review sandbox logs
On Linux with Landlock:Common issues
Permission denied writing to /usr/local
Permission denied writing to /usr/local
/usr/local is outside the workspace. Either:- Use
--add-dir /usr/localto make it writable - Use
--sandbox danger-full-accessfor full access - Allow the agent to request escalation
Network connection refused
Network connection refused
Network access may be restricted. Enable with:
Cannot modify .git directory
Cannot modify .git directory
.git is protected by default. Use danger-full-access or manually run git commands outside Codex.Landlock not supported on this kernel
Landlock not supported on this kernel
Landlock requires Linux kernel 5.13+. On older kernels:
- Upgrade your kernel, or
- Use
danger-full-accessmode (no sandbox)
Configuration
Configure sandboxing in~/.codex/config.toml:
Best practices
Use workspace-write by default
Provides good balance between safety and functionality
Enable network selectively
Only enable when tasks require internet access
Review escalation requests
Carefully examine commands before approving escalation
Use full-access sparingly
Reserve
danger-full-access for trusted environments onlyNext steps
Approvals
Configure when to prompt for permission
Non-interactive mode
Use sandboxing in CI/CD