Wire the Windows MXC sandbox into command execution (#45176)

## What changed

- Add explicit MXC backend selection and carry its identity through exec-server process reporting and sandbox violation classification.
- Launch MXC through the Codex executable with the effective permission profile and command environment.
- Reject exec-server MXC requests when native MXC is unavailable or when they request a TTY, an `arg0` override, or managed networking. Reject private desktop isolation during MXC preparation.
- Allow an explicitly empty child environment and avoid exposing request payload values in launcher decode errors.

## Testing

Add coverage for sandbox selection and unsupported-request rejection, plus Windows RPC tests for stdin writes and temporary-directory permissions derived from the command environment. Native MXC tests skip when MXC is unavailable.

GitOrigin-RevId: 3626ff0f9ad7f9b812ce09b68c31ea9a5a9c72b1
This commit is contained in:
iceweasel-oai authored and copyberry committed 2026-09-13 06:07:03 +00:00
1 parent dfaf451426
commit c379459bba
37 files changed
+422 -85

No files matched your search

+48 -6
View File
@@ -25,6 +25,48 @@ use pretty_assertions::assert_eq;
use std::collections::HashMap;
use tempfile::TempDir;
#[test]
fn mxc_selection_preserves_unsandboxed_requests_and_other_platforms() {
let manager = SandboxManager::new();
let platform_sandbox = if cfg!(windows) {
SandboxType::WindowsMxc
} else {
get_platform_sandbox(/*windows_sandbox_enabled*/ false).unwrap_or(SandboxType::None)
};
for (permissions, preference, expected) in [
(
PermissionProfile::read_only(),
SandboxablePreference::Auto,
platform_sandbox,
),
(
PermissionProfile::Disabled,
SandboxablePreference::Require,
platform_sandbox,
),
(
PermissionProfile::read_only(),
SandboxablePreference::Forbid,
SandboxType::None,
),
(
PermissionProfile::Disabled,
SandboxablePreference::Auto,
SandboxType::None,
),
] {
assert_eq!(
manager.select_initial(
&permissions,
preference,
WindowsSandboxLevel::Mxc,
/*has_managed_network_requirements*/ false,
),
expected,
);
}
}
#[test]
fn danger_full_access_defaults_to_no_sandbox_without_network_requirements() {
let manager = SandboxManager::new();
@@ -103,7 +145,7 @@ fn unsandboxed_transform_preserves_foreign_cwd_and_unrestricted_file_system_poli
environment_id: None,
network: None,
sandbox_policy_cwd: &cwd_uri,
codex_linux_sandbox_exe: None,
sandbox_exe: None,
use_legacy_landlock: false,
windows_sandbox_level: WindowsSandboxLevel::Disabled,
windows_sandbox_private_desktop: false,
@@ -160,7 +202,7 @@ fn symlinked_workspace_reports_seatbelt_preparation_error() {
environment_id: None,
network: None,
sandbox_policy_cwd: &workspace_uri,
codex_linux_sandbox_exe: None,
sandbox_exe: None,
use_legacy_landlock: false,
windows_sandbox_level: WindowsSandboxLevel::Disabled,
windows_sandbox_private_desktop: false,
@@ -215,7 +257,7 @@ fn transform_additional_permissions_enable_network_for_external_sandbox() {
environment_id: None,
network: None,
sandbox_policy_cwd: &cwd_uri,
codex_linux_sandbox_exe: None,
sandbox_exe: None,
use_legacy_landlock: false,
windows_sandbox_level: WindowsSandboxLevel::Disabled,
windows_sandbox_private_desktop: false,
@@ -286,7 +328,7 @@ fn transform_additional_permissions_preserves_denied_entries() {
environment_id: None,
network: None,
sandbox_policy_cwd: &cwd_uri,
codex_linux_sandbox_exe: None,
sandbox_exe: None,
use_legacy_landlock: false,
windows_sandbox_level: WindowsSandboxLevel::Disabled,
windows_sandbox_private_desktop: false,
@@ -388,7 +430,7 @@ fn transform_linux_seccomp_request(
environment_id: None,
network: None,
sandbox_policy_cwd: &cwd_uri,
codex_linux_sandbox_exe: Some(codex_linux_sandbox_exe),
sandbox_exe: Some(codex_linux_sandbox_exe),
use_legacy_landlock: false,
windows_sandbox_level: WindowsSandboxLevel::Disabled,
windows_sandbox_private_desktop: false,
@@ -590,7 +632,7 @@ fn transform_for_direct_spawn_windows_materializes_inner_helper() {
environment_id: None,
network: None,
sandbox_policy_cwd: &cwd_uri,
codex_linux_sandbox_exe: None,
sandbox_exe: None,
use_legacy_landlock: false,
windows_sandbox_level: WindowsSandboxLevel::Elevated,
windows_sandbox_private_desktop: false,