openai / openai/codex

Windows sandbox blocks MSBuild WriteLinesToFile temp *~ files with MSB3491 in elevated and unelevated modes

Open
#39,927 1 comment 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

app bug sandbox windows-os
Dominant language
Rust
Stars
125k
Forks
19.4k
PR merge metrics
PR metrics pending

Description

What version of the Codex App are you using?

Codex Desktop for Windows 26.818.31338

Bundled CLI:

codex-cli 0.149.0-alpha.4

The CLI also emits:

WARNING: failed to clean up stale arg0 temp dirs: Access is denied. (os error 5)
WARNING: proceeding, even though we could not create PATH aliases: Access is denied. (os error 5)
What platform is your computer?
Microsoft Windows NT 10.0.26200.0 x64

Native Windows Codex Desktop sandbox. Reproduced in both:

[windows]
sandbox = "elevated"

and, after a full Desktop restart:

[windows]
sandbox = "unelevated"
Summary

After updating Codex Desktop, sandboxed MSBuild cannot execute a minimal WriteLinesToFile task against a declared writable workspace. MSBuild fails with MSB3491 while creating/writing its random *~ temporary file in the output directory.

The requested target .cache file is never created, so the failure occurs before replacement/overwrite of the target.

The same deterministic failure occurs under both the elevated and unelevated Windows sandbox implementations.

Minimal reproduction

Use any existing writable directory below the active workspace, represented below as:

D:\workspace\repo\obj\Debug\net10.0

Create a uniquely named project under the current user's system TEMP:

<Project>
  <Target Name="Probe">
    <WriteLinesToFile
      File="D:\workspace\repo\obj\Debug\net10.0\codex-writelines-target-<GUID>.cache"
      Lines="msbuild-probe-content"
      Overwrite="true"
      WriteOnlyWhenDifferent="true" />
  </Target>
</Project>

Run exactly once:

dotnet msbuild "$env:TEMP\codex-writelines-<GUID>.proj" /t:Probe /nologo
Actual behavior
error MSB3491: Failed to write lines to file
"D:\workspace\repo\obj\Debug\net10.0\codex-writelines-target-<GUID>.cache".
Access to the path
'D:\workspace\repo\obj\Debug\net10.0\<random-name>.<random-extension>~'
is denied.

dotnet msbuild ExitCode: 1
Target file: absent

Concrete redacted path shape:

...\obj\Debug\net10.0\ijvhd5q2.lpn~

No solution is loaded, no restore runs, and no source project is referenced.

Expected behavior

WriteLinesToFile should create its temporary file and atomically produce the target inside a declared writable workspace directory. The command should exit 0 in both supported sandbox modes.

Controls and diagnostics
  • The workspace is trusted and advertised as writable.
  • The output directory exists.
  • The directory ACL grants inherited Modify permission to the Codex sandbox group.
  • The existing real AssemblyInfoInputs.cache file is owned by the host user, has only the Archive attribute, and inherits Modify permission.
  • A basic uniquely named .tmp create/read/delete probe previously succeeded in the same directory.
  • The minimal MSBuild target still fails on the random *~ file.
  • At failure time, the requested target .cache file does not exist.
  • Under elevated mode, the process identity is the dedicated CodexSandboxOffline user.
  • Under unelevated mode after a full restart, the process identity is the host Windows user; the failure remains identical.
  • Shutting down MSBuild build servers does not help.
  • Disabling build servers and forcing -m:1 does not help.
  • No ACL modifications are needed for the same repository to build outside the Codex sandbox.
Impact

Normal .NET builds fail during CreateGeneratedAssemblyInfoInputsCacheFile:

Microsoft.NET.GenerateAssemblyInfo.targets(...): error MSB3491
...AssemblyInfoInputs.cache
Access to the path '...\<random>~' is denied.

This prevents Codex Desktop from validating .NET changes in native Windows sandbox mode.

Related issues
  • #34179 — unelevated sandbox starts commands but workspace writes fail
  • #32168 — unelevated sandbox and split writable roots
  • #32184 — Windows App sandbox child-process / Access denied regression

This report is narrower: it provides a standalone MSBuild WriteLinesToFile reproduction and demonstrates that the failure is on the random *~ temporary file before the target exists.

Privacy note

All user names, machine names, and project-specific paths have been redacted. No raw sandbox logs or project contents are attached.

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start by running the supplied dotnet msbuild minimal WriteLinesToFile reproduction in both elevated and unelevated sandbox modes, then inspect the Windows sandbox handling of temporary workspace writes. Done means the command exits 0 and creates the target file in both modes without the random *~ file being denied.

Written by the indexing model from the issue text.

Assessment

Tech stack
rust
Domain
operating-systems, security
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Active
Clarity
Needs clarification
Newbie friendliness
38/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.