Skip to content

[Windows] Codex App sandbox fails to execute commands (HRESULT 0x80070020) #55230

Open

Description

@cokewilly

What version of the Codex App are you using (From “About Codex” dialog)?

26.1013.40934

What subscription do you have?

ChatGPT Plus

What platform is your computer?

Windows 11 Pro 25H2 (OS Build 26200.9711), x64

What issue are you seeing?

Problem

Codex App on Windows 11 consistently fails to execute even basic commands such as Get-Location.

Error message

CreateProcessSecurityEnvironment failed (HRESULT = 0x80070020)

Steps to reproduce

  1. Open Codex App on Windows 11.
  2. Open a local project.
  3. Ask Codex to execute Get-Location.
  4. The sandbox fails to start the command and returns HRESULT 0x80070020.

Expected behavior

Codex should execute basic read-only PowerShell commands successfully.

Actual behavior

Commands fail before execution, preventing Codex from working on local projects.

Troubleshooting already performed

  • Restarted Windows and Codex App.
  • Confirmed that CodexSandboxService.OpenAI.Codex is running under LocalSystem.
  • Confirmed that MXC availability is reported as true.
  • Observed both mxc and elevated sandbox selections in the sandbox logs.
  • Removed the explicit sandbox = "elevated" configuration and restarted Codex, but the error persisted.
  • Windows Application Event ID 1003 reported:
    unable to restore package uninstall listener: open the logged-in user's token: The system cannot find the file specified (os error 2).
  • Sandbox setup logs also reported a file-sharing violation (os error 32) while updating the user-profile ACL, although setup subsequently completed.

Request

Please help identify why sandbox process creation fails and provide a safe fix without disabling Windows security protections or granting unrestricted filesystem access.

What steps can reproduce the bug?

Steps to reproduce:

  1. Launch the Codex desktop app on Windows 11 Pro 25H2.

  2. Open a local project folder.

  3. Ask Codex to run the following PowerShell command:

    Get-Location

  4. Codex attempts to initialize the Windows sandbox.

  5. Command execution fails with:

    CreateProcessSecurityEnvironment failed (HRESULT = 0x80070020)

Reproducibility: Consistently reproducible, including after restarting Windows and the Codex app.

Expected result: The command executes successfully and returns the current working directory.

Actual result: The command does not execute because sandbox process creation fails.

What is the expected behavior?

Codex App should successfully initialize the Windows sandbox and execute basic PowerShell commands such as Get-Location, returning the current working directory without errors. It should also be able to safely read and work with files in the selected local project.

Additional information

The issue persists after restarting Windows and Codex App. The Codex sandbox service is running under LocalSystem. MXC availability is reported as true, but sandbox initialization still fails. Windows Application Event ID 1003 reports an error when opening the logged-in user's token (os error 2). The sandbox setup log also recorded a file-sharing violation (os error 32). I would appreciate guidance on resolving this without disabling Windows security protections.

Activity

  1. added
    app
    on Oct 19, 2026
  2. added
    bug
    windows-os
    sandbox
    on Oct 19, 2026
  3. github-actions commented on Oct 19, 2026

    @github-actions
    Contributor
  4. hengau192939-cmyk commented on Oct 19, 2026

    @hengau192939-cmyk

    I can reproduce this exact issue on Codex Desktop for Windows.

    Environment

    • ChatGPT/Codex Desktop: 26.1013.4894.0
    • Codex CLI: 0.163.0-alpha.10.2
    • Lenovo Windows laptop
    • Sandbox service running normally

    Key discovery: MXC causes the failure.

    Running Codex CLI normally successfully executes Get-Location in PowerShell.

    But enabling MXC explicitly with:

    codex exec --sandbox read-only -c 'features.prefer_mxc=true' --skip-git-repo-check "Run Get-Location and report the result."

    reproduces the exact error:

    MXC launcher: failed to create the process security environment: CreateProcessSecurityEnvironment failed (HRESULT = 0x80070020)
    

    Codex Desktop always launches its backend processes with features.prefer_mxc=true.

    I tried changing electron-prefer-mxc-enabled to false in .codex-global-state.json while Desktop was closed, but the setting returned to true after restarting Desktop.

    Other troubleshooting already completed:

    • Windows Repair
    • Sandbox service restart
    • Administrator and normal-user tests
    • Read-only and workspace-write sandbox modes
    • Elevated and unelevated Windows sandbox configurations
    • Antivirus and event-log checks
    • Testing with Elevoc Control Service stopped
    • Codex Workspace Diagnose (dependencies healthy)

    Questions for maintainers:

    1. Is there a supported way to disable MXC in the Windows Desktop app?
    2. Is this a known MXC regression?
    3. Is there a workaround that preserves existing local projects and conversation history?

    The Codex CLI works without MXC, but the desktop application remains unusable for local command execution.

  5. cokewilly commented on Oct 20, 2026

    @cokewilly
    Author

    Additional clarification:

    I am using Codex through the integrated Codex interface in the ChatGPT Windows desktop app, rather than a separately launched Codex desktop application.

    The ChatGPT app reports that it is up to date.

    I also installed Codex CLI v0.163.0 separately through npm. The CLI successfully executes Get-Location on the same Windows machine, while Codex inside the ChatGPT desktop app consistently fails with HRESULT 0x80070020.

    Both interfaces are using the "Ask for approval" permission mode.

    This suggests a difference in command execution or sandbox initialization between the integrated desktop interface and the CLI.

  6. Raider72-eng commented on Oct 23, 2026

    @Raider72-eng

    I am experiencing a closely related issue with Codex Desktop on Windows 11.

    Environment:

    • Windows 11, build 26300 (10.0.26300.0)
    • Codex CLI 0.163.0-alpha.11.2
    • Windows sandbox: elevated
    • Desktop starts with features.prefer_mxc=true

    Observed behavior:

    Even cmd.exe /c echo TOOL-OK remains pending indefinitely in Codex Desktop, without output or an exit code. This reproduces across two independent local workspaces.

    One execution remained pending for over 18 minutes.

    Additional diagnostic findings:

    • Direct sandbox execution works, including file read/write operations.
    • The Codex CLI with MXC disabled executes the same shell command successfully in 401 ms.
    • Enabling features.prefer_mxc=true in the CLI results in missing shell-tool output and no tool exit code.
    • The Desktop MXC helper (codex.exe --__codex-windows-mxc) was observed waiting in a thread stack involving processmodel.dll!CreateProcessSecurityEnvironment.

    Unlike the original report, I have not observed HRESULT 0x80070020. In my case, the tool operation hangs rather than returning an immediate error.

    This may be a related failure mode in the Windows MXC process initialization or execution path.

    The successful CLI execution without MXC provides a useful control test. I can provide additional diagnostics if needed.

  7. adski27 commented on Oct 24, 2026

    @adski27

    Additional reproduction and Process Monitor evidence for MXC startup failure 0x80070020.

    Environment

    • Windows 11 Home x64, OS build 26300.9711; KB5127648 installed 16 October 2026.
    • Codex package observed in the trace: OpenAI.Codex_26.1016.8622.0_x64__2p2nqsd0c76g0.
    • Testing performed on 23–24 October 2026.
    • Restricted filesystem permissions; additional access requests were disabled in the affected chat.

    Failure and impact

    Codex cannot reliably start its local tool environment. Basic shell commands and local file reads fail before the requested command executes:

    MXC launcher: failed to create the process security environment:
    CreateProcessSecurityEnvironment failed (HRESULT = 0x80070020)
    

    The Node tool also failed to start with the same launcher error. This prevents local document analysis, including reading files attached to the chat.

    Reproduction

    Ask Codex to execute either:

    Get-Content 'C:\Windows\win.ini' -TotalCount 2

    or:

    Get-Item 'D:\adski\TEMP\LogfileCHAT.CSV'

    Both returned the same MXC startup error. A basic cmd.exe version command also failed repeatedly in the original chat.

    A Windows version test reportedly succeeded once in a separate folder-scoped chat, but subsequent file-read tests there failed. This has not provided a reliable workaround.

    Restarting did not resolve the issue. Using a different shell, disabling shell-profile loading, and changing the working directory also did not resolve it.

    Process Monitor evidence

    I captured a controlled attempt to execute a basic Windows version command. During that attempt, codex.exe, PID 43916, checked numerous unrelated entries directly under C:\, repeatedly opening them for attributes and querying file IDs.

    Relevant excerpt, with original timestamps and details:

    Time of Day	Process Name	PID	Operation	Path	Result	Detail
    00:46:41.4702317	codex.exe	43916	CreateFile	C:\DumpStack.log	ACCESS DENIED	Desired Access: Read Attributes, Synchronize, Disposition: Open, Options: Synchronous IO Non-Alert, Attributes: n/a, ShareMode: Read, Write, Delete, AllocationSize: n/a
    00:46:41.4705906	codex.exe	43916	CreateFile	C:\DumpStack.log.tmp	SHARING VIOLATION	Desired Access: Read Attributes, Synchronize, Disposition: Open, Options: Synchronous IO Non-Alert, Attributes: n/a, ShareMode: Read, Write, Delete, AllocationSize: n/a
    00:46:41.4709066	codex.exe	43916	CreateFile	C:\DumpStack.log.tmp	SHARING VIOLATION	Desired Access: Read Attributes, Synchronize, Disposition: Open, Options: Synchronous IO Non-Alert, Attributes: n/a, ShareMode: Read, Write, Delete, AllocationSize: n/a
    00:46:41.4712122	codex.exe	43916	CreateFile	C:\EFI	SUCCESS	Desired Access: Read Attributes, Synchronize, Disposition: Open, Options: Synchronous IO Non-Alert, Attributes: n/a, ShareMode: Read, Write, Delete, AllocationSize: n/a, OpenResult: Opened
    00:46:41.4713516	codex.exe	43916	QueryIdInformation	C:\EFI	SUCCESS
    00:46:41.4714070	codex.exe	43916	CloseFile	C:\EFI	SUCCESS
    00:46:41.4783527	codex.exe	43916	CreateFile	C:\IntelOptaneData	ACCESS DENIED	Desired Access: Read Attributes, Synchronize, Disposition: Open, Options: Synchronous IO Non-Alert, Attributes: n/a, ShareMode: Read, Write, Delete, AllocationSize: n/a
    00:46:41.4787403	codex.exe	43916	CreateFile	C:\IntelOptaneData	ACCESS DENIED	Desired Access: Read Attributes, Synchronize, Disposition: Open, Options: Synchronous IO Non-Alert, Attributes: n/a, ShareMode: Read, Write, Delete, AllocationSize: n/a
    00:46:41.4970701	codex.exe	43916	CreateFile	C:\swapfile.sys	SHARING VIOLATION	Desired Access: Read Attributes, Synchronize, Disposition: Open, Options: Synchronous IO Non-Alert, Attributes: n/a, ShareMode: Read, Write, Delete, AllocationSize: n/a
    00:46:41.4973826	codex.exe	43916	CreateFile	C:\swapfile.sys	SHARING VIOLATION	Desired Access: Read Attributes, Synchronize, Disposition: Open, Options: Synchronous IO Non-Alert, Attributes: n/a, ShareMode: Read, Write, Delete, AllocationSize: n/a
    

    Other entries checked in the same sequence included C:\Evidence, C:\inetpub, C:\Intel, C:\OEM, C:\OneDriveTemp, C:\packages, and C:\Program Files.

    The command subsequently terminated with CreateProcessSecurityEnvironment failed (HRESULT = 0x80070020).

    Interpretation and limits

    The trace establishes that the Codex process encountered sharing violations on protected drive-root files during the failed attempt. It does not establish that either specific operation caused sandbox creation to abort: processing continued after the first sharing violation.

    The affected chat’s supplied filesystem permission profile included a read entry for the special root. Whether that contributes to these drive-root checks is unconfirmed.

    No system-file permissions were changed, and no attempt was made to unlock or delete these files.

    Request

    Could maintainers investigate:

    • Why sandbox startup checks unrelated drive-root entries for a basic command.
    • Whether a sharing violation during filesystem-scope preparation is propagated as a fatal startup error.
    • Whether the failure depends on the supplied filesystem grants.
    • Whether diagnostics can identify the exact path and setup stage responsible for the returned HRESULT.

    I can provide the retained Process Monitor capture through an appropriate support channel.

    Potentially related reports, sharing the same error signature but not necessarily the same cause:

  8. smatryk commented on Oct 28, 2026

    @smatryk

    I am experiencing a similar issue in Codex Desktop on Windows (reported on behalf of the user).

    • Codex Desktop: 26.1023.50603, build 22391; updater reported up to date.
    • Windows build: 26200 (Get-ComputerInfo reported WindowsProductName Windows 10 Pro and WindowsVersion 2009).
    • Before restarting Windows, sandboxed PowerShell commands and computer-use initialization failed with MXC launcher: failed to create the process security environment: CreateProcessSecurityEnvironment failed (HRESULT = 0x80070020).
    • After a full Windows restart, a sandboxed Get-Location produced no output and remained running beyond 15 seconds; computer-use initialization timed out after 30 seconds. These observations do not establish that the post-restart hang has the same cause.
    • net use showed mapped network drives but no administrative C$ share; none were disconnected.

    Expected: local commands and computer-use initialize successfully. Actual: local execution and desktop control are unavailable.

  9. fedoranz commented on Oct 29, 2026

    @fedoranz

    Still reproducible on 30 October 2026 after a full Windows restart. Get-Location fails before execution:

    MXC launcher: failed to create the process security environment: CreateProcessSecurityEnvironment failed (HRESULT = 0x80070020)

    Integrated browser control and Node tools also fail with the same launcher error.

    C:\Users\paulm.codex\config.toml contains:

    [features]
    prefer_mxc = false
    
    [windows]
    sandbox = "elevated"
    

    Despite this, sandbox logs continue to report MXC availability: true and Windows sandbox selection: mxc.

    User and machine CODEX_HOME environment variables are unset. Enabling SBX_DEBUG=1 and RUST_LOG=debug produced no additional sandbox log detail.

    Please advise how to force the elevated fallback and collect diagnostics identifying the MXC startup failure.

  10. rfv165888-bot commented on Nov 5, 2026

    @rfv165888-bot

    Summary

    Windows Codex Desktop fails before running Get-Location with:

    CreateProcessSecurityEnvironment failed (HRESULT = 0x80070020)
    

    It worked on the morning of November 5, 2026. The first observed failure was before 15:53 that day (Taipei time, UTC+8). Reinstalling the desktop app did not resolve the issue.

    Backend comparison

    • On the same machine, Codex CLI using the elevated sandbox successfully runs Get-Location.
    • After setting windows.sandbox = "elevated" and features.prefer_mxc = false and reopening the desktop app, Desktop still launches through MXC and fails.
    • The command itself has not started when the failure occurs.

    Existing Procmon capture

    All times below are November 5, 2026, Taipei time (UTC+8).

    • At 19:11:27.7238689, Appinfo (svchost.exe, PID 6808, TID 14472) attempts CreateFile on C:\Persi0.sys with Generic Read. The result is SHARING VIOLATION, NTSTATUS 0xC0000043. The request uses Disposition: Open, Options: Synchronous IO Non-Alert, Non-Directory File, and ShareMode: Read, Write.
    • The captured stack contains processmodel!SbeCreateProcessSecurityEnvironment+0x108 and DFFilter.SYS+0x774a.
    • Subsequent events on the same thread retain the same SBE call chain and show exception unwinding (CxxThrowException, RaiseException, RtlUnwindEx) and error-message formatting (FormatMessageW). The intervening BFS state-directory and AppContainer named-pipe close events have kernel-only stacks, so their user-mode callers cannot be independently established from those two events alone.
    • At 19:11:27.7273987, the MXC launcher (codex.exe --__codex-windows-mxc, PID 12560) exits with status 1, approximately 3.53 ms after the Persi0.sys sharing violation.
    • For comparison, earlier pagefile.sys sharing violations on that thread are followed by additional open attempts and continued processing of other paths. After the Persi0.sys Generic Read failure, no retry or continued target enumeration was observed before cleanup/error handling.

    Deep Freeze and evidence limits

    • Deep Freeze Enterprise version: 8.30.220.4890.
    • The installed DFC.exe get /ISFROZEN query returned 0 (Thawed) at approximately 19:28. The actual Frozen/Thawed state at the 19:11 failure is unknown. A next-boot setting is not being treated as evidence of the current state.
    • fltmc instances -v C: confirms that DFFilter is attached to C: at the time of the later diagnostic check.
    • Persi0.sys is the most likely implicated resource, not a proven root cause. The capture does not record the actual SBE return value or exception payload. The error-code conversion is consistent with ERROR_SHARING_VIOLATION (32) becoming HRESULT_FROM_WIN32(32) = 0x80070020, but that specific propagation has not been directly verified.
    • The conflicting handle owner is unconfirmed. A later live handle snapshot found no match among accessible processes; System PID 4 could not be queried, leaving a blind spot. A current snapshot also cannot identify a historical handle owner conclusively.
    • DFFilter appearing in the stack establishes participation in the I/O path, not ownership of the conflicting handle or responsibility for the failure.

    Questions for maintainers

    1. Can you confirm whether this Persi0.sys sharing violation is propagated through SbeCreateProcessSecurityEnvironment as 0x80070020? Is there an existing diagnostic path that would expose the relevant return value without changing the host configuration?
    2. How should MXC handle an unreadable host file encountered during security-environment creation: avoid unnecessary content reads, safely skip an optional object, or fail with a diagnostic naming the required resource? Can this compatibility case be investigated without weakening isolation?
    3. Is there a supported way to select a non-MXC sandbox backend for Windows Desktop, and why might Desktop continue to select MXC after the settings above? The CLI elevated backend works on this machine.

    A sanitized five-event stack extract can be provided upon request. No raw PML/XML capture, user or machine identifiers, or license information is attached.

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

    appbugsandboxwindows-os

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions