Skip to content

Windows sandbox helper creates an empty .git directory for a nonexistent deny-write path, triggering repeated Git probes and high Defender CPU usage #32324

Open

Description

@Suryxin-xx

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

26.623.19656.0

What subscription do you have?

Plus

What platform is your computer?

Windows11

What issue are you seeing?

The Codex Windows sandbox filesystem helper creates an empty .git directory in a workspace that is intentionally not a Git repository.

This happens after Codex uses file modification tools such as apply_patch.

I captured the directory creation with Microsoft Process Monitor. The process that creates the directory is codex.exe, running as the Windows restricted-token filesystem helper.

Observed process command line:

codex.exe --run-as-windows-sandbox
--windows-sandbox-level restricted-token
--workspace-root E:\Agent\Project\General
--deny-write-paths-json ["E:\Agent\Project\General.git"]
...
codex.exe --codex-run-as-fs-helper

The exact directory creation event was:

Time: 10:51:21.3906739
Process: codex.exe
PID: 19512
Operation: CreateFile
Path: E:\Agent\Project\General.git
Result: SUCCESS
Disposition: Create
Options: Directory
OpenResult: Created

The same process immediately performed:

QueryDirectory
QuerySecurityFile
SetSecurityFile

This indicates that the restricted-token filesystem helper receives .git as a deny-write path and creates the directory in order to apply a DACL, even though the path did not exist before.

The created .git directory is empty and is not a valid Git repository.

After the empty .git directory appears, the Codex Desktop Git worker repeatedly treats the workspace as a possible Git repository and starts many short-lived git.exe processes.

Observed repeated commands include:

git.exe -c core.hooksPath=NUL -c core.fsmonitor=false rev-parse --git-dir
git.exe -c core.hooksPath=NUL -c core.fsmonitor=false rev-parse HEAD
git.exe -c core.hooksPath=NUL -c core.fsmonitor=false remote -v
git.exe -c core.hooksPath=NUL -c core.fsmonitor=false status --porcelain
git.exe config --null --get core.fsmonitor

This causes a process creation loop. Microsoft Defender then scans the repeatedly created Git processes and related file activity, resulting in:

High Antimalware Service Executable CPU usage
Increased disk activity
High fan speed
Many simultaneous or rapidly created git.exe processes

Renaming or deleting the empty .git directory immediately stops the repeated Git probing. However, Codex recreates it again after another file-editing task.

The workspace was moved outside OneDrive and the problem still reproduces, so OneDrive is not the root cause.

Pure shell tasks do not reproduce the issue. File modifications using apply_patch or similar Codex file-editing tools reproduce it consistently.

Expected behavior:

A nonexistent path listed in --deny-write-paths-json should not be created merely to apply a deny ACL.

The sandbox helper should behave approximately like this:

if deny_path.exists() {
apply_deny_acl(deny_path)?;
} else {
// Do not materialize a nonexistent protected path.
continue;
}

For a Local workspace that is not a Git repository, Codex should not create .git, and the Git worker should not continuously probe an empty or invalid Git directory.

What steps can reproduce the bug?

On Windows, create a normal directory that is not a Git repository.

Example:

New-Item -ItemType Directory "E:\CodexNoGitTest" -Force
Set-Content "E:\CodexNoGitTest\test.txt" "hello"

Confirm that the workspace does not contain .git:

Test-Path "E:\CodexNoGitTest.git"

Expected result:

False
Open this directory in the Codex Windows App using Local mode with the Windows sandbox enabled.

Ask Codex to make a simple file edit that uses its file modification or patch tool.

Example request:

Change the contents of test.txt from "hello" to "hello world".

After the task finishes, inspect the workspace root:

Get-ChildItem "E:\CodexNoGitTest" -Force

Observe that Codex has created:

E:\CodexNoGitTest.git

Inspect the directory:

Get-ChildItem "E:\CodexNoGitTest.git" -Force

It is empty and is not a valid Git repository.

Monitor running Git processes:

Get-CimInstance Win32_Process |
Where-Object { $_.Name -eq "git.exe" } |
Select-Object ProcessId, ParentProcessId, CommandLine

Observe repeated Git repository probes such as:

rev-parse --git-dir
rev-parse HEAD
remote -v
status --porcelain
config --get core.fsmonitor
Rename or remove only the empty .git directory:
Rename-Item "E:\CodexNoGitTest.git" ".git.disabled-empty"
Observe that the repeated Git probes stop.
Run another Codex file-editing task and observe that the empty .git directory is created again.

Additional Process Monitor reproduction:

Filter by:

Path is E:\CodexNoGitTest.git
Operation is CreateFile
The first successful creation event is performed by codex.exe.

The process is running with:

--run-as-windows-sandbox
--windows-sandbox-level restricted-token
--deny-write-paths-json ["E:\CodexNoGitTest.git"]
--codex-run-as-fs-helper

The CreateFile event uses:

Disposition: Create
Options: Directory
OpenResult: Created

This suggests the bug is in the shared Windows restricted-token filesystem helper rather than in Git, Defender, OneDrive, the shell, or a workspace script.

What is the expected behavior?

No response

Additional information

No response

Activity

  1. added
    appIssues related to the Codex desktop app
    on Jul 11, 2026
  2. added
    bugSomething isn't working
    windows-osIssues related to Codex on Windows systems
    sandboxIssues related to permissions or sandboxing
    on Jul 11, 2026
  3. github-actions commented on Jul 11, 2026

    @github-actions
    Contributor
  4. XucroYuri commented on Jul 11, 2026

    @XucroYuri

    Additional evidence from two non-repository Windows workspaces, including timestamps that separate creation of an invalid .git path from later CodeGraph activity.

    Environment

    • Codex Desktop: 26.707.3748.0
    • Codex CLI: 0.144.1
    • OS: Windows 11 Pro for Workstations, build 26200, x64

    Observed invalid Git paths

    1. C:\Users\<user>\Documents\Codex\2026-07-11\xiu\.git

      • Creation time: 2026-07-11 17:30:57 local time
      • Directory entries: 0
      • git -C <workspace> rev-parse --is-inside-work-tree: false / exit failure
    2. D:\TTS\.git

      • Top-level .git creation time: 2026-07-11 10:17:14
      • It was not a valid repository.
      • At 17:27:30, a later integration wrote only .git\info\exclude containing .codegraph.
      • The valid repositories are nested below this root (D:\TTS\TTS_more, etc.); D:\TTS itself remained invalid.

    The second timestamp sequence is useful for attribution: the .git directory existed hours before CodeGraph wrote info/exclude. The current CodeGraph helper only writes when .git already exists, so it did not create the top-level marker in this occurrence. I did not have Process Monitor provenance for the initial creation event, but this state and timing independently match the sandbox-created invalid .git shape reported here.

    Once these non-repository / invalid-repository roots were present in Desktop state, a separate process sample observed 21 Codex-owned git.exe PIDs in 4 seconds, primarily rev-parse --show-toplevel and config --get core.fsmonitor.

    Suggested regression coverage

    • A nonexistent deny-write path must remain nonexistent after ACL preparation.
    • An empty/non-repository .git directory must not cause repeated Git discovery.
    • A nested valid repository must not cause its non-repository parent to be materialized as another .git root.

    This issue or PR was generated by LazyCodex.
    Tag: lazycodex-generated

  5. suiyuebaobao commented on Jul 22, 2026

    @suiyuebaobao

    The empty .git path, repeated Git probes, and downstream Defender CPU here closely match the process chain I reproduced.

    I published a single-file Windows launcher for the original Microsoft Store/MSIX Codex app:

    It starts Codex with a process-scoped GIT_DIR=NUL. On my machine, the stable trace changed from 247 new git.exe and 137 new taskkill.exe processes per 10 seconds to 0 and 0 over 15 seconds; WMI Provider Host fell from about 6.6% to 0.9%.

    Usage: fully exit Codex from the Windows system tray, then run the script.

    This is an unofficial workaround, not an upstream fix. It deliberately disables or limits Review, Changes, branch detection, commit, and other Git-backed Codex features. It does not patch Codex, modify repositories or Git configuration, write system environment variables, require elevation, terminate processes, or remove chat history. Launching Codex normally restores Git integration.

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

    appIssues related to the Codex desktop appbugSomething isn't workingperformancesandboxIssues related to permissions or sandboxingwindows-osIssues related to Codex on Windows systems

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions