A hostname verifier accepts every host, so a certificate for any name passes
What it finds
HostnameVerifier { _, _ -> true } or override fun verify(...) = true accepts a valid certificate issued for any other host, which lets an attacker with any certificate impersonate the server.
From the rule's source, permissive_hostname_verifier.rs.
import javax.net.ssl.HostnameVerifierimport javax.net.ssl.SSLSession val any = HostnameVerifier { _, _ -> true }tx0 reports: the hostname verifier accepts every hostval checked = HostnameVerifier { host, _ -> host == "example.org" } class AnyHost : HostnameVerifier { override fun verify(hostname: String, session: SSLSession): Boolean = truetx0 reports: the hostname verifier accepts every host} fun client(builder: OkHttpClient.Builder) = builder.hostnameVerifier { _, _ -> true }tx0 reports: the hostname verifier accepts every host Turn it on, off or suppress it
The rule runs in every tier. To turn it off for a project, set its level in tx0.toml:
[rules]
"tx0/kotlin:accept-any-hostname" = "off"To keep one finding, suppress it with a reason. tx0 suppress ID --reason "..." writes the comment on the line before the code:
// tx0: ignore[tx0/kotlin:accept-any-hostname] reason="..."tx0 explain tx0/kotlin:accept-any-hostname shows the same in the terminal. Found a false positive? Report it.