Windows sandbox can leave workspace owned by CodexSandboxOnline, then setup refresh fails with SetNamedSecurityInfoW 5
What version of the Codex App are you using (From “About Codex” dialog)?
Observed from sandbox log path:
OpenAI.Codex_26.616.9593.0_x64__2p2nqsd0c76g0
codex-command-runner-0.142.0.exe
The in-app/browser environment previously reported BROWSER_USE_CODEX_APP_VERSION=26.616.71553, but the current sandbox helper path in the log is the AppX package above.
What subscription do you have?
ChatGPT Plus
What platform is your computer?
Windows desktop app, Windows x64.
What issue are you seeing?
Codex Windows sandbox setup started failing before ordinary commands and apply_patch could run. The important part is that the workspace directory owner had become a Codex sandbox account.
Before manual repair, read-only commands and apply_patch were blocked with:
windows sandbox: helper_unknown_error: setup refresh had errors
The current setup error file contained:
{
"code": "helper_unknown_error",
"message": "setup refresh had errors"
}
The sandbox log showed repeated failures while trying to grant write ACEs to the workspace root:
setup refresh: spawning C:\Program Files\WindowsApps\OpenAI.Codex_26.616.9593.0_x64__2p2nqsd0c76g0\app\resources\codex-windows-sandbox-setup.exe
granting write ACE to <WORKSPACE_ROOT> for sandbox group and capability SID
write ACE grant failed on <WORKSPACE_ROOT>: SetNamedSecurityInfoW failed: 5
setup refresh: processed 2 write roots (read roots delegated); errors=["write ACE failed on <WORKSPACE_ROOT>: SetNamedSecurityInfoW failed: 5"]
setup refresh completed with errors: ["write ACE failed on <WORKSPACE_ROOT>: SetNamedSecurityInfoW failed: 5"]
setup error: setup refresh had errors
setup refresh: exited with status ExitStatus(ExitStatus(1))
ACL inspection showed the project path had unexpected owners:
<WORKSPACE_PARENT> Owner: <MACHINE>\CodexSandboxOffline
<WORKSPACE_ROOT> Owner: <MACHINE>\CodexSandboxOnline
The user did not intentionally set these owners. The workspace is a normal local project directory, not something that should be owned by sandbox service accounts.
After the user manually reset ownership back to their Windows user, the same Codex thread recovered immediately:
<WORKSPACE_PARENT> Owner: <MACHINE>\<USER>
<WORKSPACE_ROOT> Owner: <MACHINE>\<USER>
Post-repair verification:
Get-Location => success inside sandbox
git status --short --untracked-files=all => success inside sandbox
apply_patch add temporary probe file => success
Get-Content temporary probe file => success
apply_patch delete temporary probe file => success
The sandbox log after the owner repair shows setup refresh succeeding again:
setup refresh: processed 2 write roots (read roots delegated); errors=[]
codex-windows-sandbox-setup.exe] setup binary completed
This strongly suggests the failure was not a project file problem or patch-content problem. It was caused by the workspace or parent directory being left owned by CodexSandboxOnline / CodexSandboxOffline, after which the sandbox helper could no longer grant the required ACE and every command path failed.
What steps can reproduce the bug?
I do not yet have a deterministic fresh reproduction for the ownership change itself. The observed sequence was:
- Use Codex Desktop on Windows with
workspace-writeand[windows] sandbox = "elevated". - Work in a normal local project directory.
- After recent Windows Desktop sandbox/helper activity, commands and
apply_patchstart failing before execution withhelper_unknown_error: setup refresh had errors. - Inspect ACL ownership for the workspace and parent directory.
- Observe owner values of
CodexSandboxOnline/CodexSandboxOfflineinstead of the user account. - Manually reset owners back to the user account.
- Retry ordinary sandbox commands and
apply_patch; they succeed, and setup refresh logserrors=[].
What is the expected behavior?
Codex sandbox may create sandbox users, add temporary ACL entries, or create junctions as needed, but it should never leave a user workspace or workspace parent directory owned by CodexSandboxOnline / CodexSandboxOffline.
If ownership or ACL state is abnormal, Codex should report a clear diagnostic and remediation, rather than failing as a generic helper_unknown_error.
Additional information
Local config included:
sandbox_mode = "workspace-write"
[windows]
sandbox = "elevated"
[sandbox_workspace_write]
network_access = true
There was no C:\Users\<USER>\.codex\.env file, so this does not appear to be the proxy-env helper regression path.
This is high severity because it mutates or leaves behind Windows ownership state on user workspace directories. Even after the immediate failure is fixed by resetting the owner, users may not realize their project tree or parent directory is owned by a Codex sandbox account.
2 Comments
Potential duplicates detected. Please review them and close your issue if it is a duplicate.
Powered by Codex Action
I can confirm this issue also affects Codex inside VS Code on Windows, and I was able to recover the environment by restoring ownership of
.git.Environment:
openai.chatgpt-26.818.32112-win32-x64
Symptoms:
Even trivial commands such as:
Get-Date
git rev-parse HEAD
python --version
failed before PowerShell actually started with:
Failed to create unified exec process
helper_unknown_error: setup refresh had errors
~/.codex/.sandbox/setup_error.jsononly contained:{
"code": "helper_unknown_error",
"message": "setup refresh had errors"
}
However, the daily sandbox log exposed the actual failure:
deny ACE failed on C:\dev\proyectos\PD-Agent\.git:
SetNamedSecurityInfoW failed for C:\dev\proyectos\PD-Agent\.git: 5
setup refresh completed with errors
setup error: setup refresh had errors
I then checked ownership:
(Get-Acl "C:\dev\proyectos\PD-Agent\.git").Owner
Result:
DESKTOP-...\CodexSandboxOffline
WORKAROUND THAT RECOVERED CODEX:
.gitto the normal Windows user:icacls "C:\path\to\repo\.git" /setowner "MACHINE\USERNAME" /T /C
Important: running this from a non-elevated PowerShell resulted in "Access denied". It had to be run from an elevated Administrator PowerShell.
(Get-Acl "C:\path\to\repo\.git").Owner
Expected:
MACHINE\USERNAME
After doing only this ownership repair, without resetting ACLs, deleting
.git, reinstalling Codex, or modifying the repository, Codex immediately recovered.Verification inside Codex:
git rev-parse HEAD
git status --short --branch
python --version
All three executed successfully.
So in this case the root cause was specifically that
.githad been left owned byCodexSandboxOffline. The next sandbox setup refresh then attempted to apply the deny ACE to.git, Windows returned ERROR_ACCESS_DENIED (5), and the entire execution environment became unusable.This persisted across many hours, so simply waiting/restarting was not sufficient.
For other affected users, I would recommend CHECKING ownership first rather than blindly resetting ACLs:
(Get-Acl "C:\path\to\repo\.git").Owner
If it unexpectedly reports
CodexSandboxOfflineorCodexSandboxOnline, restoring ownership may recover the environment.It would also be helpful if Codex surfaced the underlying
SetNamedSecurityInfoW failed: 5error instead of only showing the genericsetup refresh had errors, becausesetup_error.jsoncurrently hides the actionable cause.