Windows: codex exec --sandbox workspace-write remains read-only
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.txtis 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 sandboxparent; - 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
workspace-writeis passed explicitly tocodex exec.- The command is launched directly from a host process.
- Parent sandbox depth is zero.
- Codex exits with code 0.
- The expected workspace file is not created.
- 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
- Is this a known limitation or bug in Codex CLI on Windows?
- Is
codex exec --sandbox workspace-writeexpected to support creating files in its working directory on Windows? - Is there an officially supported configuration required to make the workspace writable?
- Is an isolated and authenticated
CODEX_HOMEsupported without copying credential material? - 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?
- On Windows, create a new empty temporary folder, for example:
mkdir C:\Temp\codex-workspace-test
cd C:\Temp\codex-workspace-test
- Create a simple prompt or input asking Codex to create a file named
OUTPUT.txtin the current working directory.
- 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"
- Wait for the command to complete.
- Check the exit code and verify whether the file exists:
$LASTEXITCODE
Test-Path .\OUTPUT.txt
- The command exits successfully with exit code
0, butTest-PathreturnsFalsebecauseOUTPUT.txtis not created.
- Repeating the test with direct host-side execution, parent sandbox depth
0, sanitizedCODEX_*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_
2 Comments
Potential duplicates detected. Please review them and close your issue if it is a duplicate.
Powered by Codex Action
Additional reproduction and bounded workaround from a real packed-consumer smoke:
codex exec --sandbox workspace-write --ephemeral --json, approvalnever, network disabled.%TEMP%, both an ambient run and an auth-only isolatedCODEX_HOMErun reproduced the effective read-only behavior: PowerShell/cmd calls were policy-blocked andapply_patchreported a read-only sandbox. Neither run created the requested file. The second run also still discovered user-level~/.agentsskills and exposed connected app/MCP context, soCODEX_HOMEisolation alone was insufficient.CODEX_HOME,HOME, andUSERPROFILE, 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.[windows] sandbox = "elevated"failedcodex doctorbecause 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.