fix: require trusted approval for sandbox override (#778)

This commit is contained in:
Kevin Codex
2026-04-20 12:01:44 +08:00
committed by GitHub
parent 7002cb302b
commit aab489055c
8 changed files with 119 additions and 57 deletions

View File

@@ -13,6 +13,7 @@ import {
type SandboxInput = {
command?: string
dangerouslyDisableSandbox?: boolean
_dangerouslyDisableSandboxApproved?: boolean
}
// NOTE: excludedCommands is a user-facing convenience feature, not a security boundary.
@@ -141,9 +142,13 @@ export function shouldUseSandbox(input: Partial<SandboxInput>): boolean {
return false
}
// Don't sandbox if explicitly overridden AND unsandboxed commands are allowed by policy
// Only trusted internal callers may request an unsandboxed command. The
// model-facing Bash schema omits _dangerouslyDisableSandboxApproved, so a
// tool_use payload cannot disable the sandbox by setting
// dangerouslyDisableSandbox directly.
if (
input.dangerouslyDisableSandbox &&
input._dangerouslyDisableSandboxApproved &&
SandboxManager.areUnsandboxedCommandsAllowed()
) {
return false