{"record":{"id":"05e41e8b00d2e231","repo":"JuliusBrussee/caveman","slug":"ssrf-host-q-resolved-to-no-addresses","errorCode":null,"errorMessage":"ssrf: host %q resolved to no addresses","messagePattern":"ssrf: host %q resolved to no addresses","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"shared/platform/ssrf/ssrf.go","lineNumber":272,"sourceCode":"\t}\n\n\t// \"localhost\" is explicitly blocked regardless of what DNS says — unless a\n\t// self-hosted operator allowlisted it (resolution still runs, so every\n\t// resolved address is range-checked below like any other).\n\tif strings.EqualFold(host, \"localhost\") && !(!cfg.ManagedMode && isInAllowList(host, port, cfg.AllowList)) {\n\t\treturn fmt.Errorf(\"ssrf: host %q is blocked (loopback)\", host)\n\t}\n\n\t// Resolve ALL addresses the hostname currently maps to.  A hostname that\n\t// returns even one blocked address is rejected (defense-in-depth against\n\t// split-horizon / DNS rebinding scenarios where the pre-flight check and\n\t// the dial see different answers).\n\taddrs, err := net.DefaultResolver.LookupIPAddr(ctx, host)\n\tif err != nil {\n\t\treturn fmt.Errorf(\"ssrf: DNS resolution failed for %q: %w\", host, err)\n\t}\n\tif len(addrs) == 0 {\n\t\treturn fmt.Errorf(\"ssrf: host %q resolved to no addresses\", host)\n\t}\n\n\tfor _, ia := range addrs {\n\t\ta, ok := netip.AddrFromSlice(ia.IP)\n\t\tif !ok {\n\t\t\treturn fmt.Errorf(\"ssrf: could not parse resolved IP %v for host %q\", ia.IP, host)\n\t\t}\n\t\ta = a.Unmap() // normalise ::ffff:x.x.x.x → x.x.x.x\n\t\tif err := checkAddr(a, host, port, cfg); err != nil {\n\t\t\treturn err\n\t\t}\n\t}\n\treturn nil\n}\n\n// validateHostInput rejects URL/userinfo-shaped values before they reach DNS\n// or an error formatter. IP literals (including zoned IPv6) are handled by\n// netip.ParseAddr and may contain colons or a zone identifier.","sourceCodeStart":254,"sourceCodeEnd":290,"githubUrl":"https://github.com/JuliusBrussee/caveman/blob/3ee70a102609e550bd2e68004bf5990a9341c851/shared/platform/ssrf/ssrf.go#L254-L290","documentation":"After a successful LookupIPAddr the library expects at least one address. Some resolver stacks can return success with an empty answer; since the guard must range-check every resolved IP, an empty result is treated as an unreached destination and rejected.","triggerScenarios":"Calling ssrf.ValidateURL / ValidateHost with a hostname whose DNS record was just deleted or whose resolver returns an empty A/AAAA answer set (e.g. a round-robin entry drained to zero, or a resolver that swallows errors into empty replies).","commonSituations":"A service's DNS record removed during a decommission while clients still reference it; a load-balancer DNS name with all backends deregistered; misconfigured DNS zone with an empty answer; stale local resolver cache returning an empty response.","solutions":["Verify the hostname actually has A/AAAA records (dig A host, dig AAAA host) and re-create them if drained","Point configuration at a hostname that resolves (or an IP literal, which skips DNS entirely)","Flush/fix the local resolver if a stale empty answer is cached","If the target was intentionally removed, update the client's configured endpoint"],"exampleFix":"// before\nerr := ssrf.ValidateHost(ctx, \"retired-service.internal\", cfg) // record removed\n\n// after\nerr := ssrf.ValidateHost(ctx, \"active-service.internal\", cfg)","handlingStrategy":"validation","validationCode":"addrs, err := net.LookupHost(host)\nif err != nil || len(addrs) == 0 {\n    return fmt.Errorf(\"%s has no DNS records; fix configuration or DNS zone\", host)\n}","typeGuard":null,"tryCatchPattern":"if err := ssrf.ValidateURL(ctx, endpoint, cfg); err != nil {\n    if strings.Contains(err.Error(), \"resolved to no addresses\") {\n        return fmt.Errorf(\"DNS for %s returned no records; verify the host still exists\", host(endpoint))\n    }\n    return err\n}","preventionTips":["Monitor DNS records of configured dependencies (empty answers usually mean decommissioning)","Configure endpoints by stable hostname with existing A/AAAA records, not names you plan to drain","Cross-check `dig +short` output before promoting an endpoint"],"tags":["ssrf","dns","empty-result","resolution"],"backgroundTag":"empty-result-set","analyzedSha":"3ee70a102609e550bd2e68004bf5990a9341c851","analyzedAt":"2026-09-20T15:53:39.229Z","contentChangedAt":"2026-09-20T15:53:39.229Z","schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}