{"record":{"id":"40c544858d36a8fe","repo":"larksuite/cli","slug":"invalid-remote-ip","errorCode":null,"errorMessage":"invalid remote IP","messagePattern":"invalid remote IP","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"internal/validate/url.go","lineNumber":561,"sourceCode":"\t\terr,\n\t).WithCause(err)\n}\n\nfunc validateConnRemoteIP(conn net.Conn) error {\n\tif conn == nil {\n\t\treturn fmt.Errorf(\"nil connection\")\n\t}\n\traddr := conn.RemoteAddr()\n\tif raddr == nil {\n\t\treturn fmt.Errorf(\"missing remote address\")\n\t}\n\thost, _, err := net.SplitHostPort(raddr.String())\n\tif err != nil {\n\t\thost = raddr.String()\n\t}\n\tip := net.ParseIP(strings.Trim(host, \"[]\"))\n\tif ip == nil {\n\t\treturn fmt.Errorf(\"invalid remote IP\")\n\t}\n\tif isRestrictedDownloadIP(ip) {\n\t\treturn fmt.Errorf(\"local/internal host is not allowed\")\n\t}\n\treturn nil\n}\n","sourceCodeStart":543,"sourceCodeEnd":568,"githubUrl":"https://github.com/larksuite/cli/blob/7fd6ef3c07182257ce776cdc5a614e122d5bd4b3/internal/validate/url.go#L543-L568","documentation":"validateConnRemoteIP parses the host portion of the connection's remote address string with net.ParseIP. This error means the address string could not be parsed as an IP (even after trimming IPv6 brackets and tolerating a failed SplitHostPort), so the SSRF restriction check cannot be performed. The connection is rejected rather than trusted.","triggerScenarios":"RemoteAddr().String() yields something non-IP-shaped, e.g. a custom Addr whose String() returns a name or opaque token instead of host:port with an IP literal.","commonSituations":"Custom net.Addr implementations on wrapped connections; connections over unusual network types (unix pipes misused in an HTTP client); test fakes returning human-readable addresses.","solutions":["Ensure the connection's RemoteAddr is a standard *net.TCPAddr/*net.UDPAddr whose String() contains an IP","Fix custom Addr types to report an IP-based address","If a wrapper reformats the address, keep the IP literal in String() output"],"exampleFix":"// before\nfunc (a pipeAddr) String() string { return \"local-pipe\" }\n// after\nfunc (a pipeAddr) String() string { return a.ip.String() }","handlingStrategy":"type-guard","validationCode":"raddr := conn.RemoteAddr()\nif tcp, ok := raddr.(*net.TCPAddr); !ok || tcp.IP == nil {\n    return errors.New(\"remote address is not an IP-based TCP address\")\n}","typeGuard":"func remoteIP(conn net.Conn) net.IP {\n    if tcp, ok := conn.RemoteAddr().(*net.TCPAddr); ok {\n        return tcp.IP\n    }\n    return nil\n}","tryCatchPattern":"if err != nil && strings.Contains(err.Error(), \"invalid remote IP\") {\n    return fmt.Errorf(\"connection peer has no IP address; check custom Addr implementations: %w\", err)\n}","preventionTips":["Keep RemoteAddr types as *net.TCPAddr/*net.UDPAddr on download connections","If wrapping Addr types, preserve the IP literal in String()","Do not route HTTP downloads over address types without IPs (unix sockets, named pipes)"],"tags":["network","ssrf","ip","validation"],"backgroundTag":"invalid-remote-ip","analyzedSha":"7fd6ef3c07182257ce776cdc5a614e122d5bd4b3","analyzedAt":"2026-09-04T21:17:44.649Z","contentChangedAt":"2026-09-04T21:17:44.649Z","schemaVersion":2},"datasetVersion":"2026-09-12T02:17:10.037Z"}