Windows sandbox leaks kernel access tokens (~33 per sandboxed command; paged pool grows until reboot)
What happens
On Windows 11, each command that the Codex CLI runs inside its Windows sandbox leaks kernel access-token objects. Paged pool tag Toke (with SeAt, SeTd and SeDt scaling alongside it) grows for as long as sandboxed commands run. It is never reclaimed until a full Restart. With Fast Startup on, "Shut down" hibernates the kernel and keeps the leak.
No user-mode process holds the tokens: the highest handle count system-wide is about 6k. So they appear to be kernel references that the sandbox's restricted-token / command-runner path never releases.
Reproduction
- Read the
Tokepool tag's live allocation count. We used NtQuerySystemInformation with SystemPoolTagInformation (class 22), which works without elevation; PoolMon gives the same number. - Run 20 sandboxed no-op commands:
1..20 | ForEach-Object { codex sandbox -- cmd /c exit 0 } - Read the
Tokecount again.
Measurements (Windows 11 Pro 10.0.26300, codex-cli 0.160.1)
| Run | Toke live delta |
|---|---|
20 × codex sandbox -- cmd /c exit 0 |
+918 in 43 s (about 33 per command above baseline) |
100 × plain python -c pass spawns, no sandbox |
at baseline |
idle, no codex-command-runner alive |
+107 in 60 s (an unrelated background rate) |
After about 18 hours of normal agent use: Toke was 1,692 MB of paged pool with 770k live allocations. A second machine (Windows 11 Home, 16 GB) showed the same signature: 1,360 MB Toke and 655k allocations. That came to about 1.7 GB of paged pool before a restart.
Expected
Sandboxed commands release their token references when the command exits, and paged pool stays flat.
Workaround
Restart (not Shut down) regularly, or turn off Fast Startup so Shut down clears kernel pool.
Related local observation, without claiming it reproduces the CLI sandbox path: On 2026-10-25 this PC was on Windows 11 Home 25H2 build 26200.9711, with OpenAI.Codex 26.1021.3705.0, 63.82 GiB RAM, and about 11 days uptime. During heavy Codex use, the current Toke tag was 2.50 GiB paged; related tags included SeAt 453 MiB, SeTd 170 MiB, SeDt 94 MiB paged / 29 MiB nonpaged, and SeTl 151 MiB nonpaged. A one-minute sample earlier on this boot measured +358 outstanding Toke allocations / about +0.74 MiB. I have not isolated whether this follows codex sandbox commands, desktop Git probing, or another process-creation path. The user also observed two ChatGPT/Codex desktop crashes in the preceding two hours; no matching Windows Application events were present, so there is no crash signature yet.
Additional data point, same signature, with a comparison between sandbox modes.
Environment: Windows 11 Pro 10.0.26300, Codex desktop app (MSIX 26.1029.7803.0 and 26.1103.4239.0, codex-cli 0.166 / 0.167 — same result on both), [windows] sandbox = "elevated".
Method: live Toke allocation count via NtQuerySystemInformation(SystemPoolTagInformation), read immediately before and after 100 sequential runs of each command.
| 100 × command | Δ Toke (live) |
|---|---|
| codex sandbox cmd /c echo x (elevated, default) | +505, +589, +527, +976 (4 trials) |
| codex sandbox -c windows.sandbox="unelevated" cmd /c echo x | +97, +126 (2 trials) |
| plain cmd /c echo x (no sandbox) | +10 |
| idle 30–60 s (no commands) | −26 to +94 |
So on this build each elevated-sandbox command leaves about 5–10 token objects behind, unelevated about 1, and a plain process about 0. SeTd, SeTl and SeDt track Toke one-to-one. Over a normal day the machine gains about 10,000 Toke per hour while Codex is in use and stays roughly flat at night. 3.2 days after a restart it had 649k live Toke (about 1.35 GB of paged pool).
Switching to unelevated looks like a usable mitigation (about 5× less), at the cost of weaker isolation.
I hit what appears to be the same failure signature on an AMD X3D desktop with 64 GiB RAM.
Environment
- Windows 11 Pro, build
26300.9974 - Codex Desktop
26.1117.4957.0 - installed PrimaryRuntime packages:
26.1119.907.0and26.1123.915.0 [windows] sandbox = "elevated"- system uptime before the incident: about 12 days 13 hours
User-visible failure
While World of Warcraft was running, it failed an allocation of 11,185,104 bytes and reported ERROR #109 (0x8510006d) Soft lockup. Immediately around the same time, Windows could no longer start even WerFault.exe, showing 0xc000012d (commitment limit reached). Firefox had also been running during the incident, but I closed it before the first complete process snapshot, so I cannot reliably attribute its exact private bytes.
Relevant local timestamps (UTC+05):
00:21:55— Windows Resource-Exhaustion-Detector event 26 (low virtual memory)00:25:59—WerFault.exefailed with0xc000012d00:26:00— DWM process crash00:26:54— WoW allocation failure / soft lock
Measurements before Restart
The process list did not explain the missing commit. The strongest signal was kernel pool / object growth:
| Counter | Value |
|---|---|
| Physical RAM | 61.61 GiB usable |
| Available RAM (after the collapse) | ~32.96 GiB |
| System commit (after some apps had already failed/closed) | 58.86 / 104.77 GiB |
| Paged pool | 7.026 GiB |
| Nonpaged pool | 5.585 GiB |
| Process private bytes total | 38.27 GiB |
| Pagefile current / peak | 2.67 / 12.90 GiB |
| System handles | ~673,878 |
| Token objects / handles | 1,287,648 / 665,852 |
Pool-tag breakdown:
| Tag | Bytes | Outstanding allocations |
|---|---|---|
Toke |
2,669.96 MiB paged | 1,287,668 |
SeAt |
473.45 MiB paged | 5,162,399 |
SeTd |
176.61 MiB paged | 1,287,668 |
SeDt |
96.38 MiB paged | — |
SeTl |
157.19 MiB nonpaged | — |
AleS |
2,426.32 MiB nonpaged | 662,246 |
This was not consistent with a GPU-driver allocation leak in the snapshot: NVIDIA NVRM was only about 64 MiB and GxDeviceLostCount was 0.
Full Restart comparison
After a full Windows Restart (not merely closing Codex/apps):
Toke: 11.47 MiB, 5,619 outstandingAleS: ~0.97 MiB, 262 outstanding- token objects / handles: 5,619 / 1,977
- system commit: ~21.4 / 123.6 GiB
- available RAM: ~45.4 GiB
That reset makes the sandbox token leak described in this issue the best match for the incident. A concurrent native autossh setup had 40 loopback tunnels implemented by 42 PowerShell workers / 52 ssh.exe processes; I am reducing that to 21 grouped workers with bounded exponential retry backoff to remove unnecessary process/token churn, but I do not claim autossh is the root cause. I am also adding a read-only 15-minute guard for Toke, AleS, and commit pressure. I am keeping the elevated sandbox for now because the machine needs unattended administrative capability; the guard warns early and does not kill Codex or other apps.
I can collect another pool-tag delta after normal Codex use if that would help validate a fix.