Skip to content

Windows sandbox: apply_patch can add files but cannot update/delete existing files due to apply deny-read ACLs #31229

Open

Description

@pellorao

What version of Codex CLI is running?

codex-cli 0.142.5

What subscription do you have?

business

Which model were you using?

gpt-5.5

What platform is your computer?

Microsoft Windows NT 10.0.26200.0

What terminal emulator and version are you using (if applicable)?

Windows PowerShell 5.1.26100.8655

Codex doctor report

What issue are you seeing?

On Windows, apply_patch can create new files, but fails whenever it needs to read an existing file for Update File or Delete File. The failure happens even in a clean repro directory outside the main
project, so it does not appear related to project config, AGENTS.md, Git state, dependencies, symlinks, or file ACLs.

Error:

apply_patch verification failed: Failed to read file to update ...:
fs sandbox helper failed with status exit code: 1:
windows sandbox failed: helper_unknown_error: apply deny-read ACLs

What steps can reproduce the bug?

cd C:\data\javascript
mkdir codex-sandbox-repro
cd codex-sandbox-repro
git init
mkdir .scratch
"hello" | Set-Content .scratch\test.txt
Get-Content .scratch\test.txt

Then ask Codex to run:

*** Begin Patch
*** Update File: .scratch/test.txt
@@
-hello
+hello world
*** End Patch

Observed:

  • apply_patch Add File succeeds.
  • Get-Content can read the file.
  • icacls shows normal inherited permissions including CodexSandboxUsers modify rights.
  • apply_patch Update File fails with apply deny-read ACLs.
  • apply_patch Delete File fails with the same error.
  • Running shell commands with escalation works, so a workaround is to use PowerShell writes, but apply_patch has no escalation parameter.

What is the expected behavior?

apply_patch should be able to read and update/delete files inside the workspace when normal shell reads succeed and ACLs permit access.

Additional information

  • Starting Codex from the project root and using relative paths did not help.
  • Reading the target with Get-Content immediately before apply_patch did not help.
  • Switching to “Approve for me” did not help.
  • The same failure reproduced in a clean C:\data\javascript\codex-sandbox-repro git repo.

Activity

  1. added
    bug
    on Jul 6, 2026
  2. added
    CLI
    windows-os
    sandbox
    on Jul 6, 2026
  3. pellorao commented on Jul 10, 2026

    @pellorao
    Author

    I checked the suggested potential duplicates.

    I think #30712 and the unelevated part of #31220 are closely related, but they do not look like the exact same failure mode as this issue.

    This issue fails with:

    windows sandbox failed: helper_unknown_error: apply deny-read ACLs
    

    apply_patch Add File succeeds, but Update File / Delete File fail when the fs-helper tries to read an existing workspace file. Normal PowerShell reads succeed in the same clean repro directory.

    By contrast, #30712 fails earlier while preparing the unelevated sandbox wrapper:

    windows unelevated restricted-token sandbox cannot enforce split writable root sets directly
    

    That looks like a split writable-root enforcement problem, while this issue looks like the helper launches but then incorrectly denies reading an existing file.

    #31220 includes the same split-root failure as #30712, plus a separate elevated-mode CreateProcessAsUserW failed: 1312 problem.

    #31086, #30964, and #29938 look related to Windows sandbox/setup-helper failures, but they center on codex-windows-sandbox-setup.exe, ShellExecuteExW failed to launch setup helper: 1223, module-not-found dialogs, or proxy/setup-marker mismatch. Those seem related but not exact duplicates of this apply deny-read ACLs repro.

    So my suggestion would be:

  4. pellorao commented on Jul 10, 2026

    @pellorao
    Author

    I closed #31248 as likely related to this Windows sandbox read/ACL issue, but I want to preserve one additional data point.

    In my reproduction, view_image failed with:

    windows sandbox failed: helper_unknown_error: apply deny-read ACLs
    

    This happened while using the elevated Windows sandbox. The local image existed on disk and was readable from PowerShell.

    After changing:

    [windows]
    sandbox = "elevated"

    to:

    [windows]
    sandbox = "unelevated"

    view_image started working correctly.

    So this may be useful evidence that the view_image failure is tied to the elevated Windows sandbox read/ACL path, not to image decoding or file existence.

    I later encountered a different failure mode in unelevated mode:

    windows unelevated restricted-token sandbox cannot enforce split writable root sets directly
    

    I think that should be tracked separately from this apply deny-read ACLs issue. The two failure modes appear different:

    • apply deny-read ACLs: helper runs but denies reading an existing local file.
    • split writable root sets: unelevated sandbox rejects the writable-root configuration before the tool can run.
  5. chess-oai commented on Sep 18, 2026

    @chess-oai
    Contributor

    could you share the setup error: entry and following error lines from %USERPROFILE%\.codex\.sandbox\sandbox.YYYY-MM-DD.log after reproducing?

    also, is .codex\.sandbox\deny_read_acl_state.json empty or valid json? no need to share its contents

  6. pellorao commented on Sep 21, 2026

    @pellorao
    Author

    This problem plagued me for far too long; I've now switched to running it under WSL.
    The original installation has been uninstalled, and the previous logs are gone as well.

    could you share the setup error: entry and following error lines from %USERPROFILE%\.codex\.sandbox\sandbox.YYYY-MM-DD.log after reproducing?

    also, is .codex\.sandbox\deny_read_acl_state.json empty or valid json? no need to share its contents

  7. leeeunzzi commented on Sep 23, 2026

    @leeeunzzi

    I can reproduce this issue consistently on native Windows with codex-cli 0.156.0, in both Codex CLI and Codex Desktop.

    I tested this while trying to enforce a company security policy that prevents Codex from reading sensitive configuration files while still allowing normal source-code editing.

    Environment

    Windows (native, not WSL)
    codex-cli 0.156.0
    Windows sandbox: elevated

    What I observed

    Without any filesystem deny rules:
    Reading normal files works
    Creating new files works
    Editing existing files with apply_patch works
    With sensitive files configured as deny under filesystem:
    Reading normal files works
    Reading denied sensitive files is correctly blocked
    Creating new files still works
    Editing existing normal files fails with Failed to apply patch

    I reproduced the same behavior with the filesystem rules defined in:

    the user config.toml
    the managed requirements.toml

    Removing only the filesystem deny configuration immediately makes apply_patch work again.

    I also confirmed that the target normal files are not read-only and that the Windows user has normal modify permissions on them.

    This makes it difficult to deploy Codex in our organization: we need to prevent Codex from reading files containing DB credentials, API keys, server information, etc., while still allowing developers to edit existing source files normally.

    Could you please confirm whether this is a known limitation/bug in the native Windows sandbox, and whether a fix or supported workaround is planned?

    I would be happy to provide additional reproduction details if needed.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    CLIbugsandboxwindows-os

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions