From 575d5d1ffcee90b098cb9a6b0d2060f711e8e6c2 Mon Sep 17 00:00:00 2001 From: dj-oyu <68707227+dj-oyu@users.noreply.github.com> Date: Wed, 25 Feb 2026 12:57:21 +0900 Subject: [PATCH] fix(sandbox): allow /dev/* paths in workspace guard (not just device files) /dev/null, /dev/urandom etc. are useful system resources that pose no workspace-escape risk. Replacing the os.ModeDevice stat check with a simple /dev/ prefix match is simpler and more general. Co-Authored-By: Claude Sonnet 4.6 --- pkg/tools/shell.go | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/pkg/tools/shell.go b/pkg/tools/shell.go index 1cdf17672..4aced8b45 100644 --- a/pkg/tools/shell.go +++ b/pkg/tools/shell.go @@ -777,10 +777,10 @@ func (t *ExecTool) guardCommand(command, cwd string) string { if isExecutable(p) { continue } - // Allow character/block device files (e.g. /dev/null used by - // "curl -o /dev/null"). These are not regular files and pose + // Allow /dev/* paths (e.g. /dev/null, /dev/urandom). + // Device files are not regular filesystem paths and pose // no workspace-escape risk. - if info, statErr := os.Stat(p); statErr == nil && info.Mode()&os.ModeDevice != 0 { + if strings.HasPrefix(p, "/dev/") { continue } // Agent CLI slash commands: skip non-existent paths