Codex Sandbox Permissions: How to Diagnose Access Denied

Updated
8 min read
A terminal request stops at a gate before a protected folder.
TL;DR

A permission error can come from the workspace, the network, or the operating system. Find the layer that denied the action and make the smallest approved change.

A Codex task runs its tests, then fails when it tries to write generated files into a different directory. The useful question is which path the command tried to write. Once you have the path, you can tell whether the project opened in the wrong place, the job needs a separately approved destination, or the output belongs back inside the repo.

Codex sandbox permissions limit where commands can read and write and what network resources they can reach. Approval policy governs when Codex can ask for an exception. The official approvals and sandbox guide explains how those controls work together.

Read the error before changing a setting

Copy the command, the working directory and the exact path or host in the error. In an interactive CLI session, check the current workspace and mode with the status command described in the approvals guide. In the desktop app, look at the project’s source folders and the permission mode beneath the composer.

5 rows · Click column to sort
An ordinary file writeResolve the output path and check it belongs to the workspace you opened.
A write under a protected project directoryRead the selected profile and check whether the subdirectory has its own rule.
A package downloadCheck whether the command is allowed to use the network and reach that registry.
A service call that returns an authorization errorCheck the service account, requested operation and service-side policy.
An operation that also fails in your own normal shellCheck the operating system’s access controls or ask the machine owner.

A package manager may fail even though it can read your project. It might write a cache under your user directory or need a registry outside the sandbox. Inspect the failed action before asking for an exception. Keep the application’s normal test and install commands in AGENTS.md so the next agent can start with the intended workflow.

Fix the smallest authorised part of the task

If the app should have opened the repository but you selected its parent or a sibling, reopen the correct folder and rerun the smallest relevant command. If a generated file belongs in the checkout, point the generator at the project’s documented output directory. If the task really needs a protected file or an external service, have the owner review a narrowly scoped request.

OpenAI’s description of the Codex sandbox covers workspace roots, protected paths and network control. On managed Windows machines, consult the separate Windows sandbox guide and share the exact error with IT when it concerns managed requirements or operating system permissions.

Check the same boundary on the next run

Repeat the original small operation, then check that the resulting file or service request landed where you expected. If several developers see the same error, record the supported setup and the relevant project root. Our Codex harness checklist shows how to make approved locations part of an ordinary pull request workflow.

Example: a test passes and a generated file cannot be saved

Suppose a repo runs its tests in a workspace and writes a report after the tests finish. The command fails only when saving the report. First distinguish the test result from the final process status. The log may show a successful test run followed by a denied write. If you only restart the command, you get another green test and the same denied write.

Record where the report path came from. It might be relative to the working directory, configured in a project file, or supplied by an environment variable. Resolve it to the path the process actually attempted to open. If the destination belongs inside the project, use the project's existing output directory. If a different process consumes the file and owns the destination, confirm that contract with its maintainer.

Now repeat one small invocation with the intended destination. Confirm the original checks still run and the result lands in the right place. If the report must be retained by CI, verify that the CI job collects that same file. You can fix the immediate error and still break the team's workflow if you change the destination without telling the consumer.

Example: an ordinary read works and a Git write fails

A developer can read the workspace and edit a source file. A command then fails while trying to write Git metadata. It is tempting to call the entire workspace read-only because the last command said denied. The narrower diagnosis is that the Git operation touches a protected part of the project. OpenAI's permission profiles documentation describes more specific rules under a workspace, and managed configuration can further restrict which choices are available.

Ask whether the task actually calls for changing Git state. Inspecting a diff and running a test often serve the immediate review. If the operation is needed, follow the approved process for that command in your environment. Record the action you need in the request. The owner should be able to decide from the command and target rather than guessing what a general permission change would allow.

The same pattern applies when a tool tries to update its own cache in a different directory. Find the path first. If the project already offers a workspace cache, try the documented setup. If IT administers the directory, send them the exact command and location. Distinguish the observable fact about the denied write from your hypothesis about how it should be configured.

Example: an API call fails after a successful network connection

A service request can fail at more than one layer. Start from the error that actually returned. If the process cannot connect to a host, check the allowed network route, proxy, or endpoint with the owner. If it reaches the service and receives an explicit authorization error, check the identity and operation as well. An approval inside the coding client does not change the provider’s access rules.

For example, a dependency can fetch metadata from one host and fetch the package from a second host. The first response alone does not tell you the second route is allowed. Capture the failing request and verify that the second host is part of the approved workflow. A well-scoped report names the expected registry and the action the build tried. Avoid circulating credentials or full environment dumps when a destination and a status are enough.

If you need to test a service integration, use an approved test environment with a minimally scoped account and synthetic data. Our OpenAI on AWS guide covers a related case where a provider's own model access, endpoint, and deployment identity must be checked separately.

Write a permission report somebody else can act on

A useful report has enough information to reproduce the denial and enough context to decide whether the action belongs in the task. It can fit in a short work item:

  • The expected result and why the blocked action is necessary.
  • The command and working directory, with credentials omitted.
  • The exact path, registry, or service operation the error refers to.
  • The active workspace or permission profile and the affected environment.
  • Whether the same action works under the developer's usual access.
  • The smallest approved change or next diagnostic step.

Where managed policy applies, give the administrator the client and operating system version. A reproduction that describes the user's expectation, the exact denied access, and the current setup is easier to investigate than a collection of unrelated logs. Leave personal paths or details out of public reports if they are unnecessary for the problem.

Make the setup predictable for the next developer

Once you resolve the denial, document the location the project should be opened from and which commands it expects to run. Include any setup that happens outside a normal task with the team that maintains it. If output belongs in an existing project directory, record that choice beside the command so it can be checked in review. If the task does not need network access after setup, keep the setup and test instructions distinct.

Finally, rerun one small path from a fresh task. Confirm that a developer can use the documented permissions and still get the expected result. If they need a separate approval, verify that the prompt describes the operation clearly. The best outcome is a task whose permissions a teammate can understand when they first open it.

Keep a small example for onboarding

Imagine a developer opening the repository for the first time. Give them a task that reads one source file and runs one ordinary package check. Put the supported output directory and any known external dependency in the task card. The developer can tell whether the basic workflow is available before asking for a change in permissions.

If their run differs from yours, compare how the project was opened, what the client reported as the current workspace, and whether both machines apply the same policy. This is a cheap way to distinguish a shared configuration problem from a machine-specific restriction. Once you resolve the difference, put the specific fix in the setup notes where the next person will see it.

For example, an onboarding note can say that package checks expect the repository root and use a temporary directory already approved by the team. It can also name the owner who manages network access for dependency setup. These two facts can prevent a routine test failure from becoming a broad request for more access.

When a task is delegated, set the permission boundary at the parent session. The Codex subagent context guide explains how the boundary carries over. A useful handoff gives the child the paths needed for the task and tells it what to report if a path is denied.

Frequently Asked Questions

Why can Codex read a file but not edit it?

The active permission profile or operating system may allow reads while denying writes. Check the workspace root, the specific target, and any protected subpath.

Are the Codex sandbox and approval policy the same thing?

The sandbox limits what a process can reach. Approval policy determines when the client may request or review an exception.

Can a file be denied even if it is under the workspace root?

Yes. Certain directories can have more restrictive rules than the workspace around them. Managed requirements and operating system permissions can also apply.

#codex#developer-tools#sandboxing#access-control

One AI engineering post, weekly

LLM benchmarks, prompt techniques, and token-cost breakdowns, delivered to your inbox.

What should we test or explain next?

Comments

Have a question or something to add? Sign in to join the discussion.

Mahmudul Haque Qudrati — CEO & ML Engineer at Pristren

Mahmudul Haque Qudrati

CEO & ML Engineer

Software architect, full-stack engineer, and machine learning practitioner. Founder & CEO of Pristren, CTO at Venture Kick-backed PIN Sport Application GmbH (Basel, Switzerland), Software Development Lead at DailyFrame GmbH (building Dimetra patient transport software), and creator of Zlyqor. Focused on custom workflow automation, scalable web and mobile applications, and production AI/ML systems.