Skip to content

 Windows workspace-write: Python-created directory becomes inaccessible to the sandbox token #51874

Open

Description

@advaitmadhekar

What version of Codex CLI is running?

  • Codex CLI 0.161.0

What subscription do you have?

plus

Which model were you using?

No response

What platform is your computer?

windows

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

No response

Codex doctor report

Codex Doctor v0.161.0 · windows-x86_64

Notes
   ⚠ security     Microsoft Defender can interfere with Codex. Verify Codex exclusions.
   ⚠ mcp          MCP configuration has optional issues - Set the missing MCP env vars or disable the affected server.
─────────────────────────────────────────────────────────────

Environment
  ✓ system       en-US
      os                       Windows 10.0.26300 (Windows 11 Core) [64-bit]
      OS language              en-US
      VISUAL                   not set
      EDITOR                   not set
  ✓ disk         sufficient free disk space (24.4 GiB)
      warning threshold        5.0 GiB
      failure threshold        1.0 GiB
      CODEX_HOME available     24.4 GiB
      worktree available       24.4 GiB
  ⚠ security     Microsoft Defender can interfere with Codex. Verify Codex exclusions.
      endpoint products        Microsoft Defender
      exclusion targets        signed Codex app; codex.exe; codex-windows-sandbox-setup.exe; codex-command-runner.exe; codex-code-mode-host.exe
    ▸ Codex exclusions         not verified (expected Codex application and helper exclusions)
    → Microsoft Defender: Add a certificate or executable-path exclusion for Codex and its helpers. If Attack Surface Reduction blocks Codex, add a rule exclusion. If Controlled Folder Access blocks Codex, allow the app.
  ✓ runtime      standalone (windows, package C:\Users\madhe\.codex\packages\standalone\releases\0.161.0-x86_64-pc-windows-msvc, bin C:\Users\madhe\.codex\packages\standalone\releases\0.161.0-x86_64-pc-windows-msvc\bin, resources C:\Users\madhe\.codex\packages\standalone\releases\0.161.0-x86_64-pc-windows-msvc\codex-resources, path C:\Users\madhe\.codex\packages\standalone\releases\0.161.0-x86_64-pc-windows-msvc\codex-path)
      version                  0.161.0
      install method           standalone (windows, package C:\Users\madhe\.codex\packages\standalone\releases\0.161.0-x86_64-pc-windows-msvc, bin C:\Users\madhe\.codex\packages\standalone\releases\0.161.0-x86_64-pc-windows-msvc\bin, resources C:\Users\madhe\.codex\packages\standalone\releases\0.161.0-x86_64-pc-windows-msvc\codex-resources, path C:\Users\madhe\.codex\packages\standalone\releases\0.161.0-x86_64-pc-windows-msvc\codex-path)
      commit                   unknown
      executable               C:\Users\madhe\AppData\Local\Programs\OpenAI\Codex\bin\codex.exe
  ✓ install      consistent
      context                  standalone (windows, package C:\Users\madhe\.codex\packages\standalone\releases\0.161.0-x86_64-pc-windows-msvc, bin C:\Users\madhe\.codex\packages\standalone\releases\0.161.0-x86_64-pc-windows-msvc\bin, resources C:\Users\madhe\.codex\packages\standalone\releases\0.161.0-x86_64-pc-windows-msvc\codex-resources, path C:\Users\madhe\.codex\packages\standalone\releases\0.161.0-x86_64-pc-windows-msvc\codex-path)
      managed by               npm: no · bun: no · pnpm: no · Vite+: no · package root —
      PATH entries (1)         C:\Users\madhe\AppData\Local\Programs\OpenAI\Codex\bin\codex.exe
  ✓ search       file exists (bundled, C:\Users\madhe\.codex\packages\standalone\releases\0.161.0-x86_64-pc-windows-msvc\codex-path\rg.exe)
      search command           C:\Users\madhe\.codex\packages\standalone\releases\0.161.0-x86_64-pc-windows-msvc\codex-path\rg.exe
      search provider          bundled
      search command readiness file exists
  ✓ git          no Git worktree is active
  ✓ git          git executable found; execution not verified
      selected git             C:\Program Files\Git\cmd\git.exe
      repo detected            false
      PATH entries (1)         C:\Program Files\Git\cmd\git.exe
      git execution            not inspected (PATH helpers are not executed)
  ✓ terminal     Windows Terminal
      terminal                 Windows Terminal
      stdin is terminal        true
      stdout is terminal       true
      stderr is terminal       true
      terminal size            120x30
      color output             enabled
      WT_SESSION               present
      console input code page  437
      console output code page 437
      stdout console mode      0x00000007 (VT processing: true)
      stderr console mode      0x00000007 (VT processing: true)
  ✓ title        default · project madhe
      title source             default
      title items              activity, project-name
      activity item            true
      project source           cwd
      project value            madhe
  ✓ state        databases healthy
      CODEX_HOME               C:\Users\madhe\.codex (dir)
      log dir                  C:\Users\madhe\.codex\log (missing)
      sqlite home              C:\Users\madhe\.codex (dir)
      state DB                 C:\Users\madhe\.codex\state_5.sqlite (file) · integrity ok
      log DB                   C:\Users\madhe\.codex\logs_2.sqlite (file) · integrity ok
      goals DB                 C:\Users\madhe\.codex\goals_1.sqlite (file) · integrity ok
      memories DB              C:\Users\madhe\.codex\memories_1.sqlite (file) · integrity ok
      active rollouts          15 files · 84.84 MB (avg 5.66 MB)
      archived rollouts        0 files · 0 B (avg 0 B)
      memories v2 DB           C:\Users\madhe\.codex\memories_v2_1.sqlite (missing)
      memories v2 DB integrity skipped (missing)
      queue DB                 C:\Users\madhe\.codex\queue_1.sqlite (file)
      queue DB integrity       ok
      thread history DB        C:\Users\madhe\.codex\thread_history_1.sqlite (file)
      thread history DB integrity ok
      standalone release cache 2 entries in C:\Users\madhe\.codex\packages\standalone\releases
  ✓ threads      rollout files and state DB thread inventory agree
      default model provider   openai
      rollout DB active files  15
      rollout DB archived files 0
      rollout DB scan errors   0
      rollout DB malformed file names 0
      rollout DB scan cap reached false
      rollout DB rows          15
      rollout DB active rows   15
      rollout DB archived rows 0
      rollout DB missing active rows 0
      rollout DB missing archived rows 0
      rollout DB stale rows    0
      rollout DB archive mismatches 0
      rollout DB duplicate rollout thread ids 0
      rollout DB duplicate DB paths 0
      rollout DB model providers openai=15
      rollout DB sources       vscode=15

Configuration
  ✓ config       loaded
      model                    gpt-6.1-sol · openai
      cwd                      C:\Users\madhe
      config.toml              C:\Users\madhe\.codex\config.toml
      config.toml parse        ok
      MCP servers              1
      feature flags            56 enabled · 0 overridden (full list with --all)
      configuration scope      invocation config, including cloud-managed policy
      active thread overrides  not inspected
      configuration load ms    3
  ✓ auth         auth is configured
      auth storage mode        File
      auth.json path (file backend/fallback) C:\Users\madhe\.codex\auth.json
      stored auth mode         chatgpt
      stored API key           false
      stored ChatGPT tokens    true
      stored agent identity    false
  ⚠ mcp          MCP configuration has optional issues — Set the missing MCP env vars or disable the affected server.
      configured servers       1
      disabled servers         0
      stdio servers            1
      node_repl                env var CODEX_WINDOWS_REGISTERED_CORE is not set
  ✓ sandbox      restricted fs + restricted network · approval OnRequest
      approval policy          OnRequest
      filesystem sandbox       restricted
      denied-read rules        0
      denied-read glob rules   0
      glob scan max depth      unbounded
      managed filesystem source none
      network sandbox          restricted
      linux helper             none
      execve wrapper helper    none
      sandbox backend          <redacted>
      denied-read restrictions false
  ✓ sandbox      no explicit filesystem paths to probe

Desktop App
  ✓ desktop      the desktop application is installed
      version                  26.1002.7124.0
      running                  false
      log directory            $HOME\AppData\Local\Codex/Logs
  ✓ desktop      the desktop application is not running
  ✓ desktop      no locally visible recent Codex security enforcement was found

Updates
  ✓ updates      update configuration is locally consistent
      startup update check     true
      update action            standalone installer
      version cache            C:\Users\madhe\.codex\version.json
      cached latest version    0.160.1
      last checked at          2026-10-07 14:43 UTC
      latest version           0.161.0
      latest version status    current version is not older

Connectivity
  ✓ network      no proxy env vars
      proxy env vars           none
      respect system proxy     disabled
      managed proxy            not configured
  ✓ websocket    connected (HTTP 101 Switching Protocols) · 15s timeout
      model provider           openai
      provider name            OpenAI
      wire API                 responses
      supports websockets      true
      proxy env vars           none
      connect timeout          15000 ms
      auth mode                chatgpt
      endpoint                 wss://chatgpt.com/backend-api/<redacted>
      DNS                      2 IPv4, 0 IPv6, first IPv4
      handshake result         HTTP 101 Switching Protocols
      reasoning header         false
      server model present     false
  ✓ reachability active provider endpoints are reachable over HTTP
      reachability mode        ChatGPT auth
      ChatGPT inference URL    https://chatgpt.com/backend-api/<redacted> reachable (HTTP 405)
      desktop assets CDN       https://persistent.oaistatic.com/codex-app-prod/<redacted> reachable (HTTP 200)

Background Server
  ✓ app-server   running (persistent mode)
      daemon state dir         C:\Users\madhe\.codex\app-server-daemon
      settings                 C:\Users\madhe\.codex\app-server-daemon\settings.json (file)
      pid file                 C:\Users\madhe\.codex\app-server-daemon\app-server.pid (missing)
      update-loop pid file     C:\Users\madhe\.codex\app-server-daemon\app-server-updater.pid (missing)
      dedicated pid file       C:\Users\madhe\.codex\app-server-daemon\daemon.pid (file)
      dedicated update-loop pid file C:\Users\madhe\.codex\app-server-daemon\daemon-updater.pid (file)
      control socket           C:\Users\madhe\.codex\app-server-control\app-server-control.sock
      status                   running
      app-server version       0.161.0
      mode                     persistent

─────────────────────────────────────────────────────────────
23 ok · 2 notes · 2 warn · 0 fail degraded

--summary compact output   --all expand truncated lists
--json redacted report

What issue are you seeing?

Environment

  • Windows 11
  • Codex CLI 0.161.0
  • Python 3.12.15
  • Sandbox: workspace-write

Minimal reproduction

Run from a writable workspace inside Codex:

import os
import uuid

path = os.path.abspath(f"acl-repro-{uuid.uuid4().hex}")
print(f"Directory: {path}")

for name, operation in [
("mkdir", lambda: os.mkdir(path, mode=0o700)),
("listdir", lambda: os.listdir(path)),
("rmdir", lambda: os.rmdir(path)),
]:
try:
print(f"{name}: OK {operation()!r}")
except OSError as exc:
print(f"{name}: {exc!r}; winerror={exc.winerror}")

A failed deletion leaves the disposable directory in place. The reproduction does not explicitly modify ACLs.

Expected versus actual

All three operations should succeed for a directory created in the writable workspace.

Execution environment mkdir listdir rmdir
Normal PowerShell Pass Pass Pass
Codex danger-full-access Pass Pass Pass
Codex workspace-write Pass Windows error 5 Windows error 5

Under workspace-write, listing and deletion raise PermissionError: [WinError 5] Access is denied.

Diagnostic findings

Read-only inspection established:

  • The Python process token reports TokenHasRestrictions=1.

  • TokenRestrictedSids contains four SIDs:

    S-1-5-21-3913693972-769090868-1185087580-3858860717
    S-1-5-21-1878514808-31792991-3378615717-4044301570
    S-1-5-5-0-1098925
    S-1-1-0
    
  • The parent directory grants inheritable Modify access to the first two restricting SIDs.

  • icacls cannot read the child directory’s ACL: access denied.

  • GetNamedSecurityInfoW cannot read the child’s owner: access denied.

  • The token user, token owner, and parent owner are ADVAIT\madhe, SID S-1-5-21-853681387-521164086-1509020480-1001.

The controls and token evidence support a restricted-token/child-security-descriptor interaction. They do not establish the exact child ACL defect, because its security descriptor could not be inspected from the restricted process.

Potentially separate process-launch issue

Codex also intermittently reports:

CreateProcessAsUserW failed: 5 (Access is denied)

when launching PowerShell. This occurs during process creation, whereas the confirmed filesystem failure occurs inside a successfully launched Python process. A shared cause has not been established; track the launch failure separately pending further evidence.

No security settings or research files were changed.

What steps can reproduce the bug?

  1. On Windows 11 with Codex CLI 0.161.0, start Codex in a writable workspace using workspace-write.

  2. Run this with Python 3.12.15:

    import os
    import uuid
    
    path = os.path.abspath(f"acl-repro-{uuid.uuid4().hex}")
    print(path)
    
    for name, operation in [
        ("mkdir", lambda: os.mkdir(path, mode=0o700)),
        ("listdir", lambda: os.listdir(path)),
        ("rmdir", lambda: os.rmdir(path)),
    ]:
        try:
            print(name, "OK", operation())
        except OSError as exc:
            print(name, repr(exc), "winerror=", exc.winerror)
    
  3. Observe that creation succeeds, but listing and deletion fail with Windows error 5 (Access is denied). Leave the directory untouched if deletion fails.

  4. Run the same script in normal PowerShell and in Codex with danger-full-access as controls. All three operations succeed there.

The intermittent CreateProcessAsUserW failed: 5 is a separate process-launch symptom and is not required to reproduce this filesystem bug.

What is the expected behavior?

No response

Additional information

No response

Activity

  1. added
    bug
    on Oct 7, 2026
  2. added
    CLI
    windows-os
    sandbox
    on Oct 7, 2026
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