JuliusBrussee/caveman · error
ssrf: destination (for host ) is in blocked range ; add to…
Error message
ssrf: destination %s (for host %q) is in blocked range %s; add %s to the SSRF allowlist (CAVE_SSRF_ALLOWLIST) to permit it
What it means
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.
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
Example fix
// before
cfg := ssrf.SelfHostedConfig()
err := ssrf.ValidateURL(ctx, "http://127.0.0.1:8080/relay", cfg)
// after
cfg := ssrf.SelfHostedConfig("127.0.0.1:8080")
err := ssrf.ValidateURL(ctx, "http://127.0.0.1:8080/relay", cfg) Defensive patterns
Strategy: validation
Validate before calling
// self-hosted, intentional loopback target
if !slices.Contains(os.Args_env("CAVE_SSRF_ALLOWLIST"), "127.0.0.1:8080") {
return errors.New("local relay target requires CAVE_SSRF_ALLOWLIST=127.0.0.1:8080")
} Try / catch
if err := ssrf.ValidateURL(ctx, endpoint, cfg); err != nil {
var sug string
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") {
sug = allowlistEntryFromError(err.Error()) // error text contains the exact entry
return fmt.Errorf("add %q to CAVE_SSRF_ALLOWLIST and retry", sug)
}
return err
} Prevention
- 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
When it happens
Trigger: 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.
Common situations: 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.
Related errors
- ssrf: destination (for host ) is a private address; add to…
- awscreds: refusing plaintext container credentials endpoint…
- awscreds: refusing plaintext IMDS endpoint at host
- cave_sandbox_credential_env_not_allowlisted
- githubapp: base_url rejected by SSRF guard
AI-assisted analysis of JuliusBrussee/caveman@3ee70a1026 (2026-09-20).
Data as JSON: /api/errors/6876ee2ae707cea3.
Report an issue: GitHub.
Appendix: source
Thrown at shared/platform/ssrf/ssrf.go:334
for _, p := range loopbackPrefixes {
if p.Contains(addr) {
// 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 absolutelyView on GitHub (pinned to 3ee70a1026)