From 8b1545902e2536fe0207177bd1900d4f891db79a Mon Sep 17 00:00:00 2001 From: David Wiesen Date: Tue, 21 Apr 2026 02:06:38 -0700 Subject: [PATCH] windows: skip WindowsApps read ACL grants --- .../src/setup_orchestrator.rs | 22 +++++++++++++++++++ 1 file changed, 22 insertions(+) diff --git a/codex-rs/windows-sandbox-rs/src/setup_orchestrator.rs b/codex-rs/windows-sandbox-rs/src/setup_orchestrator.rs index f6583e0de4..e3d32835b0 100644 --- a/codex-rs/windows-sandbox-rs/src/setup_orchestrator.rs +++ b/codex-rs/windows-sandbox-rs/src/setup_orchestrator.rs @@ -58,6 +58,7 @@ const WINDOWS_PLATFORM_DEFAULT_READ_ROOTS: &[&str] = &[ r"C:\Program Files (x86)", r"C:\ProgramData", ]; +const WINDOWS_APPS_READ_ROOT: &str = "c:/program files/windowsapps"; pub fn sandbox_dir(codex_home: &Path) -> PathBuf { codex_home.join(".sandbox") @@ -334,6 +335,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_windows_apps_path(dir) { roots.push(dir.to_path_buf()); } @@ -343,6 +345,11 @@ fn gather_helper_read_roots(codex_home: &Path) -> Vec { roots } +fn is_windows_apps_path(path: &Path) -> bool { + let key = canonical_path_key(path); + key == WINDOWS_APPS_READ_ROOT || key.starts_with(&format!("{WINDOWS_APPS_READ_ROOT}/")) +} + fn gather_legacy_full_read_roots( command_cwd: &Path, policy: &SandboxPolicy, @@ -804,6 +811,7 @@ mod tests { use super::WINDOWS_PLATFORM_DEFAULT_READ_ROOTS; use super::gather_legacy_full_read_roots; use super::gather_read_roots; + use super::is_windows_apps_path; use super::loopback_proxy_port_from_url; use super::offline_proxy_settings_from_env; use super::profile_read_roots; @@ -816,6 +824,7 @@ mod tests { use std::collections::HashMap; use std::collections::HashSet; use std::fs; + use std::path::Path; use std::path::PathBuf; use tempfile::TempDir; @@ -1009,6 +1018,19 @@ mod tests { assert!(roots.contains(&expected)); } + #[test] + fn windows_apps_path_detection_matches_store_install_roots() { + assert!(is_windows_apps_path(Path::new( + r"C:\Program Files\WindowsApps\OpenAI.Codex_26.417.5275.0_x64__2p2nqsd0c76g0\app\resources" + ))); + assert!(is_windows_apps_path(Path::new( + "c:/program files/windowsapps/OpenAI.Codex/app/resources" + ))); + assert!(!is_windows_apps_path(Path::new( + r"C:\Program Files\OpenAI.Codex\app\resources" + ))); + } + #[test] fn restricted_read_roots_skip_platform_defaults_when_disabled() { let tmp = TempDir::new().expect("tempdir");