Windows sandbox: race condition with the `cap_sid` file update. Multiple Codex CLI instances race to write that file - last one wins and workspaces become unwriteable

Open 💬 3 comments Opened Jul 17, 2026 by MajesticMug
💡 Likely answer: A maintainer (github-actions[bot], contributor) responded on this thread — see the highlighted reply below.

What version of Codex CLI is running?

0.144.5

What subscription do you have?

Pro

Which model were you using?

gpt-5.6-sol

What platform is your computer?

Microsoft Windows NT 10.0.26200.0 x64

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

PowerShell

Codex doctor report

{
  "schemaVersion": 1,
  "generatedAt": "1784260400s since unix epoch",
  "overallStatus": "ok",
  "codexVersion": "0.144.5",
  "checks": {
    "app_server.status": {
      "id": "app_server.status",
      "category": "app-server",
      "status": "ok",
      "summary": "background server is not running",
      "details": {
        "control socket": "C:\\Users\\javie\\.codex\\app-server-control\\app-server-control.sock",
        "daemon state dir": "C:\\Users\\javie\\.codex\\app-server-daemon",
        "mode": "ephemeral",
        "pid file": "C:\\Users\\javie\\.codex\\app-server-daemon\\app-server.pid (missing)",
        "settings": "C:\\Users\\javie\\.codex\\app-server-daemon\\settings.json (missing)",
        "status": "not running",
        "update-loop pid file": "C:\\Users\\javie\\.codex\\app-server-daemon\\app-server-updater.pid (missing)"
      },
      "remediation": null,
      "durationMs": 0
    },
    "auth.credentials": {
      "id": "auth.credentials",
      "category": "auth",
      "status": "ok",
      "summary": "auth is configured",
      "details": {
        "auth file": "C:\\Users\\javie\\.codex\\auth.json",
        "auth storage mode": "File",
        "stored API key": "false",
        "stored ChatGPT tokens": "true",
        "stored agent identity": "false",
        "stored auth mode": "chatgpt"
      },
      "remediation": null,
      "durationMs": 0
    },
    "config.load": {
      "id": "config.load",
      "category": "config",
      "status": "ok",
      "summary": "config loaded",
      "details": {
        "CODEX_HOME": "C:\\Users\\javie\\.codex",
        "config.toml": "C:\\Users\\javie\\.codex\\config.toml",
        "config.toml parse": "ok",
        "cwd": "C:\\Users\\javie",
        "enabled feature flags": "<redacted>",
        "feature flag overrides": "none",
        "feature flags enabled": "35",
        "log dir": "C:\\Users\\javie\\.codex\\log",
        "mcp servers": "1",
        "model": "gpt-5.6-sol",
        "model provider": "openai",
        "sqlite home": "C:\\Users\\javie\\.codex"
      },
      "remediation": null,
      "durationMs": 0
    },
    "git.environment": {
      "id": "git.environment",
      "category": "git",
      "status": "ok",
      "summary": "git version 2.49.0.windows.1",
      "details": {
        "PATH git #1": "C:\\Program Files\\Git\\cmd\\git.exe",
        "PATH git entries": "1",
        "git build options": "git version 2.49.0.windows.1; cpu: x86_64; built from commit: cca1f38702730b35f52c29efd62864b85e85ddcc; sizeof-long: 4; sizeof-size_t: 8; shell-path: D:/git-sdk-64-build-installers/usr/bin/sh; feature: fsmonitor--daemon; libcurl: 8.12.1; OpenSSL: OpenSSL 3.2.4 11 Feb 2025; zlib: 1.3.1",
        "git exec path": "C:/Program Files/Git/mingw64/libexec/git-core",
        "git version": "git version 2.49.0.windows.1",
        "repo detected": "false",
        "selected git": "C:\\Program Files\\Git\\cmd\\git.exe"
      },
      "remediation": null,
      "durationMs": 108
    },
    "installation": {
      "id": "installation",
      "category": "install",
      "status": "ok",
      "summary": "installation looks consistent",
      "details": {
        "PATH codex #1": "C:\\Users\\javie\\AppData\\Local\\Programs\\OpenAI\\Codex\\bin\\codex.exe",
        "current executable": "C:\\Users\\javie\\AppData\\Local\\Programs\\OpenAI\\Codex\\bin\\codex.exe",
        "install context": "standalone (windows, package C:\\Users\\javie\\.codex\\packages\\standalone\\releases\\0.144.5-x86_64-pc-windows-msvc, bin C:\\Users\\javie\\.codex\\packages\\standalone\\releases\\0.144.5-x86_64-pc-windows-msvc\\bin, resources C:\\Users\\javie\\.codex\\packages\\standalone\\releases\\0.144.5-x86_64-pc-windows-msvc\\codex-resources, path C:\\Users\\javie\\.codex\\packages\\standalone\\releases\\0.144.5-x86_64-pc-windows-msvc\\codex-path)",
        "managed by bun": "false",
        "managed by npm": "false",
        "managed by pnpm": "false",
        "managed package root": "not set"
      },
      "remediation": null,
      "durationMs": 67
    },
    "mcp.config": {
      "id": "mcp.config",
      "category": "mcp",
      "status": "ok",
      "summary": "MCP configuration is locally consistent",
      "details": {
        "configured servers": "1",
        "disabled servers": "0",
        "streamable_http servers": "1"
      },
      "remediation": null,
      "durationMs": 3312
    },
    "network.env": {
      "id": "network.env",
      "category": "network",
      "status": "ok",
      "summary": "network-related environment looks readable",
      "details": {
        "proxy env vars": "none"
      },
      "remediation": null,
      "durationMs": 0
    },
    "network.provider_reachability": {
      "id": "network.provider_reachability",
      "category": "reachability",
      "status": "ok",
      "summary": "active provider endpoints are reachable over HTTP",
      "details": {
        "ChatGPT base URL": "https://chatgpt.com/backend-api/ reachable (HTTP 403)",
        "reachability mode": "ChatGPT auth"
      },
      "remediation": null,
      "durationMs": 105
    },
    "network.websocket_reachability": {
      "id": "network.websocket_reachability",
      "category": "websocket",
      "status": "ok",
      "summary": "Responses WebSocket handshake succeeded",
      "details": {
        "DNS": "2 IPv4, 0 IPv6, first IPv4",
        "auth mode": "chatgpt",
        "connect timeout": "15000 ms",
        "endpoint": "wss://chatgpt.com/backend-api/<redacted>",
        "handshake result": "HTTP 101 Switching Protocols",
        "model provider": "openai",
        "models etag present": "true",
        "provider name": "OpenAI",
        "proxy env vars": "none",
        "reasoning header": "false",
        "server model present": "false",
        "supports websockets": "true",
        "wire API": "responses"
      },
      "remediation": null,
      "durationMs": 642
    },
    "runtime.provenance": {
      "id": "runtime.provenance",
      "category": "runtime",
      "status": "ok",
      "summary": "running standalone on windows-x86_64",
      "details": {
        "commit": "unknown",
        "current executable": "C:\\Users\\javie\\AppData\\Local\\Programs\\OpenAI\\Codex\\bin\\codex.exe",
        "install method": "standalone (windows, package C:\\Users\\javie\\.codex\\packages\\standalone\\releases\\0.144.5-x86_64-pc-windows-msvc, bin C:\\Users\\javie\\.codex\\packages\\standalone\\releases\\0.144.5-x86_64-pc-windows-msvc\\bin, resources C:\\Users\\javie\\.codex\\packages\\standalone\\releases\\0.144.5-x86_64-pc-windows-msvc\\codex-resources, path C:\\Users\\javie\\.codex\\packages\\standalone\\releases\\0.144.5-x86_64-pc-windows-msvc\\codex-path)",
        "platform": "windows-x86_64",
        "version": "0.144.5"
      },
      "remediation": null,
      "durationMs": 0
    },
    "runtime.search": {
      "id": "runtime.search",
      "category": "search",
      "status": "ok",
      "summary": "search is OK (bundled)",
      "details": {
        "search command": "C:\\Users\\javie\\.codex\\packages\\standalone\\releases\\0.144.5-x86_64-pc-windows-msvc\\codex-path\\rg.exe",
        "search command readiness": "file exists",
        "search provider": "bundled"
      },
      "remediation": null,
      "durationMs": 0
    },
    "sandbox.helpers": {
      "id": "sandbox.helpers",
      "category": "sandbox",
      "status": "ok",
      "summary": "sandbox configuration is readable",
      "details": {
        "approval policy": "OnRequest",
        "codex-linux-sandbox helper": "none",
        "execve wrapper helper": "none",
        "filesystem sandbox": "restricted",
        "network sandbox": "enabled"
      },
      "remediation": null,
      "durationMs": 0
    },
    "state.paths": {
      "id": "state.paths",
      "category": "state",
      "status": "ok",
      "summary": "state paths and databases are inspectable",
      "details": {
        "CODEX_HOME": "C:\\Users\\javie\\.codex (dir)",
        "active rollout files": "771 files, 1489903118 total bytes, 1932429 average bytes",
        "archived rollout files": "0 files, 0 total bytes, 0 average bytes",
        "goals DB": "C:\\Users\\javie\\.codex\\goals_1.sqlite (file)",
        "goals DB integrity": "ok",
        "log DB": "C:\\Users\\javie\\.codex\\logs_2.sqlite (file)",
        "log DB integrity": "ok",
        "log dir": "C:\\Users\\javie\\.codex\\log (missing)",
        "memories DB": "C:\\Users\\javie\\.codex\\memories_1.sqlite (file)",
        "memories DB integrity": "ok",
        "sqlite home": "C:\\Users\\javie\\.codex (dir)",
        "standalone release cache": "7 entries in C:\\Users\\javie\\.codex\\packages\\standalone\\releases",
        "state DB": "C:\\Users\\javie\\.codex\\state_5.sqlite (file)",
        "state DB integrity": "ok"
      },
      "remediation": null,
      "durationMs": 6254
    },
    "state.rollout_db_parity": {
      "id": "state.rollout_db_parity",
      "category": "threads",
      "status": "ok",
      "summary": "rollout files and state DB thread inventory agree",
      "details": {
        "default model provider": "openai",
        "rollout DB active files": "771",
        "rollout DB active rows": "771",
        "rollout DB archive mismatches": "0",
        "rollout DB archived files": "0",
        "rollout DB archived rows": "0",
        "rollout DB duplicate DB paths": "0",
        "rollout DB duplicate rollout thread ids": "0",
        "rollout DB malformed file names": "0",
        "rollout DB missing active rows": "0",
        "rollout DB missing archived rows": "0",
        "rollout DB model providers": "local_go_router=449, openai=297, local_router=13, local_llamacpp=12",
        "rollout DB rows": "771",
        "rollout DB scan cap reached": "false",
        "rollout DB scan errors": "0",
        "rollout DB sources": "subagent:other=261, cli=246, vscode=137, subagent:thread_spawn=105, exec=13, subagent:review=9",
        "rollout DB stale rows": "0"
      },
      "remediation": null,
      "durationMs": 18611
    },
    "system.environment": {
      "id": "system.environment",
      "category": "system",
      "status": "ok",
      "summary": "OS language en-US",
      "details": {
        "EDITOR": "not set",
        "VISUAL": "not set",
        "os": "Windows 10.0.26200 (Windows 11 Professional) [64-bit]",
        "os language": "en-US",
        "os type": "Windows",
        "os version": "10.0.26200"
      },
      "remediation": null,
      "durationMs": 0
    },
    "terminal.env": {
      "id": "terminal.env",
      "category": "terminal",
      "status": "ok",
      "summary": "terminal metadata was detected",
      "details": {
        "WT_SESSION": "present",
        "color output": "enabled",
        "console input code page": "437",
        "console output code page": "437",
        "stderr console mode": "0x00000007 (VT processing: true)",
        "stderr is terminal": "true",
        "stdin is terminal": "true",
        "stdout console mode": "0x00000007 (VT processing: true)",
        "stdout is terminal": "true",
        "terminal": "Windows Terminal",
        "terminal size": "120x30"
      },
      "remediation": null,
      "durationMs": 0
    },
    "terminal.title": {
      "id": "terminal.title",
      "category": "title",
      "status": "ok",
      "summary": "terminal title default",
      "details": {
        "terminal title activity": "true",
        "terminal title items": "activity, project-name",
        "terminal title project source": "cwd",
        "terminal title project value": "javie",
        "terminal title source": "default"
      },
      "remediation": null,
      "durationMs": 0
    },
    "updates.status": {
      "id": "updates.status",
      "category": "updates",
      "status": "ok",
      "summary": "update configuration is locally consistent",
      "details": {
        "cached latest version": "0.144.5",
        "check for update on startup": "true",
        "last checked at": "2026-07-16T16:33:02.080418100Z",
        "latest version": "0.144.5",
        "latest version status": "current version is not older",
        "update action": "standalone installer",
        "version cache": "C:\\Users\\javie\\.codex\\version.json"
      },
      "remediation": null,
      "durationMs": 495
    }
  }
}

What issue are you seeing?

Every file write or command inside the workspace goes through the auto-review process even when the permissions are set to workspace-write.

I was able to track this down to the cap.rs file, where the code updates the files and overwrites them without holding a lock, ignoring the fact that other Codex CLI instances can also write the file, causing the last one to win!

This seems to cause a downstream issue where the ACLs are updated on the root but not on the descendants.

What steps can reproduce the bug?

Preconditions:

  • Set the following configs:
  • approvals_reviewer = "auto_review"
  • default_permissions = "workspace-write"

Steps to reproduce:

  • Start two Codex CLI instances on two different projects and have the agent work on a long task
  • Start a new instance in a new folder that will trigger the ACL grant logic
  • Observe how the agents start requesting elevation (command review) for every file edit and command

What is the expected behavior?

All agents are able to write and edit files inside the workspace when the default permissions are set to workspace-write, even when running multiple Codex CLI instances on different folders. Regular file creation/editing/deleting inside the workspace should not trigger the command review model.

Additional information

I was also able to reproduce this with a unit tests in cap.rs:

#[test]
fn concurrent_workspace_sid_updates_preserve_every_key() {
    let temp = tempfile::tempdir().expect("tempdir");
    let codex_home = temp.path().join("codex-home");
    std::fs::create_dir_all(&codex_home).expect("create codex home");

    let workspaces = (0..16)
        .map(|index| temp.path().join(format!("workspace-{index}")))
        .collect::<Vec<_>>();
    for workspace in &workspaces {
        std::fs::create_dir_all(workspace).expect("create workspace");
    }

    let barrier = Arc::new(Barrier::new(workspaces.len()));
    let mut handles = Vec::with_capacity(workspaces.len());
    for workspace in &workspaces {
        let workspace = workspace.clone();
        let barrier = Arc::clone(&barrier);
        let codex_home = codex_home.clone();
        handles.push(thread::spawn(move || {
            barrier.wait();
            workspace_cap_sid_for_cwd(&codex_home, &workspace).expect("workspace sid")
        }));
    }
    let returned_sids = handles
        .into_iter()
        .map(|handle| handle.join().expect("join workspace sid thread"))
        .collect::<HashSet<_>>();

    let caps = load_or_create_cap_sids(&codex_home).expect("load caps");
    let persisted_sids = caps
        .workspace_by_cwd
        .values()
        .cloned()
        .collect::<HashSet<_>>();

    assert_eq!(persisted_sids, returned_sids);
    assert_eq!(caps.workspace_by_cwd.len(), workspaces.len());
}

View original on GitHub ↗

3 Comments

github-actions[bot] contributor · 1 month ago

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

  • #32914

Powered by Codex Action

MajesticMug · 1 month ago
Potential duplicates detected. Please review them and close your issue if it is a duplicate. * Launching another VS Code Codex window terminates Full access in the existing window (error 1312) #32914 _Powered by Codex Action_

I think this bug would supersede #32914 because it points directly at the root cause.

I wonder if this is the root cause for multiple Windows sandbox issues. The bug looks somewhat critical because it degrades performance with multiple VS Code instances using the CLI through the extension in Windows.

bincera · 6 days ago

I can reproduce what appears to be the same class of failure in Codex Desktop with a multi-root project, with some additional evidence about stale descendant ACLs.

Environment

  • Codex Desktop package: OpenAI.Codex_26.818.3698.0
  • command runner observed in the sandbox log: codex-command-runner-0.149.0-alpha.4.exe
  • Windows 10 Pro 22H2, build 19045.7663
  • native sandbox configured as elevated
  • one Codex project containing 10 independent Git repository roots

Observed behavior

  • Editing had worked normally before 2026-08-21.
  • The sandbox log then recorded 78 occurrences of setup refresh had errors.
  • Underlying entries included deny ACE failed and SetNamedSecurityInfoW failed: 5.
  • Later setup refreshes reported errors=[], but filesystem state remained inconsistent.
  • The project UI still showed all 10 roots, while one resumed/forked task received only the documentary root plus a temporary visualization root as effective writable roots.
  • A completely new, non-forked task opened at the correct root and had a clean Git status, but a minimal apply_patch edit to an ordinary tracked README.md still requested per-file approval and then failed with:

Failed to read file to update <root>\README.md: path contains a reparse point

The file, its parent directory, and every parent in the path were checked explicitly: none is a reparse point.

ACL inventory

I compared the current workspace SID and additional-writable-root SID recorded for each root against existing tracked files and their parent directories, excluding .git, .codex, protected ACLs, and reparse points.

  • all 10 repository roots had both current role ACEs;
  • 3 repositories were fully aligned;
  • 7 repositories had stale descendants;
  • exact stale set: 175 objects (153 files and 22 directories);
  • no target was ACL-protected or a reparse point;
  • representative files containing the current role ACE could open a write handle without changing bytes;
  • representative files in the same repository missing that ACE returned Access Denied.

A bounded transactional repair prevalidated all 175 exact targets, hashes, owners, paths, counts, and Git state. The Codex process ran as CodexSandboxOffline; Windows denied the first inheritance update with code 5. The rollback completed, and content, owners, and Git state remained unchanged.

This suggests the root ACL/capability map can be current while pre-existing descendants still retain stale role identities, and that the editor may map the resulting access failure to the misleading reparse-point error.

Questions:

  1. Is there an officially supported way to force a safe descendant ACL refresh without recreating files or running a separate administrative shell?
  2. Could Desktop task forking/resumption race with cap_sid updates or retain an older writable-root role set?
  3. Can the editor distinguish WRITE_DAC/file-access denial from an actual reparse-point check failure?

I have retained the relevant CODEX_HOME/.sandbox/sandbox.log, Windows details, exact counts, and screenshots privately, following the official diagnostics guidance. I have not published .sandbox-secrets, local paths, SIDs, or the raw log.