High-performance browser automation bridge and multi-instance orchestrator with advanced stealth injection and real-time dashboard.
fix: block dangerous URL schemes in new-tab navigate, update invalid URL test
Marioc131ed606c04
diff --git a/internal/handlers/navigation.go b/internal/handlers/navigation.goindex fab7d4be..3379773d 100644--- a/internal/handlers/navigation.go+++ b/internal/handlers/navigation.go@@ -122,9 +122,14 @@ func (h *Handlers) HandleNavigate(w http.ResponseWriter, r *http.Request) {}if req.NewTab {- if parsed, err := url.Parse(req.URL); err != nil || parsed.Scheme == "" || (!strings.HasPrefix(parsed.Scheme, "http") && !strings.HasPrefix(parsed.Scheme, "chrome") && parsed.Scheme != "file" && parsed.Scheme != "data") {- web.Error(w, 400, fmt.Errorf("invalid URL: must start with http://, https://, or other valid scheme"))- return+ // Block dangerous/unsupported schemes; allow bare hostnames (e.g. "example.com")+ // which Chrome handles gracefully by prepending https://.+ if parsed, err := url.Parse(req.URL); err == nil && parsed.Scheme != "" {+ blocked := parsed.Scheme == "javascript" || parsed.Scheme == "vbscript"+ if blocked {+ web.Error(w, 400, fmt.Errorf("invalid URL scheme: %s", parsed.Scheme))+ return+ }}newTargetID, newCtx, newCtxCancel, err := h.Bridge.CreateTab(req.URL)if err != nil {diff --git a/tests/integration/navigate_test.go b/tests/integration/navigate_test.goindex a62893e2..74e20ff3 100644--- a/tests/integration/navigate_test.go+++ b/tests/integration/navigate_test.go@@ -19,11 +19,11 @@ func TestNavigate_Basic(t *testing.T) {}}-// N5: Navigate invalid URL+// N5: Navigate invalid URL (dangerous schemes must be rejected)func TestNavigate_InvalidURL(t *testing.T) {- code, _ := httpPost(t, "/navigate", map[string]string{"url": "not-a-url"})+ code, _ := httpPost(t, "/navigate", map[string]string{"url": "javascript:alert(1)"})if code == 200 {- t.Error("expected error for invalid URL")+ t.Error("expected error for javascript: scheme")}}