mirror of
https://github.com/openai/codex.git
synced 2026-11-27 15:30:27 +00:00
Restrict filesystem helper sandbox access (#38561)
## Why Filesystem helpers only need access to their own executables. Granting access to the containing directories also makes unrelated sibling files readable. ## What changed - Allow filesystem helpers to read the Codex and Linux sandbox executables directly instead of their parent directories. - Give macOS filesystem helpers a narrower Seatbelt profile that omits the normal process sandbox's `/Applications` read access. - Preserve the existing platform defaults for normal sandboxed processes. ## Testing Add unit and integration coverage for direct and symlinked sibling-file access, sandboxed copies, allowed workspace reads, and the macOS-specific Seatbelt profiles. GitOrigin-RevId: 9380c6868a695bdf2275baa74bd5e8a30a64ba1b
This commit is contained in:
1 parent
486df09a00
commit
3134ab6572
6 files changed
+245
-48
No files matched your search
@@ -11,6 +11,8 @@ use crate::policy_transforms::should_require_platform_sandbox;
|
||||
use crate::resolve_windows_elevated_filesystem_overrides;
|
||||
#[cfg(target_os = "windows")]
|
||||
use crate::resolve_windows_restricted_token_filesystem_overrides;
|
||||
#[cfg(target_os = "macos")]
|
||||
use crate::seatbelt::MacosSeatbeltProfile;
|
||||
#[cfg(target_os = "windows")]
|
||||
use crate::windows_sandbox_uses_elevated_backend;
|
||||
use codex_network_proxy::ManagedNetworkSandboxContext;
|
||||
@@ -262,11 +264,22 @@ impl std::error::Error for SandboxTransformError {
|
||||
}
|
||||
|
||||
#[derive(Default)]
|
||||
pub struct SandboxManager;
|
||||
pub struct SandboxManager {
|
||||
#[cfg(target_os = "macos")]
|
||||
seatbelt_profile: MacosSeatbeltProfile,
|
||||
}
|
||||
|
||||
impl SandboxManager {
|
||||
pub fn new() -> Self {
|
||||
Self
|
||||
Self::default()
|
||||
}
|
||||
|
||||
/// Creates a manager that applies the narrower runtime profile required by filesystem helpers.
|
||||
pub fn for_file_system_helpers() -> Self {
|
||||
Self {
|
||||
#[cfg(target_os = "macos")]
|
||||
seatbelt_profile: MacosSeatbeltProfile::FileSystemHelper,
|
||||
}
|
||||
}
|
||||
|
||||
pub fn select_initial(
|
||||
@@ -347,23 +360,26 @@ impl SandboxManager {
|
||||
SandboxType::MacosSeatbelt => {
|
||||
use crate::seatbelt::CreateSeatbeltCommandArgsParams;
|
||||
use crate::seatbelt::MACOS_PATH_TO_SEATBELT_EXECUTABLE;
|
||||
use crate::seatbelt::create_seatbelt_command_args;
|
||||
use crate::seatbelt::create_seatbelt_command_args_with_profile;
|
||||
|
||||
let pending = pending_sandboxed_request?;
|
||||
let (file_system_sandbox_policy, network_sandbox_policy) = pending
|
||||
.effective_permission_profile
|
||||
.to_runtime_permissions();
|
||||
let mut args = create_seatbelt_command_args(CreateSeatbeltCommandArgsParams {
|
||||
command: os_argv_to_strings(argv),
|
||||
file_system_sandbox_policy: &file_system_sandbox_policy,
|
||||
network_sandbox_policy,
|
||||
sandbox_policy_cwd: pending.native_sandbox_policy_cwd.as_path(),
|
||||
enforce_managed_network,
|
||||
managed_network,
|
||||
environment_id,
|
||||
network,
|
||||
extra_allow_unix_sockets: &[],
|
||||
})
|
||||
let mut args = create_seatbelt_command_args_with_profile(
|
||||
CreateSeatbeltCommandArgsParams {
|
||||
command: os_argv_to_strings(argv),
|
||||
file_system_sandbox_policy: &file_system_sandbox_policy,
|
||||
network_sandbox_policy,
|
||||
sandbox_policy_cwd: pending.native_sandbox_policy_cwd.as_path(),
|
||||
enforce_managed_network,
|
||||
managed_network,
|
||||
environment_id,
|
||||
network,
|
||||
extra_allow_unix_sockets: &[],
|
||||
},
|
||||
self.seatbelt_profile,
|
||||
)
|
||||
.map_err(SandboxTransformError::EnvironmentNetworkProxy)?;
|
||||
let mut full_command = Vec::with_capacity(1 + args.len());
|
||||
full_command.push(MACOS_PATH_TO_SEATBELT_EXECUTABLE.to_string());
|
||||
|
||||
Reference in new issue
Block a user