JuliusBrussee/caveman · error
ssrf: destination (for host ) is a private address blocked…
Error message
ssrf: destination %s (for host %q) is a private address blocked in managed mode
What it means
checkAddr resolved the destination into an RFC1918 private address (10/8, 172.16/12, 192.168/16) while the library is running in managed mode (ManagedMode mirrors CAVE_ENV=prod). In managed mode private destinations are always blocked — the allowlist is ignored — to prevent a compromised/buggy service from pivoting into the internal network.
Solutions
- Route the call through an approved public endpoint or egress proxy instead of the private address.
- If this is genuinely a self-hosted deployment, run with CAVE_ENV unset/not prod so ManagedMode=false, and add the destination to CAVE_SSRF_ALLOWLIST.
- Move the dependency to a publicly reachable address or a gateway that the SSRF policy permits.
- Verify which mode you are in: ManagedMode is derived from CAVE_ENV; check the deployment env.
Example fix
// before (prod, managed mode — always fails) CAVE_ENV=prod ... http://10.0.0.5:8080/api // after: go through the public gateway CAVE_ENV=prod ... https://api.internal-gw.example.com/api
Defensive patterns
Strategy: validation
Validate before calling
if inRFC1918(addr) && managedMode {
return fmt.Errorf("private destination %s unreachable in managed mode; use a public endpoint", addr)
} Type guard
func isRFC1918(a netip.Addr) bool {
a = a.Unmap()
return a.Is4() && (netip.MustParsePrefix("10.0.0.0/8").Contains(a) ||
netip.MustParsePrefix("172.16.0.0/12").Contains(a) ||
netip.MustParsePrefix("192.168.0.0/16").Contains(a))
} Try / catch
if err := callEndpoint(cfgURL); err != nil {
if strings.Contains(err.Error(), "blocked in managed mode") {
return fmt.Errorf("config points at a private address; deploy a public gateway URL: %w", err)
}
return err
} Prevention
- Keep per-environment endpoint config: public URLs for prod (CAVE_ENV=prod), private IPs only for self-hosted dev.
- Never hardcode 10.x/192.168.x hosts in code that runs in managed environments.
- Test prod-mode config in CI with ManagedMode=true to catch private endpoints early.
When it happens
Trigger: ValidateURLNoResolve/validateHostPort resolved a hostname (or was given an IP literal) inside 10.0.0.0/8, 172.16.0.0/12, or 192.168.0.0/16 while ManagedMode=true, e.g. calling http://localhost:8080 or http://10.0.0.5 from a production (CAVE_ENV=prod) deployment.
Common situations: Code that works locally (self-hosted dev) suddenly fails in production because CAVE_ENV=prod flips managed mode on; pointing a webhook/fetch at an internal service hostname; staging configs copied from dev that reference private IPs.
Understand the failure class
Background: "Invalid value" and "allowed values are" config errors: what your library rejected and how to fix it — this error's family across 41 libraries.
Related errors
- ssrf: destination (for host ) is a private address; add to…
- ssrf: destination (for host ) is in blocked range
- awscreds: refusing plaintext container credentials endpoint…
- awscreds: refusing plaintext IMDS endpoint at host
- githubapp: base_url rejected by SSRF guard
AI-assisted analysis of JuliusBrussee/caveman@3ee70a1026 (2026-09-20).
Data as JSON: /api/errors/c0a70ca672bb5cd5.
Report an issue: GitHub.
Appendix: source
Thrown at shared/platform/ssrf/ssrf.go:360
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)
}
}
if inRFC1918(addr) {
if cfg.ManagedMode {
return fmt.Errorf("ssrf: destination %s (for host %q) is a private address blocked in managed mode", addr, host)
}
// In self-hosted mode, RFC1918 is blocked unless the original hostname
// OR the resolved IP literal appears in the allowlist.
if !isInAllowList(host, port, cfg.AllowList) && !isInAllowList(addr.String(), port, cfg.AllowList) {
return fmt.Errorf("ssrf: destination %s (for host %q) is a private address; add %s to the SSRF allowlist (CAVE_SSRF_ALLOWLIST) to permit it", addr, host, allowListSuggestion(addr, port))
}
}
return nil
}
// allowListSuggestion renders the allowlist entry to advise for a blocked
// destination. It must be an entry isInAllowList would actually accept at BOTH
// stages: ValidateHost pre-flights with an empty port, so JoinHostPort would
// emit a trailing-colon token like "127.0.0.1:" that matches only the
// port-less stage — an operator following that advice literally relaxes the
// pre-flight guard, is blocked again at dial time by a second message naming a
// different token, and leaves a stale weakening entry behind. The bare address
// form is the one entry that matches every stage.View on GitHub (pinned to 3ee70a1026)