diff --git a/codex-rs/windows-sandbox-rs/src/elevated/runner_client.rs b/codex-rs/windows-sandbox-rs/src/elevated/runner_client.rs index d313b6cfcc..0a974363f8 100644 --- a/codex-rs/windows-sandbox-rs/src/elevated/runner_client.rs +++ b/codex-rs/windows-sandbox-rs/src/elevated/runner_client.rs @@ -36,7 +36,6 @@ use windows_sys::Win32::System::Pipes::PeekNamedPipe; use windows_sys::Win32::System::Threading::CreateProcessWithLogonW; use windows_sys::Win32::System::Threading::GetCurrentProcess; use windows_sys::Win32::System::Threading::GetCurrentThread; -use windows_sys::Win32::System::Threading::LOGON_WITH_PROFILE; use windows_sys::Win32::System::Threading::PROCESS_INFORMATION; use windows_sys::Win32::System::Threading::STARTUPINFOW; use windows_sys::Win32::System::Threading::TerminateProcess; @@ -46,6 +45,7 @@ const RUNNER_SPAWN_READY_TIMEOUT: Duration = Duration::from_secs(15); const RUNNER_PIPE_CONNECT_TIMEOUT: Duration = Duration::from_secs(15); const RUNNER_SPAWN_READY_POLL_INTERVAL: Duration = Duration::from_millis(50); const RUNNER_ERROR_MODE_FLAGS: u32 = 0x0001 | 0x0002; +const RUNNER_LOGON_FLAGS: u32 = 0; const WAIT_OBJECT_0: u32 = 0; pub(crate) struct RunnerTransport { @@ -256,7 +256,10 @@ pub(crate) fn spawn_runner_transport( user_w.as_ptr(), domain_w.as_ptr(), password_w.as_ptr(), - LOGON_WITH_PROFILE, + // The runner only needs a sandbox-user token. Forcing profile loading on every + // spawn can trigger Windows TEMP.* fallback profiles when profile initialization + // or unload is unhealthy, which matches issue #21455's leak pattern. + RUNNER_LOGON_FLAGS, exe_w.as_ptr(), cmdline_vec.as_mut_ptr(), windows_sys::Win32::System::Threading::CREATE_NO_WINDOW