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 <noreply@anthropic.com>
This commit is contained in:
parent
a7b2dbc0ad
commit
25e614abe2
1 changed files with 3 additions and 3 deletions
|
|
@ -777,10 +777,10 @@ 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
|
// Allow /dev/* paths (e.g. /dev/null, /dev/urandom).
|
||||||
// "curl -o /dev/null"). These are not regular files and pose
|
// Device files are not regular filesystem paths and pose
|
||||||
// no workspace-escape risk.
|
// no workspace-escape risk.
|
||||||
if info, statErr := os.Stat(p); statErr == nil && info.Mode()&os.ModeDevice != 0 {
|
if strings.HasPrefix(p, "/dev/") {
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
// Agent CLI slash commands: skip non-existent paths
|
// Agent CLI slash commands: skip non-existent paths
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue