JuliusBrussee/caveman · critical

ssrf: destination (for host ) is in blocked range

Error message

ssrf: destination %s (for host %q) is in blocked range %s

What it means

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.

Solutions

  1. For fake-IP setups, run the process in self-hosted mode (ManagedMode=false) — those prefixes are permitted there by design
  2. Point the endpoint at a real routable https host instead of loopback or a synthetic IP
  3. If you hit a documentation-range address, fix the config — those IPs are placeholders, never real targets
  4. Never allowlist your way around this: ranges covered by this message have no allowlist escape

Example fix

// before
cfg := ssrf.ManagedConfig() // CAVE_ENV=prod
// DNS via local mihomo TUN answers 198.18.x.x
err := ssrf.ValidateURL(ctx, "https://api.provider.com", cfg)

// after
// bypass the fake-IP proxy or run self-hosted:
cfg := ssrf.SelfHostedConfig()
err := ssrf.ValidateURL(ctx, "https://api.provider.com", cfg)
Defensive patterns

Strategy: validation

Validate before calling

ips, _ := net.LookupHost(host)
for _, ip := range ips {
    if p, err := netip.ParseAddr(ip); err == nil {
        if isLoopback(p) || isLinkLocal(p) || isDocRange(p) {
            return fmt.Errorf("%s resolves to blocked %s; pick a routable endpoint", host, ip)
        }
    }
}

Try / catch

if err := ssrf.ValidateURL(ctx, endpoint, cfg); err != nil {
    if strings.Contains(err.Error(), "in blocked range") && !strings.Contains(err.Error(), "CAVE_SSRF_ALLOWLIST") {
        return fmt.Errorf("%s is in an always-blocked range — no allowlist can permit it; change the endpoint or mode", host(endpoint))
    }
    return err
}

Prevention

When it happens

Trigger: 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.

Common situations: 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.

Related errors


AI-assisted analysis of JuliusBrussee/caveman@3ee70a1026 (2026-09-20). Data as JSON: /api/errors/cba88bb0b65dc185. Report an issue: GitHub.

Appendix: source

Thrown at shared/platform/ssrf/ssrf.go:336

			// Managed mode blocks loopback absolutely — allowing tenants to
			// route through 127.x or ::1 would trivially reach local-only
			// services. Self-hosted mode opts back in only via an explicit
			// allowlist entry: the original host, the IP literal, or
			// "localhost" (dial time only ever sees the resolved IP).
			if !cfg.ManagedMode &&
				(isInAllowList(host, port, cfg.AllowList) || isInAllowList(addr.String(), port, cfg.AllowList) || isInAllowList("localhost", port, cfg.AllowList)) {
				return nil
			}
			// A fail-closed guard that does not name its own escape hatch reads
			// as "unsupported" rather than "not opted in" — #841 concluded the
			// proxy simply could not reach a local relay, when self-hosted mode
			// has allowed exactly that all along. Managed mode is deliberately
			// silent: the allowlist is a no-op there by contract, so advertising
			// it would send the operator after a setting that cannot help.
			if !cfg.ManagedMode {
				return 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))
			}
			return fmt.Errorf("ssrf: destination %s (for host %q) is in blocked range %s", addr, host, p)
		}
	}

	for _, p := range selfHostedSyntheticPrefixes {
		if p.Contains(addr) {
			if !cfg.ManagedMode {
				return nil
			}
			return fmt.Errorf("ssrf: destination %s (for host %q) is in blocked range %s", addr, host, p)
		}
	}

	for _, p := range blockedPrefixes {
		if p.Contains(addr) {
			// These ranges (link-local/metadata, ULA outside the narrow local-TUN
			// exception, multicast, unspecified, documentation) are absolutely
			// blocked — no allowlist escape in any mode.
			return fmt.Errorf("ssrf: destination %s (for host %q) is in blocked range %s", addr, host, p)

View on GitHub (pinned to 3ee70a1026)