SsrfBlockingDns

object SsrfBlockingDns : Dns

An OkHttp Dns that refuses to resolve any host mapping to an internal address (loopback, private, link-local, cloud-metadata, IPv6-ULA — see PrivateNetworkGuard).

Because OkHttp resolves DNS for the initial request AND every redirect hop through this Dns, installing it on a client blocks SSRF to internal endpoints across redirects, and OkHttp connects only to the addresses returned here (closing the resolve-then-connect TOCTOU). If ANY resolved address is disallowed the whole host is refused, so a multi-record host cannot smuggle one internal address past the guard.

Functions

Link copied to clipboard
open override fun lookup(hostname: String): List<InetAddress>