{"record":{"id":"da896c27f139b561","repo":"XTLS/Xray-core","slug":"invalid-ip-address","errorCode":null,"errorMessage":"invalid IP address","messagePattern":"invalid IP address","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"common/net/find_process_windows.go","lineNumber":87,"sourceCode":"\t}\n\tvar class int\n\tvar fn uintptr\n\tswitch network {\n\tcase \"tcp\":\n\t\tfn = getExTCPTable\n\t\tclass = tcpTablePidConn\n\tcase \"udp\":\n\t\tfn = getExUDPTable\n\t\tclass = udpTablePid\n\tdefault:\n\t\tpanic(\"Unsupported network type for process lookup.\")\n\t}\n\tip := net.ParseIP(srcIP)\n\tport := int(srcPort)\n\n\taddr, ok := netip.AddrFromSlice(ip)\n\tif !ok {\n\t\treturn 0, \"\", \"\", errors.New(\"invalid IP address\")\n\t}\n\taddr = addr.Unmap()\n\n\tfamily := windows.AF_INET\n\tif addr.Is6() {\n\t\tfamily = windows.AF_INET6\n\t}\n\n\tbuf, err := getTransportTable(fn, family, class)\n\tif err != nil {\n\t\treturn 0, \"\", \"\", err\n\t}\n\n\tnetworkType := Network_TCP\n\tif network == \"udp\" {\n\t\tnetworkType = Network_UDP\n\t}\n\tfamilyType := AddressFamilyIPv4","sourceCodeStart":69,"sourceCodeEnd":105,"githubUrl":"https://github.com/XTLS/Xray-core/blob/7d214f8b094f75322fa3990f8aadad1c912f24f5/common/net/find_process_windows.go#L69-L105","documentation":"Thrown by FindProcess on Windows when the source IP passed to the Windows process-lookup API cannot be converted to a netip.Addr. The value returned by net.ParseIP was nil or an invalid slice, so AddrFromSlice fails. This practically means the caller supplied a malformed/unparseable IP string for a connection that should be attributed to a local process.","triggerScenarios":"Calling the exported FindProcess-like API (network 'tcp' or 'udp', srcIP, srcPort) with a srcIP that net.ParseIP rejects (e.g. empty string, 'abc', '1.2.3', or a 4-in-6 slice of unexpected length). Happens on Windows only, before getTransportTable is invoked.","commonSituations":"Routing/inbound code passing an address string that was never an IP (a domain), passing an empty source IP for UDP sessions, or IPv6/zoned addresses that failed parsing upstream.","solutions":["Validate/parse the source address with net.ParseIP or netip.ParseAddr before calling the process lookup and log the raw value on failure","Ensure UDP paths that legitimately have no source IP are skipped instead of looked up","If the address is a domain, do not call FindProcess; it only works with IP literals"],"exampleFix":"// before\npid, path, _, err := proc.FindProcess(\"tcp\", srcIPString, srcPort)\n\n// after\nip := net.ParseIP(srcIPString)\nif ip == nil {\n    return errors.New(\"invalid source IP: \" + srcIPString)\n}\npid, path, _, err := proc.FindProcess(\"tcp\", srcIPString, srcPort)","handlingStrategy":"validation","validationCode":"if net.ParseIP(srcIP) == nil {\n    return fmt.Errorf(\"skip process lookup: invalid source IP %q\", srcIP)\n}","typeGuard":"func isParsableIP(s string) bool { return net.ParseIP(s) != nil }","tryCatchPattern":"if err != nil && strings.Contains(err.Error(), \"invalid IP address\") { /* skip attribution, continue */ } else if err != nil { return err }","preventionTips":["Never pass domains to process lookup","Skip lookup when srcIP is empty (common for unconnected UDP)"],"tags":["windows","network","process-lookup","validation"],"backgroundTag":null,"analyzedSha":"7d214f8b094f75322fa3990f8aadad1c912f24f5","analyzedAt":"2026-08-15T14:26:24.325Z","schemaVersion":2},"datasetVersion":"2026-08-15T17:31:12.345Z"}