Skip to content

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

fix: re-validate download URL inline to satisfy ssrf analysis

Luigi Agosti6e10b0477448
diff --git a/internal/handlers/download_fallback_test.go b/internal/handlers/download_fallback_test.go
index a050c741..b5d6e412 100644
--- a/internal/handlers/download_fallback_test.go
+++ b/internal/handlers/download_fallback_test.go
@@ -195,7 +195,8 @@ func TestFetchDirectWithCookies_BlocksDNSRebinding(t *testing.T) {
if err == nil {
t.Fatal("expected rebinding attempt to be blocked")
}
- if !strings.Contains(err.Error(), "blocked remote IP") {
- t.Fatalf("expected blocked remote IP error, got %v", err)
+ msg := err.Error()
+ if !strings.Contains(msg, "blocked remote IP") && !strings.Contains(msg, "private/internal IP blocked") {
+ t.Fatalf("expected rebinding to be blocked at dial or revalidation, got %v", err)
}
}
diff --git a/internal/handlers/download_fetch.go b/internal/handlers/download_fetch.go
index 0ea74c8f..eef8ef9e 100644
--- a/internal/handlers/download_fetch.go
+++ b/internal/handlers/download_fetch.go
@@ -30,7 +30,19 @@ func (h *Handlers) fetchDirectWithCookies(ctx context.Context, browserCtx contex
slog.Debug("download fallback: failed to get browser cookies", "err", fetchErr)
}
- req, err := http.NewRequestWithContext(ctx, "GET", dlURL, nil)
+ // Inline re-validation: the caller already validated dlURL via the same
+ // validator, and the guarded client re-checks IPs at dial time and on
+ // redirects. Repeating it here is defence-in-depth and lets CodeQL see
+ // the validation in the same function as the request sink.
+ if err := validator.Validate(dlURL); err != nil {
+ return nil, "", 0, err
+ }
+ parsed, err := url.Parse(dlURL)
+ if err != nil || (parsed.Scheme != "http" && parsed.Scheme != "https") {
+ return nil, "", 0, fmt.Errorf("invalid download URL")
+ }
+
+ req, err := http.NewRequestWithContext(ctx, "GET", parsed.String(), nil)
if err != nil {
return nil, "", 0, err
}