mirror of
https://github.com/openai/codex.git
synced 2026-11-27 23:31:09 +00:00
Review terminal input against retained permissions (#41328)
## Why An existing terminal keeps the sandbox, network settings, and grants it had at launch. Later `write_stdin` calls must account for that retained authority, including when permissions change between turns. ## What changed - Capture each terminal's effective launch permissions and compare them with the current environment before accepting non-empty input. - Request approval when the terminal bypassed the sandbox, retains additional grants, strict auto-review is active, or its sandbox or network settings differ from the current policy. - Reject input when current denied-read or environment-owned network restrictions cannot be enforced by the existing terminal, while keeping empty polls and non-TTY interrupts available without review. - Include the effective sandbox mode and user-visible additional grants in `write_stdin` approval actions without exposing host-owned grant paths. ## Testing Added unit and end-to-end coverage for retained cross-turn grants, strict auto-review, sandbox and network policy changes, denied reads, Windows sandbox backends, and private grant redaction. GitOrigin-RevId: e2d71daf9358474c885998786c4928069100711c
This commit is contained in:
1 parent
31d338a1ea
commit
5eea8d0dd3
17 files changed
+959
-61
No files matched your search
@@ -35,6 +35,8 @@ use crate::tools::sandboxing::ToolRuntime;
|
||||
use crate::tools::sandboxing::managed_network_for_sandbox_permissions;
|
||||
use crate::tools::sandboxing::sandbox_permissions_preserving_denied_reads;
|
||||
use crate::unified_exec::NoopSpawnLifecycle;
|
||||
use crate::unified_exec::TerminalPermissions;
|
||||
use crate::unified_exec::TerminalSandboxSource;
|
||||
use crate::unified_exec::UnifiedExecError;
|
||||
use crate::unified_exec::UnifiedExecProcess;
|
||||
use crate::unified_exec::UnifiedExecProcessManager;
|
||||
@@ -106,7 +108,7 @@ pub struct UnifiedExecRuntime<'a> {
|
||||
pub(crate) struct UnifiedExecAttempt {
|
||||
pub(crate) process: UnifiedExecProcess,
|
||||
pub(crate) metrics_sidecar: Option<PluginMetricsSidecar>,
|
||||
pub(crate) escalated: bool,
|
||||
pub(crate) permissions: TerminalPermissions,
|
||||
}
|
||||
|
||||
fn unified_exec_options(
|
||||
@@ -418,6 +420,22 @@ impl<'a> ToolRuntime<UnifiedExecRequest, UnifiedExecAttempt> for UnifiedExecRunt
|
||||
req.additional_permissions.as_ref(),
|
||||
sidecar_permissions.as_ref(),
|
||||
);
|
||||
let permissions = TerminalPermissions::for_launch(
|
||||
&req.turn_environment,
|
||||
&ctx.step_context.turn,
|
||||
if self.uses_executor_managed_process_sandbox(req) {
|
||||
TerminalSandboxSource::Executor
|
||||
} else {
|
||||
TerminalSandboxSource::Native
|
||||
},
|
||||
if attempt.is_escalated() {
|
||||
SandboxPermissions::RequireEscalated
|
||||
} else {
|
||||
SandboxPermissions::UseDefault
|
||||
},
|
||||
req.additional_permissions.as_ref(),
|
||||
sidecar_permissions.as_ref(),
|
||||
);
|
||||
|
||||
if let UnifiedExecShellMode::ZshFork(zsh_fork_config) = &self.shell_mode {
|
||||
let command = build_unified_exec_sandbox_command(
|
||||
@@ -477,7 +495,7 @@ impl<'a> ToolRuntime<UnifiedExecRequest, UnifiedExecAttempt> for UnifiedExecRunt
|
||||
return Ok(UnifiedExecAttempt {
|
||||
process,
|
||||
metrics_sidecar,
|
||||
escalated: attempt.is_escalated(),
|
||||
permissions,
|
||||
});
|
||||
}
|
||||
None => {
|
||||
@@ -522,7 +540,7 @@ impl<'a> ToolRuntime<UnifiedExecRequest, UnifiedExecAttempt> for UnifiedExecRunt
|
||||
Ok(UnifiedExecAttempt {
|
||||
process,
|
||||
metrics_sidecar,
|
||||
escalated: attempt.is_escalated(),
|
||||
permissions,
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user