From 058916a2a976d40a794e5dead4c8a2136a568cb3 Mon Sep 17 00:00:00 2001 From: David Wiesen Date: Wed, 15 Apr 2026 10:09:31 -0700 Subject: [PATCH] Avoid WindowsApps ACL refresh roots --- .../src/setup_orchestrator.rs | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/codex-rs/windows-sandbox-rs/src/setup_orchestrator.rs b/codex-rs/windows-sandbox-rs/src/setup_orchestrator.rs index e0a5a063f9..e3d9a2f764 100644 --- a/codex-rs/windows-sandbox-rs/src/setup_orchestrator.rs +++ b/codex-rs/windows-sandbox-rs/src/setup_orchestrator.rs @@ -345,6 +345,7 @@ fn gather_helper_read_roots(codex_home: &Path) -> Vec { let mut roots = Vec::new(); if let Ok(exe) = std::env::current_exe() && let Some(dir) = exe.parent() + && !is_windowsapps_package_dir(dir) { roots.push(dir.to_path_buf()); } @@ -354,6 +355,14 @@ fn gather_helper_read_roots(codex_home: &Path) -> Vec { roots } +fn is_windowsapps_package_dir(path: &Path) -> bool { + let normalized = path + .to_string_lossy() + .replace('/', "\\") + .to_ascii_lowercase(); + normalized.contains("\\program files\\windowsapps\\") +} + fn gather_legacy_full_read_roots( command_cwd: &Path, policy: &SandboxPolicy, @@ -1060,6 +1069,16 @@ mod tests { assert!(roots.contains(&expected)); } + #[test] + fn windowsapps_package_dirs_are_detected() { + assert!(is_windowsapps_package_dir(Path::new( + r"C:\Program Files\WindowsApps\OpenAI.Codex_26.409.7971.0_x64__2p2nqsd0c76g0\app\resources" + ))); + assert!(!is_windowsapps_package_dir(Path::new( + r"C:\Users\alice\.codex\.sandbox\bin" + ))); + } + #[test] fn restricted_read_roots_skip_platform_defaults_when_disabled() { let tmp = TempDir::new().expect("tempdir");