Align Windows sandbox temp permissions with the child environment (#51512)

## Why

Windows temp grants could fall back to host `TEMP`/`TMP` values and bypass read-only or denied subpaths. Sandbox permissions must match the environment passed to the child process.

## What changed

- Resolve `:tmpdir` from absolute `TEMP`/`TMP` paths in the completed workload environment, preserving access modes and missing-path rules without falling back to host values.
- Deduplicate Windows environment keys case-insensitively in a deterministic order so permission resolution and the child environment select the same value.
- Use the resolved temp policy for elevated sandbox overrides across core execution, exec-server, and direct spawning.
- Launch direct-spawn sandbox wrappers with the supplied Codex executable, materializing an inner helper only when it is that executable.

## Testing

Add Windows regression coverage for temp-only writes, read-only and denied carveouts, mixed-case and duplicate environment keys, unavailable temp paths, and empty or missing write-root overrides. Exercise core execution and direct spawning, and extend exec-server RPC coverage to the elevated backend with temp values set through the environment policy.

GitOrigin-RevId: 16b8bd4702cc434fd743a08c75a3e4515780bff3
This commit is contained in:
zm-oai
2026-10-06 23:21:06 +00:00
committed by copyberry
parent 9545947c6d
commit 7efc49b258
12 changed files with 521 additions and 94 deletions
@@ -310,6 +310,7 @@ pub(crate) async fn prepare_exec_request_with_telemetry(
&permissions,
&native_sandbox_policy_cwd,
use_elevated,
&request.env,
)
} else {
resolve_windows_restricted_token_filesystem_overrides(