{"record":{"id":"cba88bb0b65dc185","repo":"JuliusBrussee/caveman","slug":"ssrf-destination-s-for-host-q-is-in-blocked-r-cba88b","errorCode":null,"errorMessage":"ssrf: destination %s (for host %q) is in blocked range %s","messagePattern":"ssrf: destination (.+?) \\(for host %q\\) is in blocked range (.+?)","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"critical","filePath":"shared/platform/ssrf/ssrf.go","lineNumber":336,"sourceCode":"\t\t\t// Managed mode blocks loopback absolutely — allowing tenants to\n\t\t\t// route through 127.x or ::1 would trivially reach local-only\n\t\t\t// services. Self-hosted mode opts back in only via an explicit\n\t\t\t// allowlist entry: the original host, the IP literal, or\n\t\t\t// \"localhost\" (dial time only ever sees the resolved IP).\n\t\t\tif !cfg.ManagedMode &&\n\t\t\t\t(isInAllowList(host, port, cfg.AllowList) || isInAllowList(addr.String(), port, cfg.AllowList) || isInAllowList(\"localhost\", port, cfg.AllowList)) {\n\t\t\t\treturn nil\n\t\t\t}\n\t\t\t// A fail-closed guard that does not name its own escape hatch reads\n\t\t\t// as \"unsupported\" rather than \"not opted in\" — #841 concluded the\n\t\t\t// proxy simply could not reach a local relay, when self-hosted mode\n\t\t\t// has allowed exactly that all along. Managed mode is deliberately\n\t\t\t// silent: the allowlist is a no-op there by contract, so advertising\n\t\t\t// it would send the operator after a setting that cannot help.\n\t\t\tif !cfg.ManagedMode {\n\t\t\t\treturn fmt.Errorf(\"ssrf: destination %s (for host %q) is in blocked range %s; add %s to the SSRF allowlist (CAVE_SSRF_ALLOWLIST) to permit it\", addr, host, p, allowListSuggestion(addr, port))\n\t\t\t}\n\t\t\treturn fmt.Errorf(\"ssrf: destination %s (for host %q) is in blocked range %s\", addr, host, p)\n\t\t}\n\t}\n\n\tfor _, p := range selfHostedSyntheticPrefixes {\n\t\tif p.Contains(addr) {\n\t\t\tif !cfg.ManagedMode {\n\t\t\t\treturn nil\n\t\t\t}\n\t\t\treturn fmt.Errorf(\"ssrf: destination %s (for host %q) is in blocked range %s\", addr, host, p)\n\t\t}\n\t}\n\n\tfor _, p := range blockedPrefixes {\n\t\tif p.Contains(addr) {\n\t\t\t// These ranges (link-local/metadata, ULA outside the narrow local-TUN\n\t\t\t// exception, multicast, unspecified, documentation) are absolutely\n\t\t\t// blocked — no allowlist escape in any mode.\n\t\t\treturn fmt.Errorf(\"ssrf: destination %s (for host %q) is in blocked range %s\", addr, host, p)","sourceCodeStart":318,"sourceCodeEnd":354,"githubUrl":"https://github.com/JuliusBrussee/caveman/blob/3ee70a102609e550bd2e68004bf5990a9341c851/shared/platform/ssrf/ssrf.go#L318-L354","documentation":"checkAddr matched an address in a range that cannot be opted into: either loopback in managed mode, or one of the always-blocked ranges (RFC2544 benchmarking 198.18.0.0/15 and the mihomo fake-IP IPv6 pool when in managed mode, plus link-local/metadata, ULA, multicast, documentation, carrier-NAT, etc.). Unlike the self-hosted loopback variant, no allowlist suggestion is printed because the allowlist is a no-op for these ranges by contract.","triggerScenarios":"Calling ssrf.ValidateURL / ValidateHost / ValidateURLNoResolve (or a guarded DialContext) with a destination resolving to a blocked range: loopback while ManagedMode=true; a fake-IP (198.18.x.x) DNS answer while ManagedMode=true; or an always-blocked range like 169.254.169.254, 192.0.2.x, fe80:: in any mode.","commonSituations":"Managed (prod) deployment where a dev config still points at localhost; a Clash/mihomo TUN proxy handing out fake-IP answers (198.18.0.0/15) to a managed-mode process; accidental use of documentation/example IPs (192.0.2.1, example.com docs) in real config; a metadata-SSRF attempt being correctly blocked.","solutions":["For fake-IP setups, run the process in self-hosted mode (ManagedMode=false) — those prefixes are permitted there by design","Point the endpoint at a real routable https host instead of loopback or a synthetic IP","If you hit a documentation-range address, fix the config — those IPs are placeholders, never real targets","Never allowlist your way around this: ranges covered by this message have no allowlist escape"],"exampleFix":"// before\ncfg := ssrf.ManagedConfig() // CAVE_ENV=prod\n// DNS via local mihomo TUN answers 198.18.x.x\nerr := ssrf.ValidateURL(ctx, \"https://api.provider.com\", cfg)\n\n// after\n// bypass the fake-IP proxy or run self-hosted:\ncfg := ssrf.SelfHostedConfig()\nerr := ssrf.ValidateURL(ctx, \"https://api.provider.com\", cfg)","handlingStrategy":"validation","validationCode":"ips, _ := net.LookupHost(host)\nfor _, ip := range ips {\n    if p, err := netip.ParseAddr(ip); err == nil {\n        if isLoopback(p) || isLinkLocal(p) || isDocRange(p) {\n            return fmt.Errorf(\"%s resolves to blocked %s; pick a routable endpoint\", host, ip)\n        }\n    }\n}","typeGuard":null,"tryCatchPattern":"if err := ssrf.ValidateURL(ctx, endpoint, cfg); err != nil {\n    if strings.Contains(err.Error(), \"in blocked range\") && !strings.Contains(err.Error(), \"CAVE_SSRF_ALLOWLIST\") {\n        return fmt.Errorf(\"%s is in an always-blocked range — no allowlist can permit it; change the endpoint or mode\", host(endpoint))\n    }\n    return err\n}","preventionTips":["Never allowlist-chase this message: these ranges have no opt-in by design","In managed deployments, disable fake-IP TUN proxies (198.18.0.0/15 answers will always fail)","Treat any hit on 169.254.169.254 as a potential SSRF probe and audit the URL source"],"tags":["ssrf","security","blocked-range","metadata","managed-mode"],"backgroundTag":"ssrf-blocked-range","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"}