Centralize filesystem helper sandbox preparation (#61138)

## What changed

- Route filesystem helpers through `SandboxManager::transform`, moving helper policy preparation and Windows direct-spawn wrapping into the sandboxing crate.
- Require explicit workspace roots and an available sandbox for helper launches, restrict networking, and reject managed networking configuration.
- Share command preparation and integrity checks between helper requests and sandboxed file opens.

## Testing

Extend coverage for helper executable reads, workspace write boundaries, restricted networking, and Windows wrapper policy serialization. Verify that sandboxed writes to helper siblings leave host files unchanged.

GitOrigin-RevId: e57bfdabf47f79f2194b35df8a75051daf933465
This commit is contained in:
viyatb-oai
2026-11-12 14:47:48 +00:00
committed by copyberry
parent d3fc4a73b0
commit 6aa83e5eee
5 changed files with 398 additions and 502 deletions
@@ -1197,7 +1197,7 @@ async fn file_system_restricted_reads_require_sandbox() -> Result<()> {
#[cfg(unix)]
#[tokio::test(flavor = "multi_thread", worker_threads = 2)]
async fn sandboxed_file_operations_cannot_read_helper_siblings() -> Result<()> {
async fn sandboxed_file_operations_cannot_read_or_write_helper_siblings() -> Result<()> {
let helper_paths = crate::common::exec_server::test_codex_helper_paths()?;
let root = TempDir::new()?;
let runtime_dir = root.path().join("runtime");
@@ -1250,6 +1250,22 @@ async fn sandboxed_file_operations_cannot_read_helper_siblings() -> Result<()> {
let sibling_uri = PathUri::from_host_native_path(&sibling)?;
let destination = PathUri::from_host_native_path(workspace.join("copied.json"))?;
// Bubblewrap may create a file at this path in its private tmpfs. Check the host file,
// whether the sandbox rejected the write or isolated it.
let write_result = file_system
.write_file(
&sibling_uri,
b"replacement".to_vec(),
Default::default(),
Some(&sandbox),
)
.await;
assert_eq!(
std::fs::read(&sibling)?,
b"secret",
"sandboxed write changed host file {sibling_uri} (write returned {write_result:?})"
);
for path in [sibling, escaping_link] {
let path = PathUri::from_host_native_path(path)?;
assert!(