# Codex Sandbox Profiles: Restrict Reads and Test Network Boundaries

Build a practical Codex permission profile with explicit secret-path denies, an enabled domain-filtering proxy and harmless tests of allowed and denied operations.

By Paras Madan | 2026-11-19


“Workspace access” is easy to misunderstand. You might expect an agent to see only the repository in front of it. Codex's built-in `:workspace` profile instead allows broad filesystem reads under your operating-system permissions, permits workspace edits and disables network access. Some configuration directories remain read-only.

OpenAI's November 18 [sandbox engineering explanation](https://openai.com/index/inside-the-codex-sandbox/) makes that tradeoff explicit: normal builds need tools and libraries outside the repository. Codex uses native operating-system restrictions rather than requiring the project to run inside a separate container.

That makes a custom profile worth considering when your development machine also contains credentials or unrelated client work. The aim is not to create the most restrictive configuration imaginable. It is to write down the access your task needs and check that the boundary actually holds.

## Start with one disposable project

I would begin with a small test repository, not an active production checkout. Make an inventory of the build command, source directories, caches and external services it needs. Put real credentials aside for this exercise.

Separate “must read” from “must edit.” A compiler needing a configuration file does not mean the agent needs permission to change it. Record the owner of each exception so a future build failure does not become an excuse to grant unrestricted access.

## Add explicit denies to the workspace profile

The public [permissions reference](https://learn.chatgpt.com/docs/permissions) supports named profiles and inheritance. This illustrative configuration keeps the built-in baseline while adding exact secret-location restrictions:

```toml
default_permissions = "reviewed-dev"

[permissions.reviewed-dev]
description = "Workspace editing with selected private paths denied."
extends = ":workspace"

[permissions.reviewed-dev.filesystem]
"~/.ssh" = "deny"
"~/.aws/credentials" = "deny"

[permissions.reviewed-dev.filesystem.":workspace_roots"]
".env" = "deny"
".env.local" = "deny"
"secrets" = "deny"
".vscode" = "read"

[permissions.reviewed-dev.network]
enabled = false
```

These example paths are not a complete secret inventory. Add the actual private locations on your machine, including unrelated repositories where appropriate. Exact paths also make the first test easier to interpret than a large collection of glob patterns.

Permission profiles are currently beta. They do not compose with older `sandbox_mode` settings: old settings or `--sandbox` can select the legacy configuration instead. Check the loaded configuration before assuming the new profile is active.

## Enable the proxy before trusting domain rules

If the task needs public documentation, replace the network section above and add these tables, avoiding duplicate TOML sections:

```toml
[features]
network_proxy = true

[permissions.reviewed-dev.network]
enabled = true

[permissions.reviewed-dev.network.domains]
"openai.com" = "allow"
"example.org" = "deny"
```

The crucial distinction is that `network.enabled = true` allows network access; it does not start the proxy. Without an active proxy, domain rules do not constrain direct connections. The permissions reference documents this explicitly.

Choose exact destinations for your actual task rather than copying a large generic allowlist. If a documentation request redirects elsewhere, investigate the destination before adding it. A successful connection is not evidence that the content is safe or that uploads to that service are appropriate.

## Test both success and refusal

The engineering article documents `codex sandbox --permission-profile NAME -- COMMAND` for applying a profile outside an agent session. In the disposable repository, create `normal.txt` and `secrets/canary.txt` beforehand, containing only harmless test strings.

Then run separate checks from that directory:

```bash
codex sandbox --permission-profile reviewed-dev -- cat normal.txt
codex sandbox --permission-profile reviewed-dev -- cat secrets/canary.txt
codex sandbox --permission-profile reviewed-dev -- sh -c 'printf ok > sandbox-output.txt'
```

The intended results are a readable normal file, a denied canary read and a successful workspace write. Record the actual output and exit status. Do not interpret “file not found” as proof of a working deny rule; establish that the fixture exists before testing.

For network checks, use harmless HEAD requests to the explicitly allowed and denied hosts. Inspect proxy logs or denial messages rather than treating any connection failure as success. DNS failures, certificate errors and unavailable servers test different things. Never attach source code, credentials or private query parameters to these probes.

## Keep the remaining boundaries visible

The [security cookbook](https://learn.chatgpt.com/docs/enterprise/security-cookbook) recommends testing allowed and denied operations, reducing inherited credential-bearing variables and using managed requirements when restrictions must survive profile changes. A custom profile alone does not protect someone who selects a different profile.

The cookbook also warns that filesystem restrictions cannot retract secrets already present in prompts or readable logs. An approved full sandbox escalation can bypass the local command proxy. Treat an escalation as a different execution context, not confirmation that the original boundary worked.

My rollout rule would be to preserve the test results alongside the configuration and repeat them after client or policy changes. Expand permissions for a named workflow only after explaining the failure. That is more useful than repeatedly switching off the sandbox until the build passes.

I'm Paras. I work at the intersection of AI, engineering and distribution.

I help AI teams explain technical products through clear documentation, practical guides and developer-focused content.

[Book a 30-minute call](https://cal.com/paras-madan/30min).
