From a2d62cf4183fb35a3aad12437bf32e2843b543cd Mon Sep 17 00:00:00 2001 From: David Wiesen Date: Wed, 15 Apr 2026 13:32:45 -0700 Subject: [PATCH] fix: skip WindowsApps read-root grants --- .../src/setup_orchestrator.rs | 24 +++++++++++++++++++ 1 file changed, 24 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..7306758291 100644 --- a/codex-rs/windows-sandbox-rs/src/setup_orchestrator.rs +++ b/codex-rs/windows-sandbox-rs/src/setup_orchestrator.rs @@ -341,10 +341,21 @@ fn profile_read_roots(user_profile: &Path) -> Vec { .collect() } +fn should_include_current_exe_read_root(dir: &Path) -> bool { + let normalized = dir + .to_string_lossy() + .replace('/', "\\") + .trim_start_matches(r"\\?\") + .to_ascii_lowercase(); + normalized != r"c:\program files\windowsapps" + && !normalized.starts_with(r"c:\program files\windowsapps\") +} + 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() + && should_include_current_exe_read_root(dir) { roots.push(dir.to_path_buf()); } @@ -1060,6 +1071,19 @@ mod tests { assert!(roots.contains(&expected)); } + #[test] + fn current_exe_read_root_skips_windowsapps_store_paths() { + assert!(!should_include_current_exe_read_root(Path::new( + r"C:\Program Files\WindowsApps\OpenAI.Codex_1.2.3.4_x64__example\app\resources" + ))); + assert!(!should_include_current_exe_read_root(Path::new( + r"\\?\C:\Program Files\WindowsApps\OpenAI.Codex_1.2.3.4_x64__example" + ))); + assert!(should_include_current_exe_read_root(Path::new( + r"C:\Program Files\OpenAI\Codex" + ))); + } + #[test] fn restricted_read_roots_skip_platform_defaults_when_disabled() { let tmp = TempDir::new().expect("tempdir");