fix(exec): fail closed on file URI and cross-volume paths

This commit is contained in:
李龙 0668001470 2026-03-16 15:33:55 +08:00
parent bdef3e411f
commit c297a57807

View file

@ -441,6 +441,14 @@ func (t *ExecTool) guardCommand(command, cwd string) string {
continue
}
if runtime.GOOS == "windows" {
pathVolume := filepath.VolumeName(p)
cwdVolume := filepath.VolumeName(cwdPath)
if pathVolume != "" && cwdVolume != "" && !strings.EqualFold(pathVolume, cwdVolume) {
return "Command blocked by safety guard (path outside working dir)"
}
}
rel, err := filepath.Rel(cwdPath, p)
if err != nil {
continue