{"record":{"id":"6876ee2ae707cea3","repo":"JuliusBrussee/caveman","slug":"ssrf-destination-s-for-host-q-is-in-blocked-r","errorCode":null,"errorMessage":"ssrf: destination %s (for host %q) is in blocked range %s; add %s to the SSRF allowlist (CAVE_SSRF_ALLOWLIST) to permit it","messagePattern":"ssrf: destination (.+?) \\(for host %q\\) is in blocked range (.+?); add (.+?) to the SSRF allowlist \\(CAVE_SSRF_ALLOWLIST\\) to permit it","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"shared/platform/ssrf/ssrf.go","lineNumber":334,"sourceCode":"\tfor _, p := range loopbackPrefixes {\n\t\tif p.Contains(addr) {\n\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","sourceCodeStart":316,"sourceCodeEnd":352,"githubUrl":"https://github.com/JuliusBrussee/caveman/blob/3ee70a102609e550bd2e68004bf5990a9341c851/shared/platform/ssrf/ssrf.go#L316-L352","documentation":"checkAddr matched the resolved (or literal) address against a loopback range (127.0.0.0/8 or ::1/128). In self-hosted (non-managed) mode the library refuses but tells you the escape hatch: add the suggested address entry to the SSRF allowlist (CAVE_SSRF_ALLOWLIST / Config.AllowList). Managed mode never produces this variant — it blocks silently at the sibling message.","triggerScenarios":"Calling ssrf.ValidateURL / ValidateHost / ValidateURLNoResolve (or a guarded dial) where the destination resolves to 127.x.x.x or ::1, cfg.ManagedMode is false, and neither the hostname, the resolved IP, nor \"localhost\" is in the allowlist with a matching port.","commonSituations":"Self-hosted operator pointing the client at a local relay/model server (Ollama, LM Studio) on loopback without having set CAVE_SSRF_ALLOWLIST; an allowlist entry with the wrong port so isInAllowList misses; allowlist given as host name while dial time sees the resolved IP.","solutions":["Add the exact address from the error message to CAVE_SSRF_ALLOWLIST (or ssrf.SelfHostedConfig(entries...)) — the error text contains the ready-to-use entry","Ensure the allowlist entry includes the port if you dial a non-default port (entry must be \"ip:port\" or the bare address form shown in the message)","For loopback, the entry \"localhost\" covers 127.0.0.0/8 and ::1 at dial time","Remember the allowlist only works when ManagedMode is false; verify CAVE_ENV wiring"],"exampleFix":"// before\ncfg := ssrf.SelfHostedConfig()\nerr := ssrf.ValidateURL(ctx, \"http://127.0.0.1:8080/relay\", cfg)\n\n// after\ncfg := ssrf.SelfHostedConfig(\"127.0.0.1:8080\")\nerr := ssrf.ValidateURL(ctx, \"http://127.0.0.1:8080/relay\", cfg)","handlingStrategy":"validation","validationCode":"// self-hosted, intentional loopback target\nif !slices.Contains(os.Args_env(\"CAVE_SSRF_ALLOWLIST\"), \"127.0.0.1:8080\") {\n    return errors.New(\"local relay target requires CAVE_SSRF_ALLOWLIST=127.0.0.1:8080\")\n}","typeGuard":null,"tryCatchPattern":"if err := ssrf.ValidateURL(ctx, endpoint, cfg); err != nil {\n    var sug string\n    if _, parseErr := fmt.Sscanf(err.Error(), \"ssrf: destination %s (for host %s) is in blocked range\", new(string), new(string)); parseErr == nil && strings.Contains(err.Error(), \"CAVE_SSRF_ALLOWLIST\") {\n        sug = allowlistEntryFromError(err.Error()) // error text contains the exact entry\n        return fmt.Errorf(\"add %q to CAVE_SSRF_ALLOWLIST and retry\", sug)\n    }\n    return err\n}","preventionTips":["Copy the allowlist entry exactly as printed in the error message — it is stage-safe (matches pre-flight and dial time)","Include the port in the entry when dialing a non-default port","Verify ManagedMode is false; the allowlist is ignored in managed mode"],"tags":["ssrf","security","loopback","allowlist","self-hosted"],"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"}