fix(sandbox): allow /dev/null and device files in workspace path guard

curl -o /dev/null -w "%{http_code}" is a common pattern for HTTP status
checks. The workspace path guard was incorrectly blocking it because
/dev/null is an absolute path outside the working directory.

Character and block device files pose no workspace-escape risk, so they
are now exempt from the outside-working-dir check (same logic as
executable binaries).

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
dj-oyu 2026-02-25 12:56:56 +09:00
parent ba2c0055f8
commit a7b2dbc0ad

View file

@ -777,6 +777,12 @@ func (t *ExecTool) guardCommand(command, cwd string) string {
if isExecutable(p) { if isExecutable(p) {
continue continue
} }
// Allow character/block device files (e.g. /dev/null used by
// "curl -o /dev/null"). These are not regular files and pose
// no workspace-escape risk.
if info, statErr := os.Stat(p); statErr == nil && info.Mode()&os.ModeDevice != 0 {
continue
}
// Agent CLI slash commands: skip non-existent paths // Agent CLI slash commands: skip non-existent paths
// (e.g., "/review" is a command, not a file). // (e.g., "/review" is a command, not a file).
if agentCLI { if agentCLI {