Skip to content

High-performance browser automation bridge and multi-instance orchestrator with advanced stealth injection and real-time dashboard.

fix: add filepath.Rel check to SafePath for static analysis compliance

Data59422502c9a8
diff --git a/internal/web/safepath.go b/internal/web/safepath.go
index 6dfc608c..14002c22 100644
--- a/internal/web/safepath.go
+++ b/internal/web/safepath.go
@@ -47,5 +47,12 @@ func SafePath(base, userPath string) (string, error) {
return "", fmt.Errorf("path %q escapes base directory %q", userPath, absBase)
}
+ // Double-check via filepath.Rel — this also serves as an explicit sanitizer
+ // recognized by static analysis tools (e.g. CodeQL go/path-injection).
+ rel, err := filepath.Rel(absBase, resolved)
+ if err != nil || strings.HasPrefix(rel, "..") {
+ return "", fmt.Errorf("path %q escapes base directory %q", userPath, absBase)
+ }
+
return resolved, nil
}