mirror of
https://github.com/openai/codex.git
synced 2026-11-27 23:31:09 +00:00
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:
1 parent
dfaf451426
commit
c379459bba
37 files changed
+422
-85
No files matched your search
@@ -88,7 +88,7 @@ impl ToolOrchestrator {
|
||||
manager: attempt.manager,
|
||||
sandbox_cwd: attempt.sandbox_cwd,
|
||||
workspace_roots: attempt.workspace_roots,
|
||||
codex_linux_sandbox_exe: attempt.codex_linux_sandbox_exe,
|
||||
sandbox_exe: attempt.sandbox_exe,
|
||||
use_legacy_landlock: attempt.use_legacy_landlock,
|
||||
windows_sandbox_level: attempt.windows_sandbox_level,
|
||||
windows_sandbox_private_desktop: attempt.windows_sandbox_private_desktop,
|
||||
@@ -290,6 +290,11 @@ impl ToolOrchestrator {
|
||||
.sandbox_cwd(req)
|
||||
.cloned()
|
||||
.unwrap_or_else(|| environment.cwd().clone());
|
||||
let codex_sandbox_exe = if cfg!(windows) {
|
||||
turn_ctx.config.codex_self_exe.as_ref()
|
||||
} else {
|
||||
turn_ctx.config.codex_linux_sandbox_exe.as_ref()
|
||||
};
|
||||
let initial_attempt = SandboxAttempt {
|
||||
sandbox: initial_sandbox,
|
||||
sandbox_requested,
|
||||
@@ -299,7 +304,7 @@ impl ToolOrchestrator {
|
||||
manager: &sandbox_manager,
|
||||
sandbox_cwd: &sandbox_policy_cwd,
|
||||
workspace_roots,
|
||||
codex_linux_sandbox_exe: turn_ctx.config.codex_linux_sandbox_exe.as_ref(),
|
||||
sandbox_exe: codex_sandbox_exe,
|
||||
use_legacy_landlock: sandbox_config.use_legacy_landlock,
|
||||
windows_sandbox_level: sandbox_config.windows_sandbox_level,
|
||||
windows_sandbox_private_desktop: sandbox_config.windows_sandbox_private_desktop,
|
||||
@@ -459,10 +464,10 @@ impl ToolOrchestrator {
|
||||
} else {
|
||||
SandboxType::None
|
||||
};
|
||||
let retry_codex_linux_sandbox_exe = if unsandboxed_allowed {
|
||||
let retry_sandbox_exe = if unsandboxed_allowed {
|
||||
None
|
||||
} else {
|
||||
turn_ctx.config.codex_linux_sandbox_exe.as_ref()
|
||||
codex_sandbox_exe
|
||||
};
|
||||
let retry_attempt = SandboxAttempt {
|
||||
sandbox: retry_sandbox,
|
||||
@@ -473,7 +478,7 @@ impl ToolOrchestrator {
|
||||
manager: &sandbox_manager,
|
||||
sandbox_cwd: &sandbox_policy_cwd,
|
||||
workspace_roots,
|
||||
codex_linux_sandbox_exe: retry_codex_linux_sandbox_exe,
|
||||
sandbox_exe: retry_sandbox_exe,
|
||||
use_legacy_landlock: sandbox_config.use_legacy_landlock,
|
||||
windows_sandbox_level: sandbox_config.windows_sandbox_level,
|
||||
windows_sandbox_private_desktop: sandbox_config.windows_sandbox_private_desktop,
|
||||
|
||||
@@ -246,7 +246,7 @@ async fn file_system_sandbox_context_preserves_executor_workspace_permissions()
|
||||
manager: &manager,
|
||||
sandbox_cwd: &sandbox_policy_cwd,
|
||||
workspace_roots: std::slice::from_ref(&sandbox_policy_cwd),
|
||||
codex_linux_sandbox_exe: None,
|
||||
sandbox_exe: None,
|
||||
use_legacy_landlock: true,
|
||||
windows_sandbox_level: WindowsSandboxLevel::RestrictedToken,
|
||||
windows_sandbox_private_desktop: true,
|
||||
@@ -315,7 +315,7 @@ async fn file_system_sandbox_context_respects_sandbox_request() {
|
||||
manager: &manager,
|
||||
sandbox_cwd: &sandbox_policy_cwd,
|
||||
workspace_roots: std::slice::from_ref(&sandbox_policy_cwd),
|
||||
codex_linux_sandbox_exe: None,
|
||||
sandbox_exe: None,
|
||||
use_legacy_landlock: false,
|
||||
windows_sandbox_level: WindowsSandboxLevel::Disabled,
|
||||
windows_sandbox_private_desktop: false,
|
||||
|
||||
@@ -124,7 +124,7 @@ async fn explicit_escalation_prepares_exec_without_managed_network() -> anyhow::
|
||||
manager: &manager,
|
||||
sandbox_cwd: &sandbox_policy_cwd,
|
||||
workspace_roots: std::slice::from_ref(&sandbox_policy_cwd),
|
||||
codex_linux_sandbox_exe: None,
|
||||
sandbox_exe: None,
|
||||
use_legacy_landlock: false,
|
||||
windows_sandbox_level: WindowsSandboxLevel::Disabled,
|
||||
windows_sandbox_private_desktop: false,
|
||||
|
||||
@@ -789,7 +789,7 @@ impl CoreShellCommandExecutor {
|
||||
environment_id: self.network_environment_id.as_deref(),
|
||||
network: self.network.as_ref(),
|
||||
sandbox_policy_cwd: &sandbox_policy_cwd,
|
||||
codex_linux_sandbox_exe: self.codex_linux_sandbox_exe.as_deref(),
|
||||
sandbox_exe: self.codex_linux_sandbox_exe.as_deref(),
|
||||
use_legacy_landlock: self.use_legacy_landlock,
|
||||
windows_sandbox_level: self.windows_sandbox_level,
|
||||
windows_sandbox_private_desktop: false,
|
||||
|
||||
@@ -394,7 +394,7 @@ pub(crate) struct SandboxAttempt<'a> {
|
||||
pub(crate) manager: &'a SandboxManager,
|
||||
pub(crate) sandbox_cwd: &'a PathUri,
|
||||
pub(crate) workspace_roots: &'a [PathUri],
|
||||
pub codex_linux_sandbox_exe: Option<&'a std::path::PathBuf>,
|
||||
pub sandbox_exe: Option<&'a std::path::PathBuf>,
|
||||
// TODO(anp): Reconcile these attempt settings with TurnEnvironment::sandbox_context
|
||||
// so process execution and patch writes honor the selected environment's backend.
|
||||
pub use_legacy_landlock: bool,
|
||||
@@ -459,9 +459,7 @@ impl<'a> SandboxAttempt<'a> {
|
||||
environment_id,
|
||||
network,
|
||||
sandbox_policy_cwd: self.sandbox_cwd,
|
||||
codex_linux_sandbox_exe: self
|
||||
.codex_linux_sandbox_exe
|
||||
.map(std::path::PathBuf::as_path),
|
||||
sandbox_exe: self.sandbox_exe.map(std::path::PathBuf::as_path),
|
||||
use_legacy_landlock: self.use_legacy_landlock,
|
||||
windows_sandbox_level: self.windows_sandbox_level,
|
||||
windows_sandbox_private_desktop: self.windows_sandbox_private_desktop,
|
||||
@@ -496,7 +494,7 @@ impl<'a> SandboxAttempt<'a> {
|
||||
environment_id: None,
|
||||
network: None,
|
||||
sandbox_policy_cwd: self.sandbox_cwd,
|
||||
codex_linux_sandbox_exe: None,
|
||||
sandbox_exe: None,
|
||||
use_legacy_landlock: self.use_legacy_landlock,
|
||||
windows_sandbox_level: self.windows_sandbox_level,
|
||||
windows_sandbox_private_desktop: self.windows_sandbox_private_desktop,
|
||||
|
||||
@@ -255,7 +255,7 @@ fn windows_sandbox_env_preserves_denied_reads_or_rejects_unsupported_backend() {
|
||||
manager: &manager,
|
||||
sandbox_cwd: &cwd_uri,
|
||||
workspace_roots: std::slice::from_ref(&cwd_uri),
|
||||
codex_linux_sandbox_exe: None,
|
||||
sandbox_exe: None,
|
||||
use_legacy_landlock: false,
|
||||
windows_sandbox_level: codex_protocol::config_types::WindowsSandboxLevel::Elevated,
|
||||
windows_sandbox_private_desktop: false,
|
||||
@@ -326,7 +326,7 @@ fn exec_server_env_keeps_command_native_and_carries_sandbox_context() {
|
||||
manager: &manager,
|
||||
sandbox_cwd: &cwd_uri,
|
||||
workspace_roots: std::slice::from_ref(&cwd_uri),
|
||||
codex_linux_sandbox_exe: None,
|
||||
sandbox_exe: None,
|
||||
use_legacy_landlock: false,
|
||||
windows_sandbox_level: codex_protocol::config_types::WindowsSandboxLevel::Disabled,
|
||||
windows_sandbox_private_desktop: false,
|
||||
|
||||
Reference in new issue
Block a user