Review saved exec escalations when read denials apply (#63743)

## Why

A saved command allow rule can skip review, but it cannot authorize
broader filesystem access when the sandbox enforces read denials. This
left explicit escalation requests running with baseline permissions even
when Guardian could review the request and the executor could preserve
the denials.

## What changed

Route those explicit `exec_command` escalation requests through Guardian
when auto-review is configured and the executor supports widening access
while preserving read denials. Tell Guardian that approval can broaden
filesystem access outside the denied paths and globs.

Evaluate read denials and sandbox selection using the target executor's
path conventions. A `:slash_tmp` denial applies on Linux and has no
effect on Windows.

## Testing

Cover Guardian approval and rejection for commands with saved allow
rules, plus `:slash_tmp` handling on current and legacy Linux and Windows
executors.

GitOrigin-RevId: abfe9888a1e168cfebb64e3faf12546e1f626aa2
This commit is contained in:
viyatb-oai
2026-11-24 21:27:17 +00:00
committed by copyberry
parent 20c7f26cd2
commit f22cc03b04
18 changed files with 310 additions and 94 deletions
+21
View File
@@ -44,7 +44,10 @@ use codex_sandboxing::policy_transforms::effective_permission_profile;
use codex_sandboxing::policy_transforms::merge_permission_profiles;
use codex_skills_extension::HostSkillsSnapshot;
use codex_skills_extension::SkillLoadOutcome;
use codex_utils_path_uri::LegacyAppPathString;
use codex_utils_path_uri::PathConvention;
use codex_utils_path_uri::PathUri;
use codex_utils_path_uri::Platform;
use codex_utils_plugins::PluginIdentity;
use futures::FutureExt;
use futures::future::BoxFuture;
@@ -240,6 +243,24 @@ impl TurnEnvironment {
self.config().permission_profile.permission_profile()
}
pub(crate) fn executor_path_convention(&self) -> Option<PathConvention> {
if let Some(os) = self.executor_platform_os.as_deref() {
return Platform::from_platform_os(Some(os)).path_convention();
}
// Legacy executors report their shell path. A leading // can also be POSIX.
let shell = LegacyAppPathString::from_path(&self.shell.as_ref()?.shell_path);
if shell.as_str().starts_with('/') {
return Some(PathConvention::Posix);
}
shell.infer_absolute_path_convention()
}
pub(crate) fn has_denied_reads(&self) -> bool {
self.permission_profile()
.file_system_sandbox_policy()
.has_denied_read_restrictions_for_convention(self.executor_path_convention())
}
/// Borrows this snapshot's filesystem using its permissions and any additional grants.
pub(crate) fn fs_accessor(
&self,