mirror of
https://github.com/openai/codex.git
synced 2026-11-27 15:30:27 +00:00
[codex] Preserve proxy state for filesystem sandbox helpers (#29671)
## Why Filesystem helpers intentionally run with a minimal environment that excludes proxy variables. After filesystem operations started using the Windows sandbox wrapper, the wrapper derived an empty proxy configuration from that helper environment and compared it with the persistent sandbox setup marker. When the marker contained proxy ports, every filesystem operation appeared to require a firewall update, which could launch elevated setup, show a UAC or loader dialog, and fail operations such as `apply_patch` with error 1223. Filesystem helpers do not use network access, so they should preserve the proxy/firewall state established by normal sandboxed process launches. ## What changed - Add an explicit Windows sandbox proxy-settings mode for reconciling or preserving persistent proxy state. - Use preserve mode for filesystem helpers while normal process launches continue to reconcile proxy settings from their environment. - Carry the selected proxy state consistently through setup validation, elevated setup, and non-elevated ACL refreshes. - Cover wrapper argument propagation and marker-derived proxy preservation. ## Validation - `cargo build -p codex-cli --bin codex` - `just test -p codex-windows-sandbox preserving_proxy_settings_uses_the_existing_marker` - `just test -p codex-windows-sandbox windows_wrapper_args_round_trip` - `just test -p codex-windows-sandbox setup_request_prefers_explicit_proxy_settings` - `just test -p codex-sandboxing transform_for_direct_spawn_windows` - `just test -p codex-exec-server fs_sandbox::tests` - Ran the same sandboxed `fs/writeFile` reproduction against published `0.142.0-alpha.6` and the new CLI. The published CLI launched elevated setup and failed with `ShellExecuteExW ... 1223`; the new CLI completed without elevation. Related to #28359.
This commit is contained in:
1 parent
ff50b47dce
commit
18fe1d9fe3
15 files changed
+211
-15
No files matched your search
@@ -152,6 +152,7 @@ pub struct SandboxTransformRequest<'a> {
|
||||
pub struct SandboxDirectSpawnTransformRequest<'a> {
|
||||
pub transform: SandboxTransformRequest<'a>,
|
||||
pub workspace_roots: &'a [AbsolutePathBuf],
|
||||
pub windows_sandbox_proxy_settings_mode: codex_windows_sandbox::WindowsSandboxProxySettingsMode,
|
||||
}
|
||||
|
||||
// TODO(anp): Revisit this preparation type once this module's PathUri migration is complete.
|
||||
@@ -484,12 +485,14 @@ impl SandboxManager {
|
||||
codex_home: &Path,
|
||||
) -> Result<SandboxExecRequest, SandboxTransformError> {
|
||||
let workspace_roots = request.workspace_roots;
|
||||
let proxy_settings_mode = request.windows_sandbox_proxy_settings_mode;
|
||||
let mut request = self.transform(request.transform)?;
|
||||
if request.sandbox == SandboxType::WindowsRestrictedToken {
|
||||
wrap_windows_sandbox_exec_request_for_direct_spawn(
|
||||
&mut request,
|
||||
workspace_roots,
|
||||
codex_home,
|
||||
proxy_settings_mode,
|
||||
)?;
|
||||
}
|
||||
Ok(request)
|
||||
@@ -501,6 +504,7 @@ fn wrap_windows_sandbox_exec_request_for_direct_spawn(
|
||||
request: &mut SandboxExecRequest,
|
||||
workspace_roots: &[AbsolutePathBuf],
|
||||
codex_home: &Path,
|
||||
proxy_settings_mode: codex_windows_sandbox::WindowsSandboxProxySettingsMode,
|
||||
) -> Result<(), SandboxTransformError> {
|
||||
// TODO(anp): Keep PathUri through the Windows sandbox wrapper boundary.
|
||||
let native_cwd =
|
||||
@@ -572,6 +576,7 @@ fn wrap_windows_sandbox_exec_request_for_direct_spawn(
|
||||
request.windows_sandbox_level,
|
||||
request.windows_sandbox_private_desktop,
|
||||
proxy_enforced,
|
||||
proxy_settings_mode,
|
||||
read_roots_override,
|
||||
read_roots_include_platform_defaults,
|
||||
write_roots_override,
|
||||
|
||||
Reference in new issue
Block a user