High-performance browser automation bridge and multi-instance orchestrator with advanced stealth injection and real-time dashboard.
fix: simplify validation to support Docker deployments
Mario9ede3038ac9c
diff --git a/CHANGELOG.md b/CHANGELOG.mdindex c0040108..679afc91 100644--- a/CHANGELOG.md+++ b/CHANGELOG.md@@ -13,7 +13,7 @@- **Integration test stability** — Added retry logic, increased timeouts, and better error reporting for flaky tests (#50)### Security-- **SSRF Prevention** — Added input validation to prevent Server-Side Request Forgery in orchestrator health checks. Validates port format and restricts connections to localhost only (#50)+- **Input Validation** — Added port validation to prevent invalid input in orchestrator health checks. Validates port format and range (1-65535) (#50)### Docs- **Definition of Done** — Added DEFINITION_OF_DONE.md and GitHub PR template with streamlined, actionable checklist (PR #48)diff --git a/internal/orchestrator/health.go b/internal/orchestrator/health.goindex 5b71b27b..afaab360 100644--- a/internal/orchestrator/health.go+++ b/internal/orchestrator/health.go@@ -36,7 +36,9 @@ func (o *Orchestrator) monitor(inst *InstanceInternal) {time.Sleep(instanceHealthPollInterval)for _, baseURL := range instanceBaseURLs(inst.Port) {- // Validate URL components to prevent SSRF+ // Note: We validate port format but not host restrictions to support+ // Docker deployments where instances run in different containers.+ // The orchestrator only checks instances it manages.req, reqErr := http.NewRequest(http.MethodGet, baseURL+"/health", nil)if reqErr != nil {lastProbe = fmt.Sprintf("%s -> %s", baseURL, reqErr.Error())diff --git a/internal/orchestrator/validation.go b/internal/orchestrator/validation.goindex 5fc009ef..8ce01c6c 100644--- a/internal/orchestrator/validation.go+++ b/internal/orchestrator/validation.go@@ -2,11 +2,10 @@ package orchestratorimport ("fmt"- "net""strconv")-// ValidatePort ensures the port is valid and safe to use+// ValidatePort ensures the port is valid format and rangefunc ValidatePort(port string) error {if port == "" {return fmt.Errorf("port cannot be empty")@@ -18,36 +17,10 @@ func ValidatePort(port string) error {return fmt.Errorf("invalid port number: %s", port)}- // Check valid port range - allow all valid TCP ports- // Pinchtab instances can run on any available port+ // Check valid port rangeif portNum < 1 || portNum > 65535 {return fmt.Errorf("port must be between 1 and 65535")}return nil}--// ValidateHost ensures only localhost connections are allowed-func ValidateHost(host string) error {- // Only allow localhost connections- allowedHosts := []string{- "localhost",- "127.0.0.1",- "[::1]",- "::1",- }-- for _, allowed := range allowedHosts {- if host == allowed {- return nil- }- }-- // Also check if it's a loopback IP- ip := net.ParseIP(host)- if ip != nil && ip.IsLoopback() {- return nil- }-- return fmt.Errorf("only localhost connections are allowed")-}diff --git a/internal/orchestrator/validation_test.go b/internal/orchestrator/validation_test.goindex c2664f13..e7a1d9e2 100644--- a/internal/orchestrator/validation_test.go+++ b/internal/orchestrator/validation_test.go@@ -13,11 +13,12 @@ func TestValidatePort(t *testing.T) {{"valid port", "8080", false},{"valid high port", "65000", false},{"valid pinchtab port", "9867", false},- {"mysql port allowed", "3306", false},- {"redis port allowed", "6379", false},+ {"port 80", "80", false},+ {"port 443", "443", false},{"empty port", "", true},{"non-numeric", "abc", true},- {"too low", "0", true},+ {"negative", "-1", true},+ {"zero", "0", true},{"too high", "70000", true},}@@ -30,29 +31,3 @@ func TestValidatePort(t *testing.T) {})}}--func TestValidateHost(t *testing.T) {- tests := []struct {- name string- host string- wantErr bool- }{- {"localhost", "localhost", false},- {"ipv4 loopback", "127.0.0.1", false},- {"ipv6 loopback bracket", "[::1]", false},- {"ipv6 loopback", "::1", false},- {"other loopback", "127.0.0.2", false},- {"external ip", "192.168.1.1", true},- {"domain", "example.com", true},- {"public ip", "8.8.8.8", true},- }-- for _, tt := range tests {- t.Run(tt.name, func(t *testing.T) {- err := ValidateHost(tt.host)- if (err != nil) != tt.wantErr {- t.Errorf("ValidateHost(%q) error = %v, wantErr %v", tt.host, err, tt.wantErr)- }- })- }-}