codex icon indicating copy to clipboard operation
codex copied to clipboard

Windows: codex exec --sandbox workspace-write remains read-only

Open gmacca77 opened this issue 4 months ago • 3 comments

What issue are you seeing?

Summary

On Windows, codex exec --sandbox workspace-write starts successfully and exits with code 0, but the effective sandbox remains read-only.

The command is launched directly from the host process. There is no external codex sandbox wrapper, no command-runner parent, and the parent sandbox depth is zero.

Despite requesting workspace-write, Codex cannot create the expected file inside the working directory.

Environment

  • Operating system: Windows
  • Product: OpenAI Codex CLI
  • Execution mode: codex exec
  • Requested sandbox: workspace-write
  • Effective sandbox: read-only
  • Parent sandbox depth: 0
  • External sandbox parent: none
  • Command runner parent: none
  • Network access: disabled
  • Approval escalation: disabled

I can provide the exact Codex version, executable checksum and Windows build from the sanitized diagnostic package.

Minimal reproduction

Run Codex from a normal host-side process, using a temporary working directory containing an input file.

Example command:

codex exec --json --sandbox workspace-write --output-schema "<SANITIZED_SCHEMA_PATH>"

The prompt asks Codex to create a simple file named OUTPUT.txt in the current working directory.

Expected behavior

Because --sandbox workspace-write is requested and the current working directory is the authorized workspace, Codex should be able to create:

OUTPUT.txt

inside that directory.

Writes outside the authorized workspace should remain blocked.

Actual behavior

  • Codex starts successfully.
  • The execution exits with code 0.
  • Structured execution events are produced.
  • The effective inner sandbox behaves as read-only.
  • OUTPUT.txt is not created.
  • The final workspace validation therefore fails.

Diagnostics already performed

We verified the following:

  • direct host-side execution;
  • parent sandbox depth is zero;
  • no codex sandbox parent;
  • no command-runner parent;
  • isolated working directory;
  • sanitized CODEX_* environment variables;
  • isolated configuration and rules;
  • explicit --sandbox workspace-write;
  • workspace path and current working directory alignment;
  • executable path and checksum validation;
  • process-tree validation;
  • filesystem snapshots before and after execution;
  • side-effect scanning;
  • write capability from the host launch point;
  • no retry or fallback.

A separate non-AI write gate using the same host-side environment can successfully write inside the workspace. The read-only behavior appears when codex exec applies its effective inner sandbox.

Observed facts

  1. workspace-write is passed explicitly to codex exec.
  2. The command is launched directly from a host process.
  3. Parent sandbox depth is zero.
  4. Codex exits with code 0.
  5. The expected workspace file is not created.
  6. Filesystem evidence shows that the Codex execution had effective read-only behavior.

Inference

The sandbox mode used internally by codex exec on Windows may not be applying or propagating the requested workspace-write policy correctly.

This is an inference based on the observed behavior, not a confirmed OpenAI diagnosis.

Security impact

Using an unrestricted sandbox is not an acceptable workaround.

The required behavior is:

  • write access only inside the designated workspace;
  • no write access outside it;
  • no network access;
  • no approval escalation.

Workarounds attempted

  • direct host-side execution;
  • removal of nested sandbox wrappers;
  • sanitized Codex environment;
  • isolated configuration;
  • isolated rules;
  • isolated working directory;
  • explicit sandbox argument;
  • pre-launch write validation;
  • process-tree validation.

These did not change the effective read-only behavior inside codex exec.

We did not use unrestricted filesystem access or copy authentication credentials into an unsupported environment.

Questions

  1. Is this a known limitation or bug in Codex CLI on Windows?
  2. Is codex exec --sandbox workspace-write expected to support creating files in its working directory on Windows?
  3. Is there an officially supported configuration required to make the workspace writable?
  4. Is an isolated and authenticated CODEX_HOME supported without copying credential material?
  5. Are there additional diagnostic logs or flags that would help identify the effective sandbox policy?

Additional evidence

I have a sanitized reproduction package containing:

  • a minimal PowerShell reproduction script;
  • Codex version and executable checksum;
  • sanitized process tree;
  • requested-versus-effective sandbox evidence;
  • sanitized environment details;
  • filesystem diff;
  • attempted-workaround matrix.

I can attach or paste the relevant sanitized files if requested.

GP_AUTONOMOUS_COMMANDER_STEP2_UPSTREAM_SUBMISSION_RESULT.json GP_AUTONOMOUS_COMMANDER_STEP2_UPSTREAM_ATTACHMENT_MANIFEST.json GP_AUTONOMOUS_COMMANDER_STEP2_UPSTREAM_CHANNEL_VALIDATION.json GP_AUTONOMOUS_COMMANDER_STEP2_UPSTREAM_ISSUE_FINAL.md GP_AUTONOMOUS_COMMANDER_STEP2_UPSTREAM_MANUAL_SUBMISSION_INSTRUCTIONS.md GP_AUTONOMOUS_COMMANDER_STEP2_UPSTREAM_SANITIZATION_REPORT.json GP_AUTONOMOUS_COMMANDER_STEP2_UPSTREAM_SUBMISSION_DECISION.json GP_AUTONOMOUS_COMMANDER_STEP2_UPSTREAM_SUBMISSION_REPORT.md

What steps can reproduce the bug?

  1. On Windows, create a new empty temporary folder, for example:
mkdir C:\Temp\codex-workspace-test
cd C:\Temp\codex-workspace-test
  1. Create a simple prompt or input asking Codex to create a file named OUTPUT.txt in the current working directory.

  2. Run Codex directly from the host process with no external sandbox wrapper and no command runner parent:

codex exec --json --sandbox workspace-write "Create a file named OUTPUT.txt in the current working directory containing the text: workspace write test"
  1. Wait for the command to complete.

  2. Check the exit code and verify whether the file exists:

$LASTEXITCODE
Test-Path .\OUTPUT.txt
  1. The command exits successfully with exit code 0, but Test-Path returns False because OUTPUT.txt is not created.

  2. Repeating the test with direct host-side execution, parent sandbox depth 0, sanitized CODEX_* environment variables, isolated configuration, and the working directory set to the authorized workspace produces the same result.

Expected result: OUTPUT.txt is created inside the current workspace, while writes outside the workspace remain blocked.

Actual result: the effective sandbox behaves as read-only even though --sandbox workspace-write was explicitly requested.

What is the expected behavior?

codex exec --sandbox workspace-write should allow Codex to create and modify files inside the current authorized workspace.

In this test, Codex should create:

OUTPUT.txt

in the current working directory with the requested content.

Writes outside the authorized workspace should remain blocked, network access should remain disabled, and no approval escalation should be required.

The command should therefore complete with exit code 0 and Test-Path .\OUTPUT.txt should return True.

Additional information

No response

gmacca77 avatar Jul 23 '26 15:07 gmacca77

Potential duplicates detected. Please review them and close your issue if it is a duplicate.

  • #34958

Powered by Codex Action

github-actions[bot] avatar Jul 23 '26 15:07 github-actions[bot]

Additional reproduction and bounded workaround from a real packed-consumer smoke:

  • Environment: codex-cli 0.149.0, Windows 11 Pro 10.0.26200 (x64), codex exec --sandbox workspace-write --ephemeral --json, approval never, network disabled.
  • With the disposable Git repo under %TEMP%, both an ambient run and an auth-only isolated CODEX_HOME run reproduced the effective read-only behavior: PowerShell/cmd calls were policy-blocked and apply_patch reported a read-only sandbox. Neither run created the requested file. The second run also still discovered user-level ~/.agents skills and exposed connected app/MCP context, so CODEX_HOME isolation alone was insufficient.
  • Moving the fixture under the authorized repository root, isolating all three of CODEX_HOME, HOME, and USERPROFILE, disabling apps/plugins/connectors, and setting [windows] sandbox = "unelevated" made the same workspace-write smoke pass. Codex read the generated project-local skill, executed PowerShell, wrote the exact requested 25-byte file, and produced nonempty workflow artifacts.
  • Before that workaround, [windows] sandbox = "elevated" failed codex doctor because sandbox ACL provisioning was incomplete/outdated. I did not run the suggested elevated setup command, since machine-level ACL mutation was outside the test authorization.

So this still appears to be a native-Windows sandbox/provisioning and isolation problem, not an application-level write failure. The unelevated setting plus fully isolated home roots is a working bounded workaround here, but the default/elevated path remains broken. A documented hermetic mode that excludes global skills/apps and reports effective sandbox/provisioning before the model turn would also prevent very expensive false starts.

No auth material, raw transcript, or plugin catalog is included.

PatrickSys avatar Aug 21 '26 18:08 PatrickSys

Codex under a dedicated Windows account: unattended operation and verifiable code changes — does anyone have a working integration?

  • Date: 2026-10-13 · Authors: Chasper (desktop) and Claude, corrected against measurements · Release: Joe
  • Purpose: question to developers of comparable Codex integrations (GitHub Discussions of the projects named in the analysis, openai/codex Discussions)
  • German original: Codex_Integrationsanfrage_20261013_de.md

Hello everyone,

we are building AUOJI OrderBoard, a task board for software development based on .NET and WinUI 3. Five local AI agents are meant to work together in it. Each agent runs under its own standard Windows user account in its own working copy and receives its assignments through an MCP server of the board.

Claude Code has been working in this system for a month without comparable problems. We have now spent about three weeks working intensively on the Codex integration and its troubleshooting.

Our environment and integration:

  • Windows 11 Pro 25H2
  • Codex CLI 0.154.0
  • Invoked via codex exec --json
  • Configuration passed at start: mcp_servers.orderboard.url, an explicit approval_mode = "approve" for each required tool, sandbox_mode = "danger-full-access" and approval_policy = "never"
  • For code changes, our service starts a separate Codex child process on demand under the same Windows account.

What works: Codex has been reading and writing our board documents through MCP tools repeatably for weeks. Communication and MCP-based document editing are therefore working in principle.

Where we are stuck:

1. Operation without a logged-on desktop session

Our current scheduled task uses InteractiveToken. Without a logged-on session of the agent account, our start service refuses the start with the Task Scheduler's message that no logged-on Windows session with a user token exists for that SID.

We have not yet achieved unattended operation without that session. Claude Code runs under the same conditions as a background process in session 0, without a logged-on desktop session.

In addition, we are investigating the profile requirements of the Codex sandbox. Issue openai/codex#17458 describes uninitialized sandbox user profiles, including a reproduction with CLI 0.154.0. Whether that issue explains our difficulties with operation without a desktop session has not been proven yet.

2. MCP approvals in non-interactive operation

In our tests the required MCP calls only worked once we set an explicit approval_mode = "approve" per tool. With that configuration they work. The general setting approval_policy = "never" alone was not sufficient in our flow.

We would like to know whether other integrators take the same route or use another supported mechanism. The discussion in issue openai/codex#24135 is related.

3. No verified code changes by the separate execution agent

Since 30 September 2026 our logs contain 467 starts of the execution agent. For that period we cannot prove a single successful code change by it.

Our own logs contain 42 errors:

  • 38 messages "no account SID registered" on 30 September and 1 October;
  • four messages "Pipe is broken" since 10 October.

These errors sit in our integration and communication layer. We do not attribute them to Codex without further evidence.

Our service does not log explicit success messages, only warnings on failure. From the absence of further warnings we therefore cannot infer a successful programming run. The result of the Codex child process currently flows back only into the calling Codex session; our service logs lack a complete record of its tool execution and its result.

The working copy currently has no pending changes. All Codex backups in it since 1 October are owned by the sandbox account CodexSandboxOffline; they therefore come from the Codex desktop app in the developer's logged-on session, not from the child process under the agent account. There is not a single file from the child process. That is our finding so far, not a complete record of all file operations.

Our questions to developers of comparable integrations:

  • Do you run Codex on native Windows as a service or scheduled task under a dedicated user account, without a logged-on desktop session? With which start mode and which profile initialization?
  • Which exact Codex version do you use, and do you use exec or the app server?
  • How do you handle MCP approvals in unattended operation?
  • With separate Codex execution processes, how do you capture tool calls, errors and results so that you can distinguish actually applied code changes from merely completed agent runs?

We are looking for experience from a working integration and would very much appreciate an exchange. We can put together a sanitized start command and relevant diagnostic excerpts.


History

  • 2026-10-13 · Translated from the German version after Joe's release; wording follows the German text paragraph by paragraph.

RealJoeBlack avatar Oct 13 '26 14:10 RealJoeBlack