mirror of
https://github.com/openai/codex.git
synced 2026-11-15 21:50:46 +00:00
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:
@@ -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!(
|
||||
|
||||
Reference in New Issue
Block a user