Select process sandboxes during launch preparation (#62183)

## Why

Workspace-relative permission rules need to resolve against the execution
host's workspace roots so a grant applies to the intended directory.
Restricted launches also need to check that the host can provide the
required sandbox.

## What changed

- Select the platform sandbox while preparing a launch, using the permission
  profile, network requirements, and Windows sandbox settings.
- Pass workspace roots into policy resolution for local commands and shell
  snapshots. Already-bound command profiles validate their concrete paths
  without resolving Windows launcher hints on hosts that do not use them.
- Share local launch preparation between tool commands and shell snapshots,
  and require a platform sandbox for exec-server launches that request one.

## Testing

Cover network-only restrictions and verify that a
`:workspace_roots` write grant allows writes to the configured subdirectory
under the command's working directory while denying writes to a sibling file
and the corresponding subdirectory under the parent. Exercise the path grant
through both app-server command execution and WebSocket exec-server execution.

GitOrigin-RevId: 492fe7ab8deddf30cfd2e2bdabf28d02d67e00c5
This commit is contained in:
viyatb-oai
2026-11-18 03:59:37 +00:00
committed by copyberry
parent 9f80bb5957
commit 6ee9bc1ba7
21 changed files with 486 additions and 246 deletions
+12 -1
View File
@@ -5,6 +5,7 @@ use codex_file_system::WindowsSandboxSelection;
use codex_protocol::config_types::WindowsSandboxLevel;
use codex_sandboxing::SandboxSelection;
use codex_sandboxing::SandboxType;
use codex_sandboxing::SandboxablePreference;
pub(crate) fn validate_remote_mxc(info: &crate::EnvironmentInfo) -> std::io::Result<()> {
if !info.capabilities.windows_mxc {
@@ -30,5 +31,15 @@ pub(crate) fn sandbox_selection(
);
}
};
(SandboxSelection::RequirePlatform, level)
(
SandboxSelection::Platform {
preference: SandboxablePreference::Require,
windows_sandbox: if level == WindowsSandboxLevel::Disabled {
SandboxType::None
} else {
SandboxType::WindowsRestrictedToken
},
},
level,
)
}