Select the elevated Windows sandbox for network proxies (#33445)

## Why

Windows firewall enforcement is tied to the logon-user sandbox identities. Proxy-enforced commands therefore need the elevated backend even when the configured sandbox mode is the default restricted-token mode.

## What changed

- Select the elevated Windows sandbox backend whenever a command uses the managed network proxy.
- Remove configuration and startup checks that required users or managed requirements to select the elevated sandbox explicitly.
- Start and expose managed network proxy state consistently on Windows.

## Testing

- Verify that proxy enforcement selects the elevated backend for the restricted-token sandbox mode.

GitOrigin-RevId: e01ac052587721c468a8fbcf4e2c7c5a185a3e05
This commit is contained in:
iceweasel-oai
2026-07-15 23:19:00 +00:00
committed by copyberry
parent 7d1218a997
commit 4bc2c723ef
23 changed files with 58 additions and 496 deletions
@@ -204,7 +204,6 @@ impl CommandExecRequestProcessor {
network_proxy_permission_profile,
managed_network_requirements_enabled,
windows_sandbox_workspace_roots,
windows_sandbox_level,
) = if let Some(permission_profile) = permission_profile {
let overrides = ConfigOverrides {
cwd: Some(cwd.to_path_buf()),
@@ -233,7 +232,6 @@ impl CommandExecRequestProcessor {
config.permissions.permission_profile().clone(),
config.managed_network_requirements_enabled(),
config.effective_workspace_roots(),
WindowsSandboxLevel::from_config(&config),
)
} else if let Some(policy) = sandbox_policy.map(|policy| policy.to_core()) {
self.config
@@ -260,7 +258,6 @@ impl CommandExecRequestProcessor {
self.config.permissions.permission_profile().clone(),
self.config.managed_network_requirements_enabled(),
self.config.effective_workspace_roots(),
windows_sandbox_level,
)
} else {
(
@@ -269,13 +266,9 @@ impl CommandExecRequestProcessor {
self.config.permissions.permission_profile().clone(),
self.config.managed_network_requirements_enabled(),
self.config.effective_workspace_roots(),
windows_sandbox_level,
)
};
let started_network_proxy = match network_proxy_spec
.as_ref()
.filter(|spec| !cfg!(target_os = "windows") || spec.enabled())
{
let started_network_proxy = match network_proxy_spec.as_ref() {
Some(spec) => match spec
.start_proxy(
&network_proxy_permission_profile,
@@ -63,19 +63,6 @@ impl WindowsSandboxRequestProcessor {
config.config_layer_stack.requirements(),
params.mode,
)?;
let target_windows_sandbox_level = match setup_mode {
CoreWindowsSandboxSetupMode::Elevated => WindowsSandboxLevel::Elevated,
CoreWindowsSandboxSetupMode::Unelevated => WindowsSandboxLevel::RestrictedToken,
};
codex_core::config::validate_windows_sandbox_network_proxy_compatibility(
target_windows_sandbox_level,
config
.permissions
.network
.as_ref()
.is_some_and(codex_core::config::NetworkProxySpec::enabled),
)
.map_err(|err| invalid_request(err.to_string()))?;
self.outgoing
.send_response(