Harden Windows sandbox provisioning file handling (#42342)

## Why

Windows sandbox provisioning performs privileged work beneath a requested Codex home. Provisioning paths and output entries must remain bound to the files and directories that were validated, without following reparse points or writing through caller-controlled hard links.

## What changed

- Add reusable no-reparse directory opens, path validation, directory guards, and handle-relative atomic file replacement.
- Use fresh or retained handles for provisioning logs, sandbox credentials, setup markers, and error reports in service provisioning mode.
- Add service-side validation for framed provisioning requests, proxy settings, fixed-drive Codex homes, and pinned sandbox directories.

## Testing

Add Windows tests covering junction and unsafe-path rejection, hard-link-safe output replacement, retained output handles, request framing and normalization, and ancestor pinning.

GitOrigin-RevId: 2ec4f0d15404c3387df1414bb0c1915cf452ecf2
This commit is contained in:
johnl-oai authored and copyberry committed 2026-09-02 20:03:43 +00:00
1 parent 501931b399
commit add870a4bf
16 files changed
+1210 -243

No files matched your search

+16
View File
@@ -69,6 +69,8 @@ mod dpapi;
#[cfg(target_os = "windows")]
mod env;
#[cfg(target_os = "windows")]
mod file_write;
#[cfg(target_os = "windows")]
mod framed_io;
#[cfg(target_os = "windows")]
mod helper_materialization;
@@ -79,6 +81,8 @@ mod identity;
#[cfg(target_os = "windows")]
mod logging;
#[cfg(target_os = "windows")]
mod no_reparse_dir;
#[cfg(target_os = "windows")]
mod path_normalization;
#[cfg(target_os = "windows")]
mod process;
@@ -195,6 +199,8 @@ pub use elevated_impl::ElevatedSandboxProfileCaptureRequest;
#[cfg(target_os = "windows")]
pub use elevated_impl::run_windows_sandbox_capture_for_permission_profile as run_windows_sandbox_capture_for_permission_profile_elevated;
#[cfg(target_os = "windows")]
pub use file_write::write_file_atomically;
#[cfg(target_os = "windows")]
pub use helper_materialization::resolve_current_exe_for_launch;
#[cfg(target_os = "windows")]
pub use helper_materialization::resolve_exe_for_launch;
@@ -249,6 +255,16 @@ pub use logging::log_note;
#[cfg(target_os = "windows")]
pub use logging::log_writer;
#[cfg(target_os = "windows")]
pub use logging::setup_log_writer;
#[cfg(target_os = "windows")]
pub use no_reparse_dir::DirectoryOpenDisposition;
#[cfg(target_os = "windows")]
pub use no_reparse_dir::create_directory_guard;
#[cfg(target_os = "windows")]
pub use no_reparse_dir::open_directory_no_reparse;
#[cfg(target_os = "windows")]
pub use no_reparse_dir::validate_local_directory_path;
#[cfg(target_os = "windows")]
pub use path_normalization::canonicalize_path;
#[cfg(target_os = "windows")]
pub use process::ConsoleMode;