﻿# V5911\. OWASP\. Insecure TLS configuration can lead to improper certificate validation, making the connection vulnerable\.

The analyzer has detected an improper certificate validation during the establishment of a TLS connection\. 

In this case, the application cannot verify that it is communicating with the specific node it is connecting to\. An attacker who gains access to the network path between the client and the server can impersonate a trusted node and carry out a [man\-in\-the\-middle](https://en.wikipedia.org/wiki/Man-in-the-middle_attack) \(MITM\) attack\.

The connection remains encrypted, but the attacker decrypts it on their own end: they can read confidential data and also tamper with requests and responses\.

Vulnerabilities related to improper certificate validation fall under [A07:2025 Authentication Failures](https://top10.owasp.org/2025/A07_2025-Authentication_Failures/) in the OWASP Top 10 Application Security Risks 2025\.

The example N1:

```cpp
func FetchReport(w http.ResponseWriter, r *http.Request) {
  client := &http.Client{
    Transport: &http.Transport{
      TLSClientConfig: &tls.Config{
        InsecureSkipVerify: true,
      },
    },
  }
  resp, err := client.Get("https://reports.example.com/daily")
  ....
}
```

Setting the `InsecureSkipVerify` field to `true` turns off server certificate verification entirely\. The client will accept any certificate: expired, untrusted, or issued for a different domain name\.

If the server uses a publicly trusted certificate, simply remove the `InsecureSkipVerify` field, since verification is enabled by default\. If the certificate was issued by a private certificate authority, add that authority's root certificate to the client's trust store through the `RootCAs` field:

```cpp
func FetchReport(w http.ResponseWriter, r *http.Request) {
  caCert, err := os.ReadFile("/etc/ssl/certs/internal-ca.pem")
  ....
  roots := x509.NewCertPool()
  roots.AppendCertsFromPEM(caCert)
  client := &http.Client{
    Transport: &http.Transport{
      TLSClientConfig: &tls.Config{
        RootCAs: roots,
      },
    },
  }
  resp, err := client.Get("https://reports.example.com/daily")
  ....
}
```

The example N2:

```cpp
client := &http.Client{
  Transport: &http.Transport{
    TLSClientConfig: &tls.Config{
      MinVersion: tls.VersionTLS10,
    },
  },
}
```

It allows [outdated](https://datatracker.ietf.org/doc/rfc8996/) versions of the TLS 1\.0 and TLS 1\.1 protocols, which have known vulnerabilities and rely on weak cryptographic algorithms\. If the client permits their use, a connection to the server may be established using an outdated protocol version, and an attacker could exploit its weaknesses\.

The minimum protocol version should be set to TLS 1\.2 or higher:

```cpp
client := &http.Client{
  Transport: &http.Transport{
    TLSClientConfig: &tls.Config{
      MinVersion: tls.VersionTLS12,
    },
  },
}
```

You can find more security recommendations on the OWASP Cheat Sheet Series pages, such as:

* [Transport Layer Security Cheat Sheet](https://cheatsheetseries.owasp.org/cheatsheets/Transport_Layer_Security_Cheat_Sheet.html)
* [Pinning Cheat Sheet](https://cheatsheetseries.owasp.org/cheatsheets/Pinning_Cheat_Sheet.html)