From badb1beb36af9f44de80969e4ce4c616dc9b59db Mon Sep 17 00:00:00 2001 From: viyatb-oai Date: Mon, 13 Apr 2026 22:41:34 -0700 Subject: [PATCH] fix(linux-sandbox): mask fragile bwrap carveout paths Co-authored-by: Codex noreply@openai.com --- codex-rs/linux-sandbox/src/bwrap.rs | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/codex-rs/linux-sandbox/src/bwrap.rs b/codex-rs/linux-sandbox/src/bwrap.rs index ddba87d6f4..96d1cf94b7 100644 --- a/codex-rs/linux-sandbox/src/bwrap.rs +++ b/codex-rs/linux-sandbox/src/bwrap.rs @@ -543,6 +543,10 @@ fn append_read_only_subpath_args( } if is_within_allowed_write_paths(subpath, allowed_write_paths) { + if fs::canonicalize(subpath).is_err() { + append_bwrap_mount_point_read_only_bind_args(args, cleanup_mount_points, subpath); + return; + } args.push("--ro-bind".to_string()); args.push(path_to_string(subpath)); args.push(path_to_string(subpath)); @@ -1156,9 +1160,10 @@ mod tests { ]); let args = create_filesystem_args(&policy, temp_dir.path()).expect("filesystem args"); - assert_eq!( - args.cleanup_mount_points, - vec![first_missing_component.clone()] + assert!( + args.cleanup_mount_points.contains(&first_missing_component), + "missing protected subtree should be registered for cleanup: {:#?}", + args.cleanup_mount_points ); let first_missing_component = path_to_string(&first_missing_component); let protected_path = path_to_string(&protected_path);