A TLS configuration turns off the verification of the server's certificate
What it finds
tls.Config{InsecureSkipVerify: true}: the client accepts any certificate for any name, so anyone on the path can impersonate the server and read or change the traffic, and the encryption protects nothing. A test server's certificate can be trusted by adding it to RootCAs, and a custom check belongs in VerifyPeerCertificate or VerifyConnection.
Reported are InsecureSkipVerify: true in a composite literal and an assignment of true to a field InsecureSkipVerify, with true the predeclared constant. A value that comes from a flag or a setting is left alone: it is the user's choice.
From the rule's source, tls_verification_disabled.rs.
package p import ( "crypto/tls" "net/http") func client(insecure bool) *http.Client { cfg := &tls.Config{InsecureSkipVerify: true}tx0 reports: certificate verification is turned off, so any server is trusted other := &tls.Config{} other.InsecureSkipVerify = truetx0 reports: certificate verification is turned off, so any server is trusted chosen := &tls.Config{InsecureSkipVerify: insecure} _ = chosen _ = other return &http.Client{Transport: &http.Transport{TLSClientConfig: cfg}}} Turn it on, off or suppress it
The rule runs from the recommended tier up. To turn it on in a lower tier, give it a level in tx0.toml:
[rules]
"tx0/go:tls-verification-disabled" = "warning"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/go:tls-verification-disabled] reason="..."tx0 explain tx0/go:tls-verification-disabled shows the same in the terminal. Found a false positive? Report it.